From 5145a3614ec39687ec24de859da04db3a3bdcbb2 Mon Sep 17 00:00:00 2001 From: Arnav Date: Sat, 27 Apr 2024 09:56:17 +1200 Subject: [PATCH] update auth test --- cypress/e2e/authentication.cy.ts | 3 ++- cypress/e2e/consts.ts | 24 +++++++++++++++++++++++ cypress/fixtures/authSuccessResponse.json | 16 +++++++-------- frontend/app/consts.ts | 4 ---- 4 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 cypress/e2e/consts.ts diff --git a/cypress/e2e/authentication.cy.ts b/cypress/e2e/authentication.cy.ts index fa45fd1d..a993fa42 100644 --- a/cypress/e2e/authentication.cy.ts +++ b/cypress/e2e/authentication.cy.ts @@ -1,6 +1,7 @@ import authSuccessResponse from "../fixtures/authSuccessResponse.json" -import { API_URI, URLS } from "../../frontend/app/consts" +import { API_URI } from "../../frontend/app/consts" +import { URLS } from "./consts" // allows successful login without using the actual admin credentials function mockValidCredentials() { diff --git a/cypress/e2e/consts.ts b/cypress/e2e/consts.ts new file mode 100644 index 00000000..4e0a66e4 --- /dev/null +++ b/cypress/e2e/consts.ts @@ -0,0 +1,24 @@ +import { ROUTES } from "@/../../frontend/app/consts" + +let uiUri + +switch (process.env.ENV) { + case "LOCAL": { + uiUri = "http://localhost:3001" + break + } + case "DEV": { + uiUri = "https://dev.aapc-nz.org" + break + } + case "PROD": { + uiUri = "https://aapc-nz.org" + break + } + default: { + uiUri = "http://localhost:3001" + } +} + +export const UI_URI = uiUri +export const URLS = Object.fromEntries(Object.entries(ROUTES).map(([name, route]) => [name, UI_URI + route])) diff --git a/cypress/fixtures/authSuccessResponse.json b/cypress/fixtures/authSuccessResponse.json index 9aa7079a..9aa204e6 100644 --- a/cypress/fixtures/authSuccessResponse.json +++ b/cypress/fixtures/authSuccessResponse.json @@ -1,10 +1,10 @@ { - "ChallengeName": "PASSWORD_VERIFIER", - "ChallengeParameters": { - "SALT": "dc322d990fa9acff18d1945ac289368f", - "SECRET_BLOCK": "AgV4KUy/ZMIR7SnRgWW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Zje4VktFIQmEf/OYuFewTV5pVPEvjXuGXcFSgVbocjT5bReeWzfA8PLGX0Kd2RHvSsQHrDhjNpbs9ipIvLSdxxJ22+OOIgSt2FfCZPIDcRgJDi0++KDTMcZe7roar2wa6PjdwcAZczLgGZ01AZcAgiPDjDWMXyY1s40XyqYlZZ3miJ3o/vroFwxqk+Vq01nrSwsXRKsjuFWr3U82NcmN/Y9w+mL2cOQBnMGUCMQCHbp3loVdFs5ca2g4EU+Gte88E/+Rjoh/pr3X4lFTpm/yxK+DgULk7nFxMNSzKtOYCMHrAKgb5YtC5O1oKG5+Mpre+P+BfubQMt9GouKSh6sBkZW0AHmR1PJR1TrNIijZKeg==", - "SRP_B": "5b440b32210055cf4a2e26f9a1a6431001ca1b0f0ed6134a8c4a33846e6d0e90f63e8bde43900ae203a5f58afd34b462c4c873a9a9a2395a534ab5ea17ade70fc43f0e73bb8b414a6305e503068067d6ddec933d4929d89b2d3e03f6157b0022d96bae72cd9eb8f9ff08a73da76e44985489d0da790e1375bd29dd9f4168d8f60ce55d708cfc3b93e2d8effe68d499771385353a345863f58f09fcab9af9f072b95e243b200be8cd53960e972f27554a15dbb01589cce567ae90de057e531463fd1fe6192e443ec25383371b0188c5abc57273dc09c030b49077c06ba7247e858a2e38ab02b3e96506d8d8e172e28d65e067443712d9a280fc1e03b1f5b396dd1d94c8c868b23db9e6a0841f9a162a603fc2cf0204fcb0674f8784d45a7f673e2ad893bec6963084258f8b14f21325792dce2ea6e76ed1ba1b658f9e282c03a73857a3d0d0ebb29453640e19342e799704f28b6c70532fd6d928c8d6eaa317c1566f31acc41ceb69603a4f894125d41901499568e724f51f5a34dc054317a135", - "USERNAME": "e4f824f8-00d1-7046-09af-e8a9136665fc", - "USER_ID_FOR_SRP": "e4f824f8-00d1-7046-09af-e8a9136665fc" + "token": "eyJhbGciOiJIUzI1NiI2cCI6IkpXVCJ9.eyJ1c2VybmFtZSI63cGN0ZXN0MjczOTQ5NjJAZtyufgaWwuY29tIiwicm9sZXMiOlsidXNlciJdLCJpYXQiOjE3MTQxNjg0Nzd9.0nN79nWs60zIwHqzcPQBOVzvwlaLLAMgDNOR2qDtR2c", + "user": { + "username": "validemail@gmail.com", + "email": "validemail@gmail.com", + "displayName": "Admin", + "verified": true, + "registeredAt": "2024-04-26T21:54:37.898Z" } -} \ No newline at end of file +} diff --git a/frontend/app/consts.ts b/frontend/app/consts.ts index 696563df..c7593c0c 100644 --- a/frontend/app/consts.ts +++ b/frontend/app/consts.ts @@ -21,8 +21,6 @@ switch (process.env.ENV) { export const API_URI = apiUri // can add custom uri for testing here export const WEBSITE_NAME = "Aotearoa Airborne Pollen Collective" -export const UI_URI = typeof window === "undefined" ? "" : window.location.origin - export const ROUTES = { LOGIN: "/login", FORGOT_PASSWORD: "/forgot-password", @@ -30,6 +28,4 @@ export const ROUTES = { REDIRECT_AFTER_LOGIN: "/news/publish", } -export const URLS = Object.fromEntries(Object.entries(ROUTES).map(([name, route]) => [name, UI_URI + route])) - export const OPEN_CMS_ROUTES = [ROUTES.LOGIN, ROUTES.FORGOT_PASSWORD] // no auth required for these ones