1package jwt
2
3import "testing"
4
5func Test_mapClaims_list_aud(t *testing.T){
6	mapClaims := MapClaims{
7		"aud": []string{"foo"},
8	}
9	want := true
10	got := mapClaims.VerifyAudience("foo", true)
11
12	if want != got {
13		t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got)
14	}
15}
16func Test_mapClaims_string_aud(t *testing.T){
17	mapClaims := MapClaims{
18		"aud": "foo",
19	}
20	want := true
21	got := mapClaims.VerifyAudience("foo", true)
22
23	if want != got {
24		t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got)
25	}
26}
27
28func Test_mapClaims_list_aud_no_match(t *testing.T){
29	mapClaims := MapClaims{
30		"aud": []string{"bar"},
31	}
32	want := false
33	got := mapClaims.VerifyAudience("foo", true)
34
35	if want != got {
36		t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got)
37	}
38}
39func Test_mapClaims_string_aud_fail(t *testing.T){
40	mapClaims := MapClaims{
41		"aud": "bar",
42	}
43	want := false
44	got := mapClaims.VerifyAudience("foo", true)
45
46	if want != got {
47		t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got)
48	}
49}
50
51func Test_mapClaims_string_aud_no_claim(t *testing.T){
52	mapClaims := MapClaims{
53	}
54	want := false
55	got := mapClaims.VerifyAudience("foo", true)
56
57	if want != got {
58		t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got)
59	}
60}
61
62func Test_mapClaims_string_aud_no_claim_not_required(t *testing.T){
63	mapClaims := MapClaims{
64	}
65	want := false
66	got := mapClaims.VerifyAudience("foo", false)
67
68	if want != got {
69		t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got)
70	}
71}