use lower if the struct is private (#1185)
This commit is contained in:
parent
25e7cd75ed
commit
b70b8ab20c
12
auth.go
12
auth.go
@ -17,8 +17,8 @@ const AuthUserKey = "user"
|
|||||||
type Accounts map[string]string
|
type Accounts map[string]string
|
||||||
|
|
||||||
type authPair struct {
|
type authPair struct {
|
||||||
Value string
|
value string
|
||||||
User string
|
user string
|
||||||
}
|
}
|
||||||
|
|
||||||
type authPairs []authPair
|
type authPairs []authPair
|
||||||
@ -28,8 +28,8 @@ func (a authPairs) searchCredential(authValue string) (string, bool) {
|
|||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
for _, pair := range a {
|
for _, pair := range a {
|
||||||
if pair.Value == authValue {
|
if pair.value == authValue {
|
||||||
return pair.User, true
|
return pair.user, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "", false
|
return "", false
|
||||||
@ -74,8 +74,8 @@ func processAccounts(accounts Accounts) authPairs {
|
|||||||
assert1(user != "", "User can not be empty")
|
assert1(user != "", "User can not be empty")
|
||||||
value := authorizationHeader(user, password)
|
value := authorizationHeader(user, password)
|
||||||
pairs = append(pairs, authPair{
|
pairs = append(pairs, authPair{
|
||||||
Value: value,
|
value: value,
|
||||||
User: user,
|
user: user,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return pairs
|
return pairs
|
||||||
|
12
auth_test.go
12
auth_test.go
@ -22,16 +22,16 @@ func TestBasicAuth(t *testing.T) {
|
|||||||
|
|
||||||
assert.Len(t, pairs, 3)
|
assert.Len(t, pairs, 3)
|
||||||
assert.Contains(t, pairs, authPair{
|
assert.Contains(t, pairs, authPair{
|
||||||
User: "bar",
|
user: "bar",
|
||||||
Value: "Basic YmFyOmZvbw==",
|
value: "Basic YmFyOmZvbw==",
|
||||||
})
|
})
|
||||||
assert.Contains(t, pairs, authPair{
|
assert.Contains(t, pairs, authPair{
|
||||||
User: "foo",
|
user: "foo",
|
||||||
Value: "Basic Zm9vOmJhcg==",
|
value: "Basic Zm9vOmJhcg==",
|
||||||
})
|
})
|
||||||
assert.Contains(t, pairs, authPair{
|
assert.Contains(t, pairs, authPair{
|
||||||
User: "admin",
|
user: "admin",
|
||||||
Value: "Basic YWRtaW46cGFzc3dvcmQ=",
|
value: "Basic YWRtaW46cGFzc3dvcmQ=",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user