Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function jwtDecode(t) {
- let token = {};
- token.raw = t;
- token.header = JSON.parse(atob(t.toString().split('.')[0]));
- token.payload = JSON.parse(atob(t.toString().split('.')[1]));
- return (token);
- }
- console.log("JWT Decode");
- var jwt = jwtDecode(pm.response.json().access_token);
- console.log(jwt);
- pm.test("Access token to needs to have application roles assigned and granted", function () {
- pm.expect(jwt.payload.roles).to.not.equal(undefined);
- });
- pm.test("Access token must have 1 role", function () {
- pm.expect(jwt.payload.roles.length).to.equal(1);
- });
- pm.test("Access token must have XYZ role", function () {
- pm.expect(jwt.payload.roles.includes("XYZ")).to.equal(true);
- });
- if(jwt.payload.roles !== undefined)
- {
- pm.test("Access token - JWT Roles: " + jwt.payload.roles.join(), function(){});
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement