From e0b8fe2726470d026ba6b9c468fdba392867d51f Mon Sep 17 00:00:00 2001 From: Naveen MR Date: Wed, 22 Sep 2021 22:46:25 +0100 Subject: [PATCH] Revert "test: [cypress] auth token verification" This reverts commit 534438af Signed-off-by: Naveen MR --- cypress/integration/common/5b_preview_role.js | 4 +- .../common/6b_auth_token_verification.js | 42 ------------------- 2 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 cypress/integration/common/6b_auth_token_verification.js diff --git a/cypress/integration/common/5b_preview_role.js b/cypress/integration/common/5b_preview_role.js index 13b8c2f33e..2f15771870 100644 --- a/cypress/integration/common/5b_preview_role.js +++ b/cypress/integration/common/5b_preview_role.js @@ -358,9 +358,7 @@ describe('Role preview validations', () => { genTest('editor') genTest('commenter') - - // enable post xcAuditModeCommentsCount fix - // genTest('viewer') + genTest('viewer') }) diff --git a/cypress/integration/common/6b_auth_token_verification.js b/cypress/integration/common/6b_auth_token_verification.js deleted file mode 100644 index 1c033c912c..0000000000 --- a/cypress/integration/common/6b_auth_token_verification.js +++ /dev/null @@ -1,42 +0,0 @@ -import { loginPage, projectsPage } from "../../support/page_objects/navigation" -import { staticProjects, roles } from "../../support/page_objects/projectConstants" -import { mainPage } from "../../support/page_objects/mainPage" - -// https://stackoverflow.com/questions/38552003/how-to-decode-jwt-token-in-javascript-without-using-a-library -// sample code to parse Jwt -// -function parseJwt (token) { - var base64Url = token.split('.')[1]; - var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); - var jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); - }).join('')) - - return JSON.parse(jsonPayload); -}; - -const genTest = (type, xcdb) => { - - describe(`${type.toUpperCase()} Authentication token validation`, () => { - - // Run once before test- open project (rest/graphql) - // - before(() => { - loginPage.loginAndOpenProject(type, xcdb) - }) - - it('auth info', ()=> { - var decodedToken = parseJwt(mainPage.getAuthToken()) - let email = decodedToken["email"] - let role = decodedToken["roles"] - - assert.equal(email, roles.owner.credentials.username) - assert.equal(role, "user") - }) - }) -} - -genTest('rest') -genTest('graphql') -genTest('rest', true) -genTest('graphql', true) \ No newline at end of file