mirror of
https://github.com/kopia/kopia.git
synced 2026-01-27 15:58:03 -05:00
* user: added user profile (username&password for authentication) and CRUD methods * manifest: helpers for disambiguating manifest entries * authn: added repository-based user authenticator * cli: added commands to manipulate user accounts and passwords * cli: added --allow-repository-users option to 'server start' * Update cli/command_user_info.go Co-authored-by: Julio López <julio+gh@kasten.io> * Always return false when the user is not found.
48 lines
822 B
Go
48 lines
822 B
Go
package user_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/kopia/kopia/internal/user"
|
|
)
|
|
|
|
func TestUserProfile(t *testing.T) {
|
|
p := &user.Profile{}
|
|
|
|
if p.IsValidPassword("bar") {
|
|
t.Fatalf("password unexpectedly valid!")
|
|
}
|
|
|
|
p.SetPassword("foo")
|
|
|
|
if !p.IsValidPassword("foo") {
|
|
t.Fatalf("password not valid!")
|
|
}
|
|
|
|
if p.IsValidPassword("bar") {
|
|
t.Fatalf("password unexpectedly valid!")
|
|
}
|
|
}
|
|
|
|
func TestNilUserProfile(t *testing.T) {
|
|
var p *user.Profile
|
|
|
|
if p.IsValidPassword("bar") {
|
|
t.Fatalf("password unexpectedly valid!")
|
|
}
|
|
}
|
|
|
|
func TestInvalidPasswordHash(t *testing.T) {
|
|
cases := [][]byte{
|
|
[]byte("**invalid*base64*"),
|
|
[]byte(""),
|
|
}
|
|
|
|
for _, tc := range cases {
|
|
p := &user.Profile{PasswordHash: tc}
|
|
if p.IsValidPassword("some-password") {
|
|
t.Fatalf("password unexpectedly valid for %v", tc)
|
|
}
|
|
}
|
|
}
|