From 0d775659e37a1e35111e9618029eb7e560512471 Mon Sep 17 00:00:00 2001 From: shadrach Date: Tue, 17 Dec 2024 20:20:44 +0100 Subject: [PATCH 1/2] enforce env flags and vars temporarily --- desci-server/src/services/repoService.ts | 6 +++--- sync-server/src/index.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/desci-server/src/services/repoService.ts b/desci-server/src/services/repoService.ts index 82cf0389..6a38810e 100644 --- a/desci-server/src/services/repoService.ts +++ b/desci-server/src/services/repoService.ts @@ -9,9 +9,9 @@ import { NodeUuid } from './manifestRepo.js'; const logger = parentLogger.child({ module: 'Repo Service' }); -const cloudflareWorkerApi = process.env.CLOUDFLARE_WORKER_API; -const cloudflareWorkerApiSecret = process.env.CLOUDFLARE_WORKER_API_SECRET; -const enableWorkersApi = process.env.ENABLE_WORKERS_API == 'true'; +const cloudflareWorkerApi = 'nodes-dev-sync.desci.com'; // process.env.CLOUDFLARE_WORKER_API; +const cloudflareWorkerApiSecret = 'auth-token'; // process.env.CLOUDFLARE_WORKER_API_SECRET; +const enableWorkersApi = true; // process.env.ENABLE_WORKERS_API == 'true'; type ApiResponse = { ok: boolean } & B; diff --git a/sync-server/src/index.ts b/sync-server/src/index.ts index 2bebd51d..c0f1ee76 100644 --- a/sync-server/src/index.ts +++ b/sync-server/src/index.ts @@ -359,11 +359,11 @@ async function getLatestDocument(request: Request, env: Env) { export default { fetch(request: Request, env) { + const secretKey = env.ENVIRONMENT === null ? 'test-api-secret' : env.API_TOKEN; console.log('Request Fetch:', { env, url: request.url, }); - const secretKey = env.ENVIRONMENT === null ? 'test-api-secret' : env.API_TOKEN; if (request.url.includes('/api/') && request.headers.get('x-api-key') != secretKey) { console.log('[Error]::Api key error'); return new Response('UnAuthorized', { status: 401 }); From 3a31ee997786a5211cd9726dedc5ff98d05d3b61 Mon Sep 17 00:00:00 2001 From: shadrach Date: Tue, 17 Dec 2024 20:45:35 +0100 Subject: [PATCH 2/2] fix: add protocol to url, run all tests --- desci-server/kubernetes/deployment_dev.yaml | 2 +- desci-server/kubernetes/deployment_prod.yaml | 2 +- desci-server/kubernetes/deployment_staging.yaml | 2 +- desci-server/src/services/repoService.ts | 2 +- desci-server/test/integration/automerge.test.ts | 2 +- desci-server/test/integration/data.test.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/desci-server/kubernetes/deployment_dev.yaml b/desci-server/kubernetes/deployment_dev.yaml index d0cdc2f7..59ad45bd 100644 --- a/desci-server/kubernetes/deployment_dev.yaml +++ b/desci-server/kubernetes/deployment_dev.yaml @@ -95,7 +95,7 @@ spec: export ELASTIC_SEARCH_USER="{{ .Data.ELASTIC_SEARCH_USER }}" export ELASTIC_SEARCH_PW="{{ .Data.ELASTIC_SEARCH_PW }}" export OPEN_ALEX_DATABASE_URL="{{ .Data.OPEN_ALEX_DATABASE_URL }}" - CLOUDFLARE_WORKER_API=nodes-dev-sync.desci.com + CLOUDFLARE_WORKER_API=https://nodes-dev-sync.desci.com CLOUDFLARE_WORKER_API_SECRET=auth-token ENABLE_WORKERS_API=true export DEBUG_TEST=0; diff --git a/desci-server/kubernetes/deployment_prod.yaml b/desci-server/kubernetes/deployment_prod.yaml index 0f3224c3..9db6e982 100755 --- a/desci-server/kubernetes/deployment_prod.yaml +++ b/desci-server/kubernetes/deployment_prod.yaml @@ -95,7 +95,7 @@ spec: export ELASTIC_SEARCH_USER="{{ .Data.ELASTIC_SEARCH_USER }}" export ELASTIC_SEARCH_PW="{{ .Data.ELASTIC_SEARCH_PW }}" export OPEN_ALEX_DATABASE_URL="{{ .Data.OPEN_ALEX_DATABASE_URL }}" - CLOUDFLARE_WORKER_API=nodes-sync.desci.com + CLOUDFLARE_WORKER_API=https://nodes-sync.desci.com CLOUDFLARE_WORKER_API_SECRET=auth-token ENABLE_WORKERS_API=true export IGNORE_LINE=0; diff --git a/desci-server/kubernetes/deployment_staging.yaml b/desci-server/kubernetes/deployment_staging.yaml index 87dbf6c2..6e240e0d 100644 --- a/desci-server/kubernetes/deployment_staging.yaml +++ b/desci-server/kubernetes/deployment_staging.yaml @@ -107,7 +107,7 @@ spec: export ELASTIC_SEARCH_USER="{{ .Data.ELASTIC_SEARCH_USER }}" export ELASTIC_SEARCH_PW="{{ .Data.ELASTIC_SEARCH_PW }}" export OPEN_ALEX_DATABASE_URL="{{ .Data.OPEN_ALEX_DATABASE_URL }}" - CLOUDFLARE_WORKER_API=nodes-sync.desci.com + CLOUDFLARE_WORKER_API=https://nodes-sync.desci.com CLOUDFLARE_WORKER_API_SECRET=auth-token ENABLE_WORKERS_API=true export DEBUG_TEST=0; diff --git a/desci-server/src/services/repoService.ts b/desci-server/src/services/repoService.ts index 6a38810e..84e1fb41 100644 --- a/desci-server/src/services/repoService.ts +++ b/desci-server/src/services/repoService.ts @@ -9,7 +9,7 @@ import { NodeUuid } from './manifestRepo.js'; const logger = parentLogger.child({ module: 'Repo Service' }); -const cloudflareWorkerApi = 'nodes-dev-sync.desci.com'; // process.env.CLOUDFLARE_WORKER_API; +const cloudflareWorkerApi = 'https://nodes-dev-sync.desci.com'; // process.env.CLOUDFLARE_WORKER_API; const cloudflareWorkerApiSecret = 'auth-token'; // process.env.CLOUDFLARE_WORKER_API_SECRET; const enableWorkersApi = true; // process.env.ENABLE_WORKERS_API == 'true'; diff --git a/desci-server/test/integration/automerge.test.ts b/desci-server/test/integration/automerge.test.ts index dabed43a..35b20fd0 100644 --- a/desci-server/test/integration/automerge.test.ts +++ b/desci-server/test/integration/automerge.test.ts @@ -50,7 +50,7 @@ const createDraftNode = async (user: User, baseManifest: ResearchObjectV1, baseM return { node: updatedNode || node, documentId: response?.documentId }; }; -describe.only('Automerge Integration', () => { +describe('Automerge Integration', () => { let user: User; let unauthedUser: User; // let node: Node; diff --git a/desci-server/test/integration/data.test.ts b/desci-server/test/integration/data.test.ts index c1c1fec3..886bcc1c 100644 --- a/desci-server/test/integration/data.test.ts +++ b/desci-server/test/integration/data.test.ts @@ -64,7 +64,7 @@ const createDraftNode = async (user: User, baseManifest: ResearchObjectV1, baseM return { node: updatedNode || node, documentId: response?.documentId }; }; -describe.only('Data Controllers', () => { +describe('Data Controllers', () => { let user: User; let unauthedUser: User; // let node: Node;