-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add db cleanup for integration testing
- Loading branch information
1 parent
29aad81
commit dbecd24
Showing
30 changed files
with
558 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Il9RUGlhWnJaOVMxSDNpNmhLQXFQeCJ9.eyJpc3MiOiJodHRwczovL3VzZW1pbGxlcmRldi5hdS5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8NjNlMGVlNDc0OGNjNmE3ZDQzMmRlMjUwIiwiYXVkIjpbImJhY2tlbmQtYXBpLWF1ZGllbmNlIiwiaHR0cHM6Ly91c2VtaWxsZXJkZXYuYXUuYXV0aDAuY29tL3VzZXJpbmZvIl0sImlhdCI6MTY3ODI1ODI2MiwiZXhwIjoxNjc4MzQ0NjYyLCJhenAiOiJVbzNjZHp3bVpUOWtMenF4TGtJbnZ5cVFZbzRsVWVqMiIsInNjb3BlIjoib3BlbmlkIGVtYWlsIHByb2ZpbGUgb2ZmbGluZV9hY2Nlc3MiLCJndHkiOiJwYXNzd29yZCIsInBlcm1pc3Npb25zIjpbXX0.mUbibCSOGWGdadKBKf8ARYbT9-z3J4KwKMpjMYz0v0rwA4rnZax0-xNHPmWZTUOTWZZMXijyT6uevyPygs9BWzXXKItc5qOQYdIUjRLaeRsUdOewYVWiiA8u7yBug7VloQhHXrUK307fPdtZZ4qJdwzLoNqhvpbaLumWMlO8v8SmzddzHrkggqSsQiMVGvAif4YnfM_v7nR8VH0CaMKM_JxzHULC2swBtpEiSGXBaj331PE7Lsds5eF9fMXvEWRzn6uwa-JVQyFaJN09eAqgb9wpUn0x9wejbkDQb47iddmyJpWq_4IHEbD_d9KAbnIzehPbBmuISJI0Bx6VnLgKuQ","date_received":"2023-03-08T06:51:02.152Z","expires_in":86400,"token_type":"Bearer"} | ||
{"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Il9RUGlhWnJaOVMxSDNpNmhLQXFQeCJ9.eyJpc3MiOiJodHRwczovL3VzZW1pbGxlcmRldi5hdS5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8NjNlMGVlNDc0OGNjNmE3ZDQzMmRlMjUwIiwiYXVkIjpbImJhY2tlbmQtYXBpLWF1ZGllbmNlIiwiaHR0cHM6Ly91c2VtaWxsZXJkZXYuYXUuYXV0aDAuY29tL3VzZXJpbmZvIl0sImlhdCI6MTY3ODYyMDgyMCwiZXhwIjoxNjc4NzA3MjIwLCJhenAiOiJVbzNjZHp3bVpUOWtMenF4TGtJbnZ5cVFZbzRsVWVqMiIsInNjb3BlIjoib3BlbmlkIGVtYWlsIHByb2ZpbGUgb2ZmbGluZV9hY2Nlc3MiLCJndHkiOiJwYXNzd29yZCIsInBlcm1pc3Npb25zIjpbXX0.D7SWSfqCKEsfXezd9paIkiNUgi1nm6oaB9ZmEnFbi1FbocbDZojahF2YHyt3C7XIygJx6LP0Bk67KOYxcuDzYBuk-HWAgXBCKM_nipqkyDdUS8fpha6fOdmcBrdYucZsqrvdfFVTmuHtcgqYgYyUpZGT7033-JB2CZYiGnoYIPQaqq00e_QAHAF0X-We8TvCdOUujRmKo0phCHlBxiFJ6HFIf9uhapnfpXU5BJH41Qx0L3A2MNaTNWktOjD2yqm-9SCtESUceIw6zqRzB1kBIsYfk1Wa11ixGDuntIcCHajrU_mbAtAKODfThZPmKrgIjcQk9ci75AhvDVY0P8flpA","date_received":"2023-03-12T11:33:40.353Z","expires_in":86400,"token_type":"Bearer"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{ | ||
"preset": "ts-jest", | ||
"roots": ["<rootDir>/src"], | ||
"testEnvironment": "jsdom", | ||
"extensionsToTreatAsEsm": [".ts"], | ||
"testRegex": ".e2e-spec.ts$", | ||
"setupFiles": ["<rootDir>/src/preRun.ts"], | ||
"globals": { | ||
"ts-jest": { | ||
"useESM": true | ||
"preset": "ts-jest", | ||
"roots": ["<rootDir>/src"], | ||
"testEnvironment": "jsdom", | ||
"extensionsToTreatAsEsm": [".ts"], | ||
"testRegex": ".e2e-spec.ts$", | ||
"setupFiles": ["dotenv/config", "<rootDir>/src/preRun.ts"], | ||
"globals": { | ||
"ts-jest": { | ||
"useESM": true | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
apps/backend-e2e/src/miller-tests/basic-security.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* eslint-disable sonarjs/no-duplicate-string */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
import { ApplicationSupportApi } from "@use-miller/shared-api-client"; | ||
import { ApiClientFactory } from "./commonDataModels/ApiClientFactory"; | ||
import { TestUserAccounts } from "./commonDataModels/AuthenticationTokenManager"; | ||
|
||
describe("For unauthenticated users", () => { | ||
const applicationSupportApi = | ||
ApiClientFactory.getUnAuthenticatedApiInstance(ApplicationSupportApi); | ||
|
||
it("unsecure endpoints are reachable", async () => { | ||
const response = await applicationSupportApi.appControllerGetHello(); | ||
expect(response).toEqual("Healthy and running"); | ||
}); | ||
|
||
it("secure endpoints are blocked", async () => { | ||
await expect(() => | ||
applicationSupportApi.appControllerGetHelloAuthorized() | ||
).rejects.toMatchObject({ status: 401 }); | ||
}); | ||
|
||
it("super secure endpoints are blocked", async () => { | ||
await expect(() => | ||
applicationSupportApi.appControllerGetHelloSuperAdmin() | ||
).rejects.toMatchObject({ status: 401 }); | ||
}); | ||
}); | ||
|
||
describe("For normal authorized users", () => { | ||
const applicationSupportApi = ApiClientFactory.getAuthenticatedApiInstance( | ||
ApplicationSupportApi | ||
); | ||
|
||
it("unsecure endpoints are reachable", async () => { | ||
const response = await applicationSupportApi.appControllerGetHello(); | ||
expect(response).toEqual("Healthy and running"); | ||
}); | ||
|
||
it("secures endpoints are reachable", async () => { | ||
const response = | ||
await applicationSupportApi.appControllerGetHelloAuthorized(); | ||
expect(response).toEqual("Healthy and running"); | ||
}); | ||
|
||
it("super secure endpoints are blocked", async () => { | ||
await expect(() => | ||
applicationSupportApi.appControllerGetHelloSuperAdmin() | ||
).rejects.toMatchObject({ status: 403 }); | ||
}); | ||
}); | ||
|
||
describe("For super admin authorized users", () => { | ||
const applicationSupportApi = ApiClientFactory.getAuthenticatedApiInstance( | ||
ApplicationSupportApi, | ||
TestUserAccounts.SUPER_USER | ||
); | ||
|
||
it("unsecure endpoints are reachable", async () => { | ||
const response = await applicationSupportApi.appControllerGetHello(); | ||
expect(response).toEqual("Healthy and running"); | ||
}); | ||
|
||
it("secures endpoints are reachable", async () => { | ||
const response = | ||
await applicationSupportApi.appControllerGetHelloAuthorized(); | ||
expect(response).toEqual("Healthy and running"); | ||
}); | ||
|
||
it("super secure endpoints are reachable", async () => { | ||
const response = | ||
await applicationSupportApi.appControllerGetHelloSuperAdmin(); | ||
expect(response).toEqual("Healthy and running"); | ||
}); | ||
|
||
afterAll(async () => { | ||
await applicationSupportApi.superPowersControllerResetDatabase(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
apps/backend-e2e/src/miller-tests/commonDataModels/WellKnownUrls.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.