Fix unit tests #7
This commit is contained in:
parent
a387121726
commit
f470bf1b53
2 changed files with 37 additions and 3 deletions
|
@ -40,7 +40,7 @@ func NewBasicAuthWebdavHandler(a *App) http.Handler {
|
|||
|
||||
func authenticate(config *Config, username, password string) (*AuthInfo, error) {
|
||||
if !config.AuthenticationNeeded() {
|
||||
return &AuthInfo{Username: "", Authenticated: true}, nil
|
||||
return &AuthInfo{Username: "", Authenticated: false}, nil
|
||||
}
|
||||
|
||||
if username == "" || password == "" {
|
||||
|
|
|
@ -24,7 +24,11 @@ func TestAuthenticate(t *testing.T) {
|
|||
{
|
||||
"empty username",
|
||||
args{
|
||||
config: &Config{},
|
||||
config: &Config{Users: map[string]*UserInfo{
|
||||
"foo": {
|
||||
Password: GenHash([]byte("password")),
|
||||
},
|
||||
}},
|
||||
username: "",
|
||||
password: "password",
|
||||
},
|
||||
|
@ -37,7 +41,11 @@ func TestAuthenticate(t *testing.T) {
|
|||
{
|
||||
"empty password",
|
||||
args{
|
||||
config: &Config{},
|
||||
config: &Config{Users: map[string]*UserInfo{
|
||||
"foo": {
|
||||
Password: GenHash([]byte("password")),
|
||||
},
|
||||
}},
|
||||
username: "foo",
|
||||
password: "",
|
||||
},
|
||||
|
@ -47,6 +55,32 @@ func TestAuthenticate(t *testing.T) {
|
|||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"empty username without users",
|
||||
args{
|
||||
config: &Config{},
|
||||
username: "",
|
||||
password: "password",
|
||||
},
|
||||
&AuthInfo{
|
||||
Username: "",
|
||||
Authenticated: false,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"empty password without users",
|
||||
args{
|
||||
config: &Config{},
|
||||
username: "foo",
|
||||
password: "",
|
||||
},
|
||||
&AuthInfo{
|
||||
Username: "",
|
||||
Authenticated: false,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"user not found",
|
||||
args{
|
||||
|
|
Loading…
Reference in a new issue