Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Test

on: push
on:
push:
pull_request:

jobs:
run-tests:
Expand Down
4 changes: 2 additions & 2 deletions packages/auth0/test/fixtures/rules-async-only/async-rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ async function asyncRule(user, context, callback) {
// these is a contrived rule, but entirely possible
// that someone would run a fetch and attach output
// to the user as part of the token
let checkURLOne = "https://frontside.com";
let checkURLOne = `${__simulator.context.idToken.iss}frontside`;
user.checkURLOne = checkURLOne;
let checkOne = await fetcher(checkURLOne);
user.checkURLOneStatus = checkOne.checkURLStatus;
user.checkURLOneText = checkOne.checkURLText.toLowerCase();

// this is a sub-site with various redirects to it should
// take some time to revolve
let checkURLTwo = "https://frontside.com/effection";
let checkURLTwo = `${__simulator.context.idToken.iss}effection`;
user.checkURLTwo = checkURLTwo;
let checkTwo = await fetcher(checkURLTwo);
user.checkURLTwoStatus = checkTwo.checkURLStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ function syncWrapper(user, context, callback) {
// these is a contrived rule, but entirely possible
// that someone would run a fetch and attach output
// to the user as part of the token
let checkURLOne = "https://frontside.com";
let checkURLOne = `${__simulator.context.idToken.iss}frontside`;
user.checkURLOne = checkURLOne;

// this is a sub-site with various redirects to it should
// take some time to revolve
let checkURLTwo = "https://frontside.com/effection";
let checkURLTwo = `${__simulator.context.idToken.iss}effection`;
user.checkURLTwo = checkURLTwo;

let fetcher = async (url) => {
Expand Down
22 changes: 18 additions & 4 deletions packages/auth0/test/rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ async function createSimulation(rulesDirectory: Fixtures, initialPerson?: Partia
users: [simulationPerson],
},
options: { rulesDirectory },
extend: {
extendRouter(router) {
router.get("/frontside", (_req, res) => {
res.send(
"<!DOCTYPE html><html><head><title>frontside</title></head><body></body></html>",
);
});
router.get("/effection", (_req, res) => {
res.send(
"<!DOCTYPE html><html><head><title>effection</title></head><body></body></html>",
);
});
},
},
});
let server = await app.listen(basePort);

Expand Down Expand Up @@ -233,10 +247,10 @@ describe("rules", () => {
const idToken = decodeJwt(token.id_token);
expect(idToken.name).toBe(person.name);

expect(idToken?.checkURLOne).toBe("https://frontside.com");
expect(idToken?.checkURLOne).toBe(`${auth0Url}/frontside`);
expect(idToken?.checkURLOneStatus).toBe(200);
expect(idToken?.checkURLOneText).toBe("frontside");
expect(idToken?.checkURLTwo).toBe("https://frontside.com/effection");
expect(idToken?.checkURLTwo).toBe(`${auth0Url}/effection`);
expect(idToken?.checkURLTwoStatus).toBe(200);
expect(idToken?.checkURLTwoText).toBe("effection");
await server.ensureClose();
Expand Down Expand Up @@ -265,11 +279,11 @@ describe("rules", () => {
const idToken = decodeJwt(token.id_token);
expect(idToken.name).toBe(person.name);

expect(idToken?.checkURLOne).toBe("https://frontside.com");
expect(idToken?.checkURLOne).toBe(`${auth0Url}/frontside`);
expect(idToken?.checkURLOneStatus).toBe(200);
expect(idToken?.checkURLOneText).toBe("frontside");

expect(idToken?.checkURLTwo).toBe("https://frontside.com/effection");
expect(idToken?.checkURLTwo).toBe(`${auth0Url}/effection`);
expect(idToken?.checkURLTwoStatus).toBe(200);
expect(idToken?.checkURLTwoText).toBe("effection");
await server.ensureClose();
Expand Down
Loading