From 1963d7b211c324c139f34bccafd959f447aa3a2d Mon Sep 17 00:00:00 2001 From: minottic Date: Tue, 12 Nov 2024 09:58:06 +0100 Subject: [PATCH] Include v4 api:mocha tests in dev setup --- services/backend/services/v4/compose.dev.yaml | 5 ++ services/backend/services/v4/config/.dev.env | 11 +++ services/backend/services/v4/config/.env | 2 +- .../v4/config/functionalAccounts.dev.json | 86 +++++++++++++++++++ .../backend/services/v4/entrypoints/tests.sh | 7 ++ 5 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 services/backend/services/v4/config/.dev.env create mode 100644 services/backend/services/v4/config/functionalAccounts.dev.json diff --git a/services/backend/services/v4/compose.dev.yaml b/services/backend/services/v4/compose.dev.yaml index b5f44a94..33f74de5 100644 --- a/services/backend/services/v4/compose.dev.yaml +++ b/services/backend/services/v4/compose.dev.yaml @@ -10,7 +10,12 @@ services: volumes: - v4_dev:/home/node/app - ${PWD}/entrypoints/setup_git.sh:/docker-entrypoints/2.sh + - ./config/functionalAccounts.dev.json:/home/node/app/functionalAccounts.json - ./entrypoints/tests.sh:/docker-entrypoints/3.sh + env_file: + - ./config/.dev.env + healthcheck: + start_period: 2m volumes: v4_dev: diff --git a/services/backend/services/v4/config/.dev.env b/services/backend/services/v4/config/.dev.env new file mode 100644 index 00000000..36ae3fd1 --- /dev/null +++ b/services/backend/services/v4/config/.dev.env @@ -0,0 +1,11 @@ +MONGODB_URI=mongodb://mongodb:27017/dev_be_next +ADMIN_GROUPS=admin,adminingestor +CREATE_DATASET_GROUPS=group1,group2,group3 +CREATE_DATASET_WITH_PID_GROUPS=group2 +CREATE_DATASET_PRIVILEGED_GROUPS=datasetIngestor,group3 +SAMPLE_PRIVILEGED_GROUPS=sampleingestor +SAMPLE_GROUPS=group1 +DATASET_CREATION_VALIDATION_ENABLED=true +DATASET_CREATION_VALIDATION_REGEX=^scicatlive_testing/[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$ +PID_PREFIX=scicatlive_testing +SITE=PSI diff --git a/services/backend/services/v4/config/.env b/services/backend/services/v4/config/.env index d20f55cf..85f6656e 100644 --- a/services/backend/services/v4/config/.env +++ b/services/backend/services/v4/config/.env @@ -4,7 +4,7 @@ JWT_SECRET=secret EXPRESS_SESSION_SECRET=secret ADMIN_GROUPS=admin -DELETE_GROUPS=buggy +DELETE_GROUPS=archivemanager CREATE_DATASET_GROUPS=ingestor PROPOSAL_GROUPS=proposalingestor SAMPLE_GROUPS=ingestor diff --git a/services/backend/services/v4/config/functionalAccounts.dev.json b/services/backend/services/v4/config/functionalAccounts.dev.json new file mode 100644 index 00000000..ac26731b --- /dev/null +++ b/services/backend/services/v4/config/functionalAccounts.dev.json @@ -0,0 +1,86 @@ +[ + { + "username": "admin", + "email": "admin@scicat.project", + "password": "27f5fd86ae68fe740eef42b8bbd1d7d5", + "role": "admin", + "global": true + }, + { + "username": "adminIngestor", + "email": "adminingestor@scicat.project", + "password": "13f4242dc691a3ee3bb5ca2006edcdf7", + "role": "adminingestor", + "global": false + }, + { + "username": "archiveManager", + "email": "archivemanager@scicat.project", + "password": "6d3b76392e6f41b087c11f8b77e3f9de", + "role": "archivemanager", + "global": false + }, + { + "username": "datasetIngestor", + "email": "datasetingestor@scicat.project", + "password": "bc35db76848cf9fbb7f40b6661644e97", + "role": "datasetingestor", + "global": false + }, + { + "username": "proposalIngestor", + "email": "proposalingestor@scicat.project", + "password": "7d8cd858fb9d0e4f5d91c34fd4016167", + "role": "proposalingestor", + "global": false + }, + { + "username": "sampleIngestor", + "email": "sampleingestor@scicat.project", + "password": "e4876cb39c7dc4fe957d7c4f6a34cdd8", + "role": "sampleingestor", + "global": false + }, + { + "username": "user1", + "email": "user1@your.site", + "password": "a609316768619f154ef58db4d847b75e", + "role": "group1", + "global": false + }, + { + "username": "user2", + "email": "user2@your.site", + "password": "f522d1d715970073a6413474ca0e0f63", + "role": "group2", + "global": false + }, + { + "username": "user3", + "email": "user3@your.site", + "password": "70dc489e8ee823ae815e18d664424df2", + "role": "group3", + "global": false + }, + { + "username": "user4", + "email": "user4@your.site", + "password": "0014890e7020f515b92b767227ef2dfa", + "role": "group4", + "global": false + }, + { + "username": "user5.1", + "email": "user5.1@your.site", + "password": "359a5fda99bfe5dbc42ee9b3ede77fb7", + "role": "group5", + "global": false + }, + { + "username": "user5.2", + "email": "user5.2@your.site", + "password": "f3ebd2e4def95db59ef95ee32ef45242", + "role": "group5", + "global": false + } +] diff --git a/services/backend/services/v4/entrypoints/tests.sh b/services/backend/services/v4/entrypoints/tests.sh index 811c4efb..88b56961 100755 --- a/services/backend/services/v4/entrypoints/tests.sh +++ b/services/backend/services/v4/entrypoints/tests.sh @@ -3,3 +3,10 @@ ## Setting the --runInBand makes the tests run sequentially, ## avoiding to fill the RAM which makes them freeze npm run test -- --runInBand + +npm start & +PID="${!}" +sleep 15 +npm run test:api:mocha + +kill "${PID}"