mirror of
https://github.com/kopia/kopia.git
synced 2026-03-27 02:21:59 -04:00
* feat(infra): improved support for in-process testing * support for killing of a running server using simulated Ctrl-C * support for overriding os.Stdin * migrated many tests from the exe runner to in-process runner * added required indirection when defining Envar() so we can later override it in tests * refactored CLI runners by moving environment overrides to CLITestEnv
45 lines
1.6 KiB
Go
45 lines
1.6 KiB
Go
package cli_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/kopia/kopia/repo/content"
|
|
"github.com/kopia/kopia/tests/testenv"
|
|
)
|
|
|
|
func (s *formatSpecificTestSuite) TestRepositoryChangePassword(t *testing.T) {
|
|
r1 := testenv.NewInProcRunner(t)
|
|
r2 := testenv.NewInProcRunner(t)
|
|
env1 := testenv.NewCLITest(t, s.formatFlags, r1)
|
|
env2 := testenv.NewCLITest(t, s.formatFlags, r2)
|
|
|
|
env1.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", env1.RepoDir, "--disable-repository-format-cache")
|
|
|
|
if s.formatVersion == content.FormatVersion1 {
|
|
env1.RunAndExpectFailure(t, "repo", "change-password", "--new-password", "newPass")
|
|
|
|
return
|
|
}
|
|
|
|
env1.RunAndExpectSuccess(t, "snapshot", "ls")
|
|
|
|
// connect to repo with --disable-repository-format-cache so that format blob is not cached
|
|
// this makes password changes immediate
|
|
env2.RunAndExpectSuccess(t, "repo", "connect", "filesystem", "--path", env1.RepoDir, "--disable-repository-format-cache")
|
|
env2.RunAndExpectSuccess(t, "snapshot", "ls")
|
|
|
|
env1.RunAndExpectSuccess(t, "repo", "change-password", "--new-password", "newPass")
|
|
|
|
// at this point env2 stops working
|
|
env2.RunAndExpectFailure(t, "snapshot", "ls")
|
|
|
|
// new connections will fail when using old (default) password
|
|
env3 := testenv.NewCLITest(t, s.formatFlags, testenv.NewInProcRunner(t))
|
|
env3.RunAndExpectFailure(t, "repo", "connect", "filesystem", "--path", env1.RepoDir, "--disable-repository-format-cache")
|
|
|
|
// new connections will succeed when using new password
|
|
env3.Environment["KOPIA_PASSWORD"] = "newPass"
|
|
|
|
env3.RunAndExpectSuccess(t, "repo", "connect", "filesystem", "--path", env1.RepoDir, "--disable-repository-format-cache")
|
|
}
|