diff --git a/le-taxi-api-tests/config/configs.ts b/le-taxi-api-tests/config/configs.ts index a3d1e32..3d2d19e 100644 --- a/le-taxi-api-tests/config/configs.ts +++ b/le-taxi-api-tests/config/configs.ts @@ -98,7 +98,9 @@ export class Configs { */ get apiTests() { return { - rootApiKey: this.cache.get("apiTests.rootApiKey"), + rootApiKey: this.environment.isAcc + ? this.cache.get("apiTests.performanceTests.rootApiKey") + : this.cache.get("apiTests.rootApiKey"), user: this.cache.get("apiTests.user"), password: this.cache.get("apiTests.password"), }; @@ -155,6 +157,8 @@ export let configs: Configs = Configs.instance; export function getAbsoluteUrl(relative: string): string { if (configs.environment.isDev) { + return `https://taximtldev.accept.ville.montreal.qc.ca${relative}`; + } else if (configs.environment.isAcc) { return `https://taximtl.accept.ville.montreal.qc.ca${relative}`; } diff --git a/le-taxi-api-tests/package.json b/le-taxi-api-tests/package.json index 54787f7..51d99d7 100644 --- a/le-taxi-api-tests/package.json +++ b/le-taxi-api-tests/package.json @@ -12,11 +12,11 @@ "load-test-optional-realtime-booking-no-destination": "tsc && node node_modules/artillery/bin/artillery run -o test-optional-realtime-booking-no-destination.report.json src/taxis/loadTests/test-realtime-booking-no-destination.yaml && node node_modules/artillery/bin/artillery report -o test-optional-realtime-booking-no-destination.report.html test-optional-realtime-booking-no-destination.report.json", "load-test-optional-trigger-many-bad-requests-alert": "tsc && node node_modules/artillery/bin/artillery run src/taxis/loadTests/test-trigger-many-bad-requests-alert.yaml", "load-test-optional-trigger-many-errors-alert": "tsc && node node_modules/artillery/bin/artillery run src/taxis/loadTests/test-trigger-many-errors-alert.yaml", - "load-test-taxi-position-snapshot-data-dump": "tsc && node node_modules/artillery/bin/artillery run -o test-taxi-position-snapshot-data-dump.report.json src/taxiPositionSnapshotDataDumps/loadTests/test-taxi-position-snapshot-data-dump.yaml && node node_modules/artillery/bin/artillery report -o test-taxi-position-snapshot-data-dump.report.html test-taxi-position-snapshot-data-dump.report.json", - "load-test-taxi-grid": "tsc && node node_modules/artillery/bin/artillery run -o test-taxi-grid.report.json src/taxis/loadTests/test-taxi-grid.yaml && node node_modules/artillery/bin/artillery report -o test-taxi-grid.report.html test-taxi-grid.report.json", - "load-test-osrm": "tsc && node node_modules/artillery/bin/artillery run -o test-osrm.report.json src/osrm/loadTests/test-osrm.yaml && node node_modules/artillery/bin/artillery report -o test-osrm.report.html test-osrm.report.json", - "generate-load-test-shared-state": "env NODE_ENV=development npm run launch-generate-load-test-shared-state", - "generate-integration-tests-shared-state": "env NODE_ENV=development npm run launch-generate-integration-tests-shared-state", + "load-test-taxi-position-snapshot-data-dump": "tsc && env NODE_ENV=acceptation node node_modules/artillery/bin/artillery run -o test-taxi-position-snapshot-data-dump.report.json src/taxiPositionSnapshotDataDumps/loadTests/test-taxi-position-snapshot-data-dump.yaml && node node_modules/artillery/bin/artillery report -o test-taxi-position-snapshot-data-dump.report.html test-taxi-position-snapshot-data-dump.report.json", + "load-test-taxi-grid": "tsc && env NODE_ENV=acceptation node node_modules/artillery/bin/artillery run -o test-taxi-grid.report.json src/taxis/loadTests/test-taxi-grid.yaml && node node_modules/artillery/bin/artillery report -o test-taxi-grid.report.html test-taxi-grid.report.json", + "load-test-osrm": "tsc &&node node_modules/artillery/bin/artillery run -o test-osrm.report.json src/osrm/loadTests/test-osrm.yaml && node node_modules/artillery/bin/artillery report -o test-osrm.report.html test-osrm.report.json", + "generate-load-test-shared-state": "env NODE_ENV=acceptation npm run launch-generate-load-test-shared-state", + "generate-integration-tests-shared-state": "env NODE_ENV=acceptation npm run launch-generate-integration-tests-shared-state", "clean": "rimraf src/**/*.js src/**/*.js.map", "watch": "npm run clean && tsc --watch --pretty", "lint": "npm run prettier && npm run tslint", diff --git a/le-taxi-api-tests/src/users/user.apiClient.ts b/le-taxi-api-tests/src/users/user.apiClient.ts index 6e82d1b..242c2f7 100644 --- a/le-taxi-api-tests/src/users/user.apiClient.ts +++ b/le-taxi-api-tests/src/users/user.apiClient.ts @@ -1,47 +1,68 @@ // Licensed under the AGPL-3.0 license. // See LICENSE file in the project root for full license information. -import { v4 as uuidv4 } from 'uuid'; -import { configs } from '../../config/configs'; -import { aFewSeconds } from '../shared/commonTests/testUtil'; -import { UserRole } from '../shared/commonTests/UserRole'; -import { getTestRunId } from '../shared/e2eTesting/testRunId'; -import { IUser } from '../shared/taxiRegistryDtos/taxiRegistryDtos'; +import { v4 as uuidv4 } from "uuid"; +import { configs } from "../../config/configs"; +import { aFewSeconds } from "../shared/commonTests/testUtil"; +import { UserRole } from "../shared/commonTests/UserRole"; +import { getTestRunId } from "../shared/e2eTesting/testRunId"; +import { IUser } from "../shared/taxiRegistryDtos/taxiRegistryDtos"; import { getSimpleUsingAccessToken, getTaxiRegistry, postSimple, postTaxiRegistry, - putTaxiRegistry -} from '../shared/taxiRegistryHttp/taxiRegistryHttp'; -import { getImmutableUserApiKey } from './user.sharedFixture'; -import { copyUserTemplate } from './userDto.template'; + putTaxiRegistry, +} from "../shared/taxiRegistryHttp/taxiRegistryHttp"; +import { getImmutableUserApiKey } from "./user.sharedFixture"; +import { copyUserTemplate } from "./userDto.template"; const rootApiKey = configs.apiTests.rootApiKey; +console.log("rootApiKey", rootApiKey); export async function createPromotedOperator(dto: IUser, apiKey?: string) { - if (dto.email === 'auto') dto.email = generateAutoEmail(); - if (dto.public_id === 'auto') dto.public_id = uuidv4(); - - const userResponse = await postTaxiRegistry('/api/legacy-web/users', dto, apiKey, rootApiKey); + if (dto.email === "auto") dto.email = generateAutoEmail(); + if (dto.public_id === "auto") dto.public_id = uuidv4(); + + const userResponse = await postTaxiRegistry( + "/api/legacy-web/users", + dto, + apiKey, + rootApiKey + ); await aFewSeconds(configs.inquiries.delayToExceedPromotion); return userResponse.body; } export async function createUser(dto: IUser, apiKey?: string) { - if (dto.email === 'auto') dto.email = generateAutoEmail(); - if (dto.public_id === 'auto') dto.public_id = dto.role === UserRole.Operator ? uuidv4() : null; - - const userResponse = await postTaxiRegistry('/api/legacy-web/users', dto, apiKey, rootApiKey); + if (dto.email === "auto") dto.email = generateAutoEmail(); + if (dto.public_id === "auto") + dto.public_id = dto.role === UserRole.Operator ? uuidv4() : null; + + const userResponse = await postTaxiRegistry( + "/api/legacy-web/users", + dto, + apiKey, + rootApiKey + ); return userResponse.body; } export async function updateUser(dto: IUser, apiKey?: string) { - const userResponse = await putTaxiRegistry('/api/legacy-web/users', dto, apiKey, rootApiKey); + const userResponse = await putTaxiRegistry( + "/api/legacy-web/users", + dto, + apiKey, + rootApiKey + ); return userResponse.body; } export async function getUser(id: string, apiKey?: string): Promise { - const userResponse = await getTaxiRegistry(`/api/legacy-web/users?id=${id}`, apiKey, rootApiKey); + const userResponse = await getTaxiRegistry( + `/api/legacy-web/users?id=${id}`, + apiKey, + rootApiKey + ); return userResponse.body[0]; } @@ -50,16 +71,19 @@ export async function login(dto?: any): Promise { // tslint:disable-next-line: no-parameter-reassignment dto = { login: configs.apiTests.user, - password: configs.apiTests.password + password: configs.apiTests.password, }; } - const userResponse = await postSimple('/api/legacy-web/login/DoLogin', dto); + const userResponse = await postSimple("/api/legacy-web/login/DoLogin", dto); return userResponse; } export async function getLoginUserinfo(accessToken?: string): Promise { - const userResponse = await getSimpleUsingAccessToken('/api/legacy-web/login/userinfo', accessToken); + const userResponse = await getSimpleUsingAccessToken( + "/api/legacy-web/login/userinfo", + accessToken + ); return userResponse; } @@ -83,10 +107,20 @@ export async function updatePassword(dto?: (x: any) => void, apiKey?: string) { async function putAccountApikey(dto: any, apiKey?: string) { const defaultApiKey = await getImmutableUserApiKey(UserRole.Manager); - return await putTaxiRegistry('/api/legacy-web/users/apikey', dto, apiKey, defaultApiKey); + return await putTaxiRegistry( + "/api/legacy-web/users/apikey", + dto, + apiKey, + defaultApiKey + ); } async function putAccountPassword(dto: any, apiKey?: string) { const defaultApiKey = await getImmutableUserApiKey(UserRole.Manager); - return await putTaxiRegistry('/api/legacy-web/users/password', dto, apiKey, defaultApiKey); + return await putTaxiRegistry( + "/api/legacy-web/users/password", + dto, + apiKey, + defaultApiKey + ); }