✅ back: very basic e2e for diagnostics (#762)
This commit is contained in:
@@ -0,0 +1,51 @@
|
|||||||
|
import "reflect-metadata";
|
||||||
|
import { afterAll, beforeEach, describe, expect, it, jest } from "@jest/globals";
|
||||||
|
import { init, TestPlatform } from "../setup";
|
||||||
|
import { getConfig as getDiagnosticsConfig } from "../../../src/core/platform/framework/api/diagnostics";
|
||||||
|
|
||||||
|
describe("The diagnostics infrastucture", () => {
|
||||||
|
let platform: TestPlatform;
|
||||||
|
const diagnosticConfig = getDiagnosticsConfig();
|
||||||
|
beforeEach(async () => {
|
||||||
|
platform = await init({
|
||||||
|
services: [
|
||||||
|
"webserver",
|
||||||
|
"database",
|
||||||
|
"applications",
|
||||||
|
"search",
|
||||||
|
"storage",
|
||||||
|
"diagnostics",
|
||||||
|
"message-queue",
|
||||||
|
"user",
|
||||||
|
"files",
|
||||||
|
"auth",
|
||||||
|
"statistics",
|
||||||
|
"platform-services",
|
||||||
|
"documents",
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await platform?.tearDown();
|
||||||
|
// @ts-ignore
|
||||||
|
platform = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
const getDiagnosticTags = (tag: string, secret: string) =>
|
||||||
|
platform.app.inject({
|
||||||
|
method: "GET",
|
||||||
|
url: `/api/diagnostics/t/${encodeURIComponent(tag)}?secret=${encodeURIComponent(secret)}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should refuse invalid probe secrets", async () => {
|
||||||
|
const result = await getDiagnosticTags("ready", "ooooh look at me ! I'm like totally such an invalid probeSecret value");
|
||||||
|
expect(result.statusCode).toBe(403);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should at least report alive", async () => {
|
||||||
|
const result = await getDiagnosticTags("ready", diagnosticConfig.probeSecret!);
|
||||||
|
expect(result.statusCode).toBe(200);
|
||||||
|
expect(result.json().ok).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -68,6 +68,8 @@ services:
|
|||||||
- SEARCH_OS_PASSWORD=admin
|
- SEARCH_OS_PASSWORD=admin
|
||||||
- SEARCH_OS_USE_AUTH=true
|
- SEARCH_OS_USE_AUTH=true
|
||||||
- SEARCH_OS_USERNAME=admin
|
- SEARCH_OS_USERNAME=admin
|
||||||
|
- DIAG_PROBE_SECRET=super_diagnostic_probe_secret
|
||||||
|
- DIAG_SECRET=super_diagnostic_secret
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
- opensearch-node1
|
- opensearch-node1
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ services:
|
|||||||
- STORAGE_S3_ENDPOINT=minio
|
- STORAGE_S3_ENDPOINT=minio
|
||||||
- STORAGE_S3_ACCESS_KEY=admin
|
- STORAGE_S3_ACCESS_KEY=admin
|
||||||
- STORAGE_S3_SECRET_KEY=adminminio
|
- STORAGE_S3_SECRET_KEY=adminminio
|
||||||
|
- DIAG_PROBE_SECRET=super_diagnostic_probe_secret
|
||||||
|
- DIAG_SECRET=super_diagnostic_secret
|
||||||
depends_on:
|
depends_on:
|
||||||
minio:
|
minio:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
Reference in New Issue
Block a user