Skip to content

Commit

Permalink
test: fix access token payload test for older cdis (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus authored Sep 15, 2022
1 parent 8256d4c commit bc1d897
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions test/session/claims/createNewSession.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,15 @@ describe(`sessionClaims/createNewSession: ${printPath("[test/session/claims/crea
if (maxVersion(apiVersion, "2.12") === "2.12") {
return;
}
const includesNullInPayload = maxVersion(apiVersion, "2.14") !== "2.14";
const response = mockResponse();
const res = await Session.createNewSession(response, "someId", payloadParam);

// The passed object should be unchanged
assert.strictEqual(Object.keys(payloadParam).length, 1);

const payload = res.getAccessTokenPayload();
assert.strictEqual(Object.keys(payload).length, 5);
assert.strictEqual(Object.keys(payload).length, includesNullInPayload ? 5 : 4);
// We have the prop from the payload param
assert.strictEqual(payload["initial"], true);
// We have the boolean claim
Expand All @@ -185,11 +186,18 @@ describe(`sessionClaims/createNewSession: ${printPath("[test/session/claims/crea
// We have the custom claim
// The resulting payload is different from the input: it doesn't container undefined
assert.deepStrictEqual(payload["user-custom"], "asdf");
assert.deepStrictEqual(payload["user-custom2"], {
inner: "asdf",
nullProp: null,
});
assert.deepStrictEqual(payload["user-custom3"], null);
if (includesNullInPayload) {
assert.deepStrictEqual(payload["user-custom2"], {
inner: "asdf",
nullProp: null,
});
assert.deepStrictEqual(payload["user-custom3"], null);
} else {
assert.deepStrictEqual(payload["user-custom2"], {
inner: "asdf",
});
assert.deepStrictEqual(payload["user-custom3"], undefined);
}
});
});
});

0 comments on commit bc1d897

Please sign in to comment.