-
-
Notifications
You must be signed in to change notification settings - Fork 998
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1865 from ansible-semaphore/email_claim_format
feat: add format for oidc claims
- Loading branch information
Showing
3 changed files
with
96 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package api | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestParseClaim(t *testing.T) { | ||
claims := map[string]interface{}{ | ||
"username": "fiftin", | ||
"email": "", | ||
"id": 1234567, | ||
} | ||
|
||
res, ok := parseClaim("email | {{ .id }}@test.com", claims) | ||
|
||
if !ok { | ||
t.Fail() | ||
} | ||
|
||
if res != "1234567@test.com" { | ||
t.Fatalf("%s must be %d@test.com", res, claims["id"]) | ||
} | ||
} | ||
|
||
func TestParseClaim2(t *testing.T) { | ||
claims := map[string]interface{}{ | ||
"username": "fiftin", | ||
"email": "", | ||
"id": 1234567, | ||
} | ||
|
||
res, ok := parseClaim("username", claims) | ||
|
||
if !ok { | ||
t.Fail() | ||
} | ||
|
||
if res != claims["username"] { | ||
t.Fail() | ||
} | ||
} | ||
|
||
func TestParseClaim3(t *testing.T) { | ||
claims := map[string]interface{}{ | ||
"username": "fiftin", | ||
"email": "", | ||
"id": 1234567, | ||
} | ||
|
||
_, ok := parseClaim("email", claims) | ||
|
||
if ok { | ||
t.Fail() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters