From dab4d0e3ff838cc380fe7ca167c11c3810d72150 Mon Sep 17 00:00:00 2001 From: Eric Doughty-Papassideris Date: Sun, 8 Dec 2024 22:53:43 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20back:=20very=20basic=20e2e=20for=20?= =?UTF-8?q?diagnostics=20(#762)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/e2e/diagnostics/diagnostics.spec.ts | 51 +++++++++++++++++++ .../docker-compose.dev.tests.opensearch.yml | 2 + tdrive/docker-compose.tests.yml | 2 + 3 files changed, 55 insertions(+) create mode 100644 tdrive/backend/node/test/e2e/diagnostics/diagnostics.spec.ts diff --git a/tdrive/backend/node/test/e2e/diagnostics/diagnostics.spec.ts b/tdrive/backend/node/test/e2e/diagnostics/diagnostics.spec.ts new file mode 100644 index 00000000..685ac62b --- /dev/null +++ b/tdrive/backend/node/test/e2e/diagnostics/diagnostics.spec.ts @@ -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); + }); +}); diff --git a/tdrive/docker-compose.dev.tests.opensearch.yml b/tdrive/docker-compose.dev.tests.opensearch.yml index 7c025bd0..14f82fb6 100644 --- a/tdrive/docker-compose.dev.tests.opensearch.yml +++ b/tdrive/docker-compose.dev.tests.opensearch.yml @@ -68,6 +68,8 @@ services: - SEARCH_OS_PASSWORD=admin - SEARCH_OS_USE_AUTH=true - SEARCH_OS_USERNAME=admin + - DIAG_PROBE_SECRET=super_diagnostic_probe_secret + - DIAG_SECRET=super_diagnostic_secret depends_on: - postgres - opensearch-node1 diff --git a/tdrive/docker-compose.tests.yml b/tdrive/docker-compose.tests.yml index 515b6cc4..983d74fc 100644 --- a/tdrive/docker-compose.tests.yml +++ b/tdrive/docker-compose.tests.yml @@ -84,6 +84,8 @@ services: - STORAGE_S3_ENDPOINT=minio - STORAGE_S3_ACCESS_KEY=admin - STORAGE_S3_SECRET_KEY=adminminio + - DIAG_PROBE_SECRET=super_diagnostic_probe_secret + - DIAG_SECRET=super_diagnostic_secret depends_on: minio: condition: service_healthy