diff --git a/auth.go b/auth.go index d4fa6c19..4514b15f 100644 --- a/auth.go +++ b/auth.go @@ -21,19 +21,17 @@ type Accounts map[string]string // authKVMap defines a key/value for Authorization token / user type authKVMap map[string]string - func (a authKVMap) searchCredential(authValue string) (string, bool) { if authValue == "" { return "", false } - user,ok:=a[authValue] - if !ok{ + user, ok := a[authValue] + if !ok { return "", false } - return user,true + return user, true } - // BasicAuthForRealm returns a Basic HTTP Authorization middleware. It takes as arguments a map[string]string where // the key is the user name and the value is the password, as well as the name of the Realm. // If the realm is empty, "Authorization Required" will be used by default. @@ -73,7 +71,7 @@ func processAccounts(accounts Accounts) authKVMap { for user, password := range accounts { assert1(user != "", "User can not be empty") value := authorizationHeader(user, password) - authMap[value]=user + authMap[value] = user } return authMap } diff --git a/auth_test.go b/auth_test.go index f6dbb3e4..9a06c1f6 100644 --- a/auth_test.go +++ b/auth_test.go @@ -20,11 +20,10 @@ func TestBasicAuth(t *testing.T) { "bar": "foo", }) - assert.Len(t, authMap, 3) - assert.Contains(t,authMap,"Basic YmFyOmZvbw==") - assert.Contains(t,authMap,"Basic Zm9vOmJhcg==") - assert.Contains(t,authMap,"Basic YWRtaW46cGFzc3dvcmQ=") + assert.Contains(t, authMap, "Basic YmFyOmZvbw==") + assert.Contains(t, authMap, "Basic Zm9vOmJhcg==") + assert.Contains(t, authMap, "Basic YWRtaW46cGFzc3dvcmQ=") }