diff --git a/tests/cypress/integration/admin/09-add-km.spec.js b/tests/cypress/integration/admin/09-add-edit-delete-km.spec.js similarity index 55% rename from tests/cypress/integration/admin/09-add-km.spec.js rename to tests/cypress/integration/admin/09-add-edit-delete-km.spec.js index c193c2f848e..92fd1adced0 100644 --- a/tests/cypress/integration/admin/09-add-km.spec.js +++ b/tests/cypress/integration/admin/09-add-edit-delete-km.spec.js @@ -16,14 +16,14 @@ * under the License. */ +import Utils from "@support/utils"; + describe("Add key manager", () => { - const carbonUsername = 'admin'; - const carbonPassword = 'admin'; - before(function () { - cy.loginToAdmin(carbonUsername, carbonPassword); - }) - it.only("Add key manager", () => { + const { carbonUsername, carbonPassword, tenant, superTenant } = Utils.getUserInfo(); + + const addKeyManager = (usernameLocal, passwordLocal) => { + cy.loginToAdmin(usernameLocal, passwordLocal); const km = 'myAuth0'; const wellKnowUrl = 'https://my-tenant.us.auth0.com/.well-known/openid-configuration'; const clientId = 'test'; @@ -32,6 +32,10 @@ describe("Add key manager", () => { const introspectionEp = 'https://my-tenant.auth0.com/oauth/token'; const userInfoEp = 'https://my-tenant.auth0.com/oauth/userInfo'; const scopeManagementEp = 'https://my-tenant.auth0.com/oauth/scope'; + const claimKey1 = 'claimKey1'; + const claimValueRegex1 = 'claimValueRegex1'; + const claimKey2 = 'claimKey2'; + const claimValueRegex2 = 'claimValueRegex2'; cy.get('[data-testid="Key Managers"]').click(); cy.get('.MuiButton-label').contains('Add Key Manager').click(); @@ -51,16 +55,47 @@ describe("Add key manager", () => { cy.get('input[name="client_id"]').type(clientId); cy.get('input[name="client_secret"]').type(clientSecret); cy.get('input[name="audience"]').type(audience); + // adding claims under Token Handling Options for JWT type + cy.get('#mui-component-select-type').click(); + cy.contains('li', 'JWT').click(); + cy.get('input[name="claimKey"]').type(claimKey1); + cy.get('input[name="claimValueRegex"]').type(claimValueRegex1); + cy.get('[aria-label="[object Object]"]').click(); + cy.get('input[name="claimKey"]').type(claimKey2); + cy.get('input[name="claimValueRegex"]').type(claimValueRegex2); + cy.get('[aria-label="[object Object]"]').click(); + // validating added claims + cy.contains(claimKey1).should('exist'); + cy.contains(claimValueRegex1).should('exist'); + cy.contains(claimKey2).should('exist'); + cy.contains(claimValueRegex2).should('exist'); cy.get('button.MuiButton-containedPrimary span').contains('Add').click(); + cy.wait(1000); // validating cy.get('td > div').contains(km).should('exist'); }); + // edit key manager + cy.get('td > div').contains(km).click(); + // editing claims under Token Handling Options for JWT type (adding one more claim and deleting one claim) + cy.get('input[name="claimKey"]').type('claimKey3'); + cy.get('input[name="claimValueRegex"]').type('claimValueRegex3'); + cy.get('[aria-label="[object Object]"]').click(); + // deleting claimKey1 + cy.contains(claimKey1).parents('tr').find('button').click(); + cy.contains(claimKey1).should('not.exist'); + cy.get('button.MuiButton-containedPrimary span').contains('Update').click(); + // delete cy.get(`[data-testid="${km}-actions"] > span:first-child svg`).click(); cy.get('button > span').contains('Delete').click(); cy.get('td > div').contains(km).should('not.exist'); + } + it.only("Add key manager - super admin", () => { + addKeyManager(carbonUsername, carbonPassword); }); - -}) \ No newline at end of file + it.only("Add key manager - tenant user", () => { + addKeyManager(Utils.getTenantUser(carbonUsername, tenant), carbonPassword); + }); +})