Skip to content

Commit 96dca47

Browse files
Dasiokodiakhq[bot]
authored andcommitted
test: add multiple audiences test validation
1 parent f0790b5 commit 96dca47

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/validateIAPToken.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,35 @@ test("validate ", async (t) => {
5252
});
5353
});
5454

55+
test("validate multiple audiences ", async (t) => {
56+
const tokens = [
57+
{
58+
iss: "https://cloud.google.com/iap",
59+
aud: "expected_audience",
60+
61+
},
62+
{
63+
iss: "https://cloud.google.com/iap",
64+
aud: "expected_audience2",
65+
66+
},
67+
];
68+
for (const token of tokens) {
69+
const testJWT = mockToken(token);
70+
const payload = await validateIAPToken(
71+
testJWT,
72+
["expected_audience", "expected_audience2"],
73+
mockFetch(mockPubKeys),
74+
);
75+
t.deepEqual(payload, {
76+
iat: new Date("10 Oct 2019").getTime(),
77+
iss: token.iss,
78+
aud: token.aud,
79+
email: token.email,
80+
});
81+
}
82+
});
83+
5584
[
5685
["invalid JWT", "invalid JWT"],
5786
[

0 commit comments

Comments
 (0)