diff --git a/frontend/.github/workflows/e2e.auth.yml b/frontend/.github/workflows/e2e.auth.yml index 441ef0fdfd..52cb414849 100644 --- a/frontend/.github/workflows/e2e.auth.yml +++ b/frontend/.github/workflows/e2e.auth.yml @@ -17,7 +17,6 @@ jobs: - name: Run Cypress uses: cypress-io/github-action@v2 with: - env: AUTH_TOKEN=${{ secrets.UNLEASH_TOKEN }} config: baseUrl=${{ github.event.deployment_status.target_url }} record: true spec: cypress/integration/auth/auth.spec.ts diff --git a/frontend/.github/workflows/e2e.feature.yml b/frontend/.github/workflows/e2e.feature.yml index c0826e6194..7251b60282 100644 --- a/frontend/.github/workflows/e2e.feature.yml +++ b/frontend/.github/workflows/e2e.feature.yml @@ -17,7 +17,7 @@ jobs: - name: Run Cypress uses: cypress-io/github-action@v2 with: - env: AUTH_TOKEN=${{ secrets.UNLEASH_TOKEN }} + env: AUTH_USER=test@unleash-e2e.com config: baseUrl=${{ github.event.deployment_status.target_url }} record: true spec: cypress/integration/feature/feature.spec.ts diff --git a/frontend/cypress/integration/auth/auth.spec.ts b/frontend/cypress/integration/auth/auth.spec.ts index 3d909437c9..5c7e4cf18b 100644 --- a/frontend/cypress/integration/auth/auth.spec.ts +++ b/frontend/cypress/integration/auth/auth.spec.ts @@ -1,7 +1,6 @@ /// -const username = 'test@test.com'; -const password = 'qY70$NDcJNXA'; +export {}; describe('auth', () => { it('renders the password login', () => { @@ -15,17 +14,16 @@ describe('auth', () => { type: 'password', }, }); + cy.visit('/'); cy.intercept('POST', '/auth/simple/login', req => { - expect(req.body.username).to.equal(username); - expect(req.body.password).to.equal(password); + expect(req.body.username).to.equal('admin'); + expect(req.body.password).to.equal('unleash4all'); }).as('passwordLogin'); - cy.get('[data-test="LOGIN_EMAIL_ID"]').type(username); - - cy.get('[data-test="LOGIN_PASSWORD_ID"]').type(password); - + cy.get('[data-test="LOGIN_EMAIL_ID"]').type('admin'); + cy.get('[data-test="LOGIN_PASSWORD_ID"]').type('unleash4all'); cy.get("[data-test='LOGIN_BUTTON']").click(); }); @@ -40,15 +38,15 @@ describe('auth', () => { type: 'password', }, }); + cy.visit('/'); - cy.get('[data-test="LOGIN_EMAIL_ID"]').should('not.exist'); - cy.get('[data-test="LOGIN_PASSWORD_ID"]').should('not.exist'); }); it('renders google auth when options are specified', () => { const ssoPath = '/auth/google/login'; + cy.intercept('GET', '/api/admin/user', { statusCode: 401, body: { @@ -77,6 +75,7 @@ describe('auth', () => { it('renders oidc auth when options are specified', () => { const ssoPath = '/auth/oidc/login'; + cy.intercept('GET', '/api/admin/user', { statusCode: 401, body: { @@ -105,6 +104,7 @@ describe('auth', () => { it('renders saml auth when options are specified', () => { const ssoPath = '/auth/saml/login'; + cy.intercept('GET', '/api/admin/user', { statusCode: 401, body: { @@ -149,6 +149,7 @@ describe('auth', () => { it('renders demo auth correctly', () => { const email = 'hello@hello.com'; + cy.intercept('GET', '/api/admin/user', { statusCode: 401, body: { @@ -171,6 +172,7 @@ describe('auth', () => { it('renders email auth correctly', () => { const email = 'hello@hello.com'; + cy.intercept('GET', '/api/admin/user', { statusCode: 401, body: { diff --git a/frontend/cypress/integration/feature/feature.spec.ts b/frontend/cypress/integration/feature/feature.spec.ts index af5d83fe89..9c0d1fb9ac 100644 --- a/frontend/cypress/integration/feature/feature.spec.ts +++ b/frontend/cypress/integration/feature/feature.spec.ts @@ -5,12 +5,13 @@ import { activeSplashIds } from '../../../src/component/splash/splash'; const randomId = String(Math.random()).split('.')[1]; const featureToggleName = `unleash-e2e-${randomId}`; -const enterprise = Boolean(Cypress.env('ENTERPRISE')); -const passwordAuth = Cypress.env('PASSWORD_AUTH'); -const authToken = Cypress.env('AUTH_TOKEN'); const baseUrl = Cypress.config().baseUrl; let strategyId = ''; +const AUTH_USER = Cypress.env('AUTH_USER'); +const AUTH_PASSWORD = Cypress.env('AUTH_PASSWORD'); +const ENTERPRISE = Boolean(Cypress.env('ENTERPRISE')); + describe('feature', () => { before(() => { // Visit all splash pages to mark them as seen. @@ -23,29 +24,24 @@ describe('feature', () => { cy.request({ method: 'DELETE', url: `${baseUrl}/api/admin/features/${featureToggleName}`, - headers: { Authorization: authToken }, }); cy.request({ method: 'DELETE', url: `${baseUrl}/api/admin/archive/${featureToggleName}`, - headers: { Authorization: authToken }, }); }); beforeEach(() => { disableFeatureStrategiesProductionGuard(); cy.visit('/'); + cy.get('[data-test="LOGIN_EMAIL_ID"]').type(AUTH_USER); - if (passwordAuth) { - cy.get('[data-test="LOGIN_EMAIL_ID"]').type('test@test.com'); - cy.get('[data-test="LOGIN_PASSWORD_ID"]').type('qY70$NDcJNXA'); - cy.get("[data-test='LOGIN_BUTTON']").click(); - } else { - cy.get('[data-test=LOGIN_EMAIL_ID]').type('test@unleash-e2e.com'); - cy.get('[data-test=LOGIN_BUTTON]').click(); + if (AUTH_PASSWORD) { + cy.get('[data-test="LOGIN_PASSWORD_ID"]').type(AUTH_PASSWORD); } - // Wait for the login redirects to complete. + cy.get("[data-test='LOGIN_BUTTON']").click(); + // Wait for the login redirect to complete. cy.get('[data-test=HEADER_USER_AVATAR'); }); @@ -107,7 +103,7 @@ describe('feature', () => { .click() .type('{leftarrow}'.repeat(20)); - if (enterprise) { + if (ENTERPRISE) { cy.get('[data-test=ADD_CONSTRAINT_ID]').click(); cy.get('[data-test=CONSTRAINT_AUTOCOMPLETE_ID]') .type('{downArrow}'.repeat(1)) @@ -124,7 +120,7 @@ describe('feature', () => { expect(req.body.parameters.stickiness).to.equal('default'); expect(req.body.parameters.rollout).to.equal('30'); - if (enterprise) { + if (ENTERPRISE) { expect(req.body.constraints.length).to.equal(1); } else { expect(req.body.constraints.length).to.equal(0); @@ -170,7 +166,7 @@ describe('feature', () => { expect(req.body.parameters.stickiness).to.equal('sessionId'); expect(req.body.parameters.rollout).to.equal('60'); - if (enterprise) { + if (ENTERPRISE) { expect(req.body.constraints.length).to.equal(1); } else { expect(req.body.constraints.length).to.equal(0); @@ -210,7 +206,7 @@ describe('feature', () => { `/projects/default/features/${featureToggleName}/strategies/create?environmentId=development&strategyName=userWithId` ); - if (enterprise) { + if (ENTERPRISE) { cy.get('[data-test=ADD_CONSTRAINT_ID]').click(); cy.get('[data-test=CONSTRAINT_AUTOCOMPLETE_ID]') .type('{downArrow}'.repeat(1)) @@ -233,7 +229,7 @@ describe('feature', () => { expect(req.body.parameters.userIds.length).to.equal(11); - if (enterprise) { + if (ENTERPRISE) { expect(req.body.constraints.length).to.equal(1); } else { expect(req.body.constraints.length).to.equal(0); diff --git a/frontend/package.json b/frontend/package.json index f99461abd7..fd2c2c41ee 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -33,9 +33,7 @@ "prepare": "yarn run build", "fmt": "prettier src --write --loglevel warn", "fmt:check": "prettier src --check", - "e2e": "yarn run cypress open --config baseUrl='http://localhost:3000' --env PASSWORD_AUTH=true,AUTH_TOKEN=$AUTH_TOKEN", - "e2e:heroku": "yarn run cypress open --config baseUrl='http://localhost:3000' --env PASSWORD_AUTH=false,AUTH_TOKEN=$AUTH_TOKEN", - "e2e:enterprise": "yarn run cypress open --config baseUrl='http://localhost:3000' --env PASSWORD_AUTH=true,ENTERPRISE=true,AUTH_TOKEN=$AUTH_TOKEN" + "e2e": "yarn run cypress open --config baseUrl='http://localhost:3000' --env AUTH_USER=admin,AUTH_PASSWORD=unleash4all" }, "devDependencies": { "@material-ui/core": "4.12.3",