This repository has been archived by the owner on May 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 995
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
- Loading branch information
1 parent
dc14462
commit 63de7be
Showing
4 changed files
with
89 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.DS_Store | ||
bin | ||
.idea/ | ||
|
||
|
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
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,72 @@ | ||
package jwt | ||
|
||
import "testing" | ||
|
||
func Test_mapClaims_list_aud(t *testing.T){ | ||
mapClaims := MapClaims{ | ||
"aud": []string{"foo"}, | ||
} | ||
want := true | ||
got := mapClaims.VerifyAudience("foo", true) | ||
|
||
if want != got { | ||
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) | ||
} | ||
} | ||
func Test_mapClaims_string_aud(t *testing.T){ | ||
mapClaims := MapClaims{ | ||
"aud": "foo", | ||
} | ||
want := true | ||
got := mapClaims.VerifyAudience("foo", true) | ||
|
||
if want != got { | ||
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) | ||
} | ||
} | ||
|
||
func Test_mapClaims_list_aud_no_match(t *testing.T){ | ||
mapClaims := MapClaims{ | ||
"aud": []string{"bar"}, | ||
} | ||
want := false | ||
got := mapClaims.VerifyAudience("foo", true) | ||
|
||
if want != got { | ||
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) | ||
} | ||
} | ||
func Test_mapClaims_string_aud_fail(t *testing.T){ | ||
mapClaims := MapClaims{ | ||
"aud": "bar", | ||
} | ||
want := false | ||
got := mapClaims.VerifyAudience("foo", true) | ||
|
||
if want != got { | ||
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) | ||
} | ||
} | ||
|
||
func Test_mapClaims_string_aud_no_claim(t *testing.T){ | ||
mapClaims := MapClaims{ | ||
} | ||
want := false | ||
got := mapClaims.VerifyAudience("foo", true) | ||
|
||
if want != got { | ||
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) | ||
} | ||
} | ||
|
||
func Test_mapClaims_string_aud_no_claim_not_required(t *testing.T){ | ||
mapClaims := MapClaims{ | ||
//"aud": "", | ||
} | ||
want := false | ||
got := mapClaims.VerifyAudience("foo", false) | ||
|
||
if want != got { | ||
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) | ||
} | ||
} |