Skip to content

Commit

Permalink
test: add multiple audiences test validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Dasio authored and kodiakhq[bot] committed Sep 25, 2023
1 parent f0790b5 commit 96dca47
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/validateIAPToken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,35 @@ test("validate ", async (t) => {
});
});

test("validate multiple audiences ", async (t) => {
const tokens = [
{
iss: "https://cloud.google.com/iap",
aud: "expected_audience",
email: "test@test.com",
},
{
iss: "https://cloud.google.com/iap",
aud: "expected_audience2",
email: "test@test.com",
},
];
for (const token of tokens) {
const testJWT = mockToken(token);
const payload = await validateIAPToken(
testJWT,
["expected_audience", "expected_audience2"],
mockFetch(mockPubKeys),
);
t.deepEqual(payload, {
iat: new Date("10 Oct 2019").getTime(),
iss: token.iss,
aud: token.aud,
email: token.email,
});
}
});

[
["invalid JWT", "invalid JWT"],
[
Expand Down

0 comments on commit 96dca47

Please sign in to comment.