1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
package jwt
import (
"testing"
)
var audFixedValue = "Aud"
var audClaimsMapsWithValues = []MapClaims{
{
"aud": audFixedValue,
},
{
"aud": []string{audFixedValue},
},
{
"aud": []interface{}{audFixedValue},
},
}
var audClaimsMapsWithoutValues = []MapClaims{
{},
{
"aud": []string{},
},
{
"aud": []interface{}{},
},
}
// Verifies that for every form of the "aud" field, the audFixedValue is always verifiable
func TestVerifyAudienceWithVerifiableValues(t *testing.T) {
for _, data := range audClaimsMapsWithValues {
if !data.VerifyAudience(audFixedValue, true) {
t.Errorf("The audience value was not extracted properly")
}
}
}
// Verifies that for every empty form of the "aud" field, the audFixedValue cannot be verified
func TestVerifyAudienceWithoutVerifiableValues(t *testing.T) {
for _, data := range audClaimsMapsWithoutValues {
if data.VerifyAudience(audFixedValue, true) {
t.Errorf("The audience should not verify")
}
}
}
|