add a test case and document sha512crypt passwords support

This commit is contained in:
Nicola Murino
2019-09-15 12:23:27 +02:00
parent b5211fd31b
commit bba78763e1
5 changed files with 39 additions and 3 deletions

View File

@@ -1196,6 +1196,39 @@ func TestPasswordsHashBcrypt(t *testing.T) {
os.RemoveAll(user.GetHomeDir())
}
func TestPasswordsHashSHA512Crypt(t *testing.T) {
sha512CryptPwd := "$6$459ead56b72e44bc$uog86fUxscjt28BZxqFBE2pp2QD8P/1e98MNF75Z9xJfQvOckZnQ/1YJqiq1XeytPuDieHZvDAMoP7352ELkO1"
clearPwd := "secret"
usePubKey := false
u := getTestUser(usePubKey)
u.Password = sha512CryptPwd
user, _, err := api.AddUser(u, http.StatusOK)
if err != nil {
t.Errorf("unable to add user: %v", err)
}
user.Password = clearPwd
client, err := getSftpClient(user, usePubKey)
if err != nil {
t.Errorf("unable to login with sha512 crypt password: %v", err)
} else {
defer client.Close()
_, err = client.Getwd()
if err != nil {
t.Errorf("unable to get working dir with sha512 crypt password: %v", err)
}
}
user.Password = sha512CryptPwd
_, err = getSftpClient(user, usePubKey)
if err == nil {
t.Errorf("login with wrong password must fail")
}
_, err = api.RemoveUser(user, http.StatusOK)
if err != nil {
t.Errorf("unable to remove user: %v", err)
}
os.RemoveAll(user.GetHomeDir())
}
func TestPermList(t *testing.T) {
usePubKey := true
u := getTestUser(usePubKey)