Skip to content

Commit

Permalink
Tests for repository passwd
Browse files Browse the repository at this point in the history
  • Loading branch information
ma-hartma committed Jun 15, 2020
1 parent 79933e4 commit 9f3beb1
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,45 @@ func TestRepositoryIsEmpty(t *testing.T) {
t.Error("Repository should not be empty")
}
}

func TestRepositoryChangePassword(t *testing.T) {
testPassword := "this_is_a_password"
newPassword := "this_is_another_password"

dir, err := ioutil.TempDir("", "knoxite")
if err != nil {
t.Errorf("Failed creating temporary dir for repository: %s", err)
return
}
defer os.RemoveAll(dir)

_, err = NewRepository(dir, testPassword)
if err != nil {
t.Errorf("Failed creating repository: %s", err)
return
}

repo, err := OpenRepository(dir, testPassword)
if err != nil {
t.Errorf("Failed opening repository: %s", err)
return
}

if repo.ChangePassword(newPassword) != nil {
t.Errorf("Failed to change repository password: %s", err)
return
}

_, err = OpenRepository(dir, testPassword)
if err == nil {
t.Errorf("Repository can still be opened with the old password after changing it: %s", err)
return
}

_, err = OpenRepository(dir, newPassword)
if err != nil {
t.Errorf("Failed opening repository with new password after changing it: %s", err)
return
}

}

0 comments on commit 9f3beb1

Please sign in to comment.