Skip to content

Commit

Permalink
test(login): claim | which always false
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftin committed Mar 24, 2024
1 parent f982f3d commit 2457cbc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ func parseClaim(str string, claims map[string]interface{}) (string, bool) {
for _, s := range strings.Split(str, "|") {
s = strings.TrimSpace(s)

if s == "" {
continue
}

if strings.Contains(s, "{{") {
tpl, err := template.New("").Parse(s)

Expand Down
14 changes: 14 additions & 0 deletions api/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,17 @@ func TestParseClaim3(t *testing.T) {
t.Fail()
}
}

func TestParseClaim4(t *testing.T) {
claims := map[string]interface{}{
"username": "fiftin",
"email": "",
"id": 1234567,
}

_, ok := parseClaim("|", claims)

if ok {
t.Fail()
}
}

0 comments on commit 2457cbc

Please sign in to comment.