Cherry pick v1.7 into master
This commit is contained in:
parent
a09dfa3ce1
commit
b6498cdcbc
73 changed files with 6573 additions and 186 deletions
|
@ -56,7 +56,7 @@ func getLinesFromFile(filename string) ([]string, error) {
|
|||
var filteredLines []string
|
||||
for _, rawLine := range rawLines {
|
||||
line := strings.TrimSpace(rawLine)
|
||||
if line != "" {
|
||||
if line != "" && !strings.HasPrefix(line, "#") {
|
||||
filteredLines = append(filteredLines, line)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,11 +198,21 @@ func TestBasicAuthUsersFromFile(t *testing.T) {
|
|||
userFileContent: "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/\ntest2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0\n",
|
||||
givenUsers: []string{"test2:$apr1$mK.GtItK$ncnLYvNLek0weXdxo68690"},
|
||||
expectedUsers: map[string]string{"test": "test", "test2": "overridden"},
|
||||
realm: "trafikee",
|
||||
realm: "traefik",
|
||||
},
|
||||
{
|
||||
desc: "Should skip comments",
|
||||
userFileContent: "#Comment\ntest:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/\ntest2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0\n",
|
||||
givenUsers: []string{},
|
||||
expectedUsers: map[string]string{"test": "test", "test2": "test2"},
|
||||
realm: "traefiker",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
if test.desc != "Should skip comments" {
|
||||
continue
|
||||
}
|
||||
test := test
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
|
|
@ -80,10 +80,10 @@ func TestDigestAuthUsersFromFile(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Should authenticate the correct user based on the realm",
|
||||
userFileContent: "test:traefik:a2688e031edb4be6a3797f3882655c05\ntest:traefikee:316a669c158c8b7ab1048b03961a7aa5\n",
|
||||
userFileContent: "test:traefik:a2688e031edb4be6a3797f3882655c05\ntest:traefiker:a3d334dff2645b914918de78bec50bf4\n",
|
||||
givenUsers: []string{},
|
||||
expectedUsers: map[string]string{"test": "test2"},
|
||||
realm: "traefikee",
|
||||
realm: "traefiker",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue