From 7ebdb1736f319e62a53143b9b28bd8f79d6fb57c Mon Sep 17 00:00:00 2001 From: Lode Hoste Date: Thu, 30 Jul 2015 18:03:00 +0200 Subject: [PATCH 1/8] Properly rename config files during integration tests (fixes #1769) --- test/norestart_test.go | 6 +++--- test/override_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/norestart_test.go b/test/norestart_test.go index 0919bf2b..680f4e5c 100644 --- a/test/norestart_test.go +++ b/test/norestart_test.go @@ -50,7 +50,7 @@ func TestAddDeviceWithoutRestart(t *testing.T) { os.Remove("h4/config.xml.orig") os.Rename("h4/config.xml", "h4/config.xml.orig") - defer os.Rename("h4/config.xml.orig", "h4/config.xml") + defer osutil.Rename("h4/config.xml.orig", "h4/config.xml") cfg, err := p4.GetConfig() if err != nil { @@ -117,7 +117,7 @@ func TestFolderWithoutRestart(t *testing.T) { os.Remove("h1/config.xml.orig") os.Rename("h1/config.xml", "h1/config.xml.orig") - defer os.Rename("h1/config.xml.orig", "h1/config.xml") + defer osutil.Rename("h1/config.xml.orig", "h1/config.xml") cfg, err := p1.GetConfig() if err != nil { @@ -154,7 +154,7 @@ func TestFolderWithoutRestart(t *testing.T) { os.Remove("h4/config.xml.orig") os.Rename("h4/config.xml", "h4/config.xml.orig") - defer os.Rename("h4/config.xml.orig", "h4/config.xml") + defer osutil.Rename("h4/config.xml.orig", "h4/config.xml") cfg, err = p4.GetConfig() if err != nil { diff --git a/test/override_test.go b/test/override_test.go index d732850d..94c7b853 100644 --- a/test/override_test.go +++ b/test/override_test.go @@ -29,7 +29,7 @@ func TestOverride(t *testing.T) { fld.ReadOnly = true cfg.SetFolder(fld) os.Rename("h1/config.xml", "h1/config.xml.orig") - defer os.Rename("h1/config.xml.orig", "h1/config.xml") + defer osutil.Rename("h1/config.xml.orig", "h1/config.xml") cfg.Save() log.Println("Cleaning...") @@ -158,7 +158,7 @@ func TestOverrideIgnores(t *testing.T) { fld.ReadOnly = true cfg.SetFolder(fld) os.Rename("h1/config.xml", "h1/config.xml.orig") - defer os.Rename("h1/config.xml.orig", "h1/config.xml") + defer osutil.Rename("h1/config.xml.orig", "h1/config.xml") cfg.Save() log.Println("Cleaning...") From 13f47060673d5674cd1ab67f2d7c68cebc1c3c5e Mon Sep 17 00:00:00 2001 From: Lode Hoste Date: Fri, 31 Jul 2015 22:30:03 +0200 Subject: [PATCH 2/8] Clarify password in integration tests --- test/h1/config.xml | 2 +- test/norestart_test.go | 1 + test/override_test.go | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/h1/config.xml b/test/h1/config.xml index e0ae9d39..a5ab5168 100644 --- a/test/h1/config.xml +++ b/test/h1/config.xml @@ -38,7 +38,7 @@
127.0.0.1:8081
testuser - $2a$10$7tKL5uvLDGn5s2VLPM2yWOK/II45az0mTel8hxAUJDRQN1Tk2QYwu + $2a$10$7tKL5uvLDGn5s2VLPM2yWOK/II45az0mTel8hxAUJDRQN1Tk2QYwu abc123
diff --git a/test/norestart_test.go b/test/norestart_test.go index 680f4e5c..1b09bbf7 100644 --- a/test/norestart_test.go +++ b/test/norestart_test.go @@ -15,6 +15,7 @@ import ( "github.com/syncthing/protocol" "github.com/syncthing/syncthing/internal/config" + "github.com/syncthing/syncthing/internal/osutil" "github.com/syncthing/syncthing/internal/rc" ) diff --git a/test/override_test.go b/test/override_test.go index 94c7b853..d91b10a4 100644 --- a/test/override_test.go +++ b/test/override_test.go @@ -18,6 +18,7 @@ import ( "github.com/syncthing/protocol" "github.com/syncthing/syncthing/internal/config" + "github.com/syncthing/syncthing/internal/osutil" "github.com/syncthing/syncthing/internal/rc" ) From 9b0d47e9eb05b6b0b81f74fcf0393971a9c22997 Mon Sep 17 00:00:00 2001 From: Lode Hoste Date: Tue, 4 Aug 2015 09:20:46 +0200 Subject: [PATCH 3/8] Fix TestReset when Syncthing shuts down too fast --- test/reset_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/reset_test.go b/test/reset_test.go index 3854023e..9fb57d2f 100644 --- a/test/reset_test.go +++ b/test/reset_test.go @@ -10,6 +10,7 @@ package integration import ( "bytes" + "io" "log" "os" "path/filepath" @@ -68,7 +69,7 @@ func TestReset(t *testing.T) { // Reset indexes of the default folder log.Println("Reset indexes of default folder") bs, err := p.Post("/rest/system/reset?folder=default", nil) - if err != nil { + if err != nil && err != io.ErrUnexpectedEOF { t.Fatalf("Failed to reset indexes (default): %v (%s)", err, bytes.TrimSpace(bs)) } From 5cfb578170fa9001bd4e08f63f0e905e19eef90d Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Thu, 6 Aug 2015 12:07:34 +0100 Subject: [PATCH 4/8] Add timeout for peek (fixes #1035) --- cmd/syncthing/tls.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/syncthing/tls.go b/cmd/syncthing/tls.go index 6faafbe5..d8b8be05 100644 --- a/cmd/syncthing/tls.go +++ b/cmd/syncthing/tls.go @@ -102,7 +102,9 @@ func (l *DowngradingListener) Accept() (net.Conn, error) { } br := bufio.NewReader(conn) + conn.SetReadDeadline(time.Now().Add(1 * time.Second)) bs, err := br.Peek(1) + conn.SetReadDeadline(time.Time{}) if err != nil { // We hit a read error here, but the Accept() call succeeded so we must not return an error. // We return the connection as is and let whoever tries to use it deal with the error. From 161d5c8379875ae77f14e7b5dcb175426b51ee09 Mon Sep 17 00:00:00 2001 From: Lode Hoste Date: Thu, 6 Aug 2015 21:52:29 +0200 Subject: [PATCH 5/8] Make rescan available for unshared folders --- gui/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/index.html b/gui/index.html index bfaf8581..1383c64a 100755 --- a/gui/index.html +++ b/gui/index.html @@ -301,7 +301,7 @@