From fcb1fba374ed1ff9a4040c0d12f8b887f028a97c Mon Sep 17 00:00:00 2001 From: Nursoltan Saipolda Date: Sat, 3 Sep 2022 12:45:16 +0800 Subject: [PATCH 1/9] clean data before run test --- test/postman/newman.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/postman/newman.js b/test/postman/newman.js index 7f029d5..bd7881e 100644 --- a/test/postman/newman.js +++ b/test/postman/newman.js @@ -183,15 +183,17 @@ async function clearTestData () { /** * Run the postman tests. */ -apiTestLib.runTests(requests, require.resolve('./resource-api.postman_collection.json'), - require.resolve('./resource-api.postman_environment.json')).then(async () => { - logger.info('newman test completed!') - await clearTestData() -}).catch(async (err) => { - logger.logFullError(err) - - // Only calling the clean up function when it is not validation error. - if (err.name !== 'ValidationError') { +clearTestData().then(() => { + apiTestLib.runTests(requests, require.resolve('./resource-api.postman_collection.json'), + require.resolve('./resource-api.postman_environment.json')).then(async () => { + logger.info('newman test completed!') await clearTestData() - } + }).catch(async (err) => { + logger.logFullError(err) + + // Only calling the clean up function when it is not validation error. + if (err.name !== 'ValidationError') { + await clearTestData() + } + }) }) From 2bfe4f9ac7f5894720f70fa26a80d90bfa905a2b Mon Sep 17 00:00:00 2001 From: Abhinav Koppula Date: Wed, 14 Sep 2022 22:50:04 +0530 Subject: [PATCH 2/9] [CircleCI]-Fix config to refer MANAGER_CREDENTIALS from env --- .circleci/config.yml | 3 ++- config/test.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fbc92f8..932f0ff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -95,12 +95,13 @@ jobs: - run: *install_deploysuite - run: name: 'newman test' + no_output_timeout: 30m command: | ./awsconfiguration.sh $DEPLOY_ENV source awsenvconf ./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-qa-appvar source buildenvvar - npm i + npm install --loglevel verbose cd mock (npm run mock-challenge-api&) (NODE_ENV=test npm start&) diff --git a/config/test.js b/config/test.js index 81cb802..0d5f18d 100644 --- a/config/test.js +++ b/config/test.js @@ -17,5 +17,7 @@ module.exports = { COPILOT_CREDENTIALS_PASSWORD: process.env.COPILOT_CREDENTIALS_PASSWORD || '', USER_CREDENTIALS_USERNAME: process.env.USER_CREDENTIALS_USERNAME || '', USER_CREDENTIALS_PASSWORD: process.env.USER_CREDENTIALS_PASSWORD || '', + MANAGER_CREDENTIALS_USERNAME: process.env.MANAGER_CREDENTIALS_USERNAME || '', + MANAGER_CREDENTIALS_PASSWORD: process.env.MANAGER_CREDENTIALS_PASSWORD || '', AUTOMATED_TESTING_REPORTERS_FORMAT: process.env.AUTOMATED_TESTING_REPORTERS_FORMAT || ['cli', 'html'] } From 51d6dc91dc30c7f314093490e5cddda76d33bfae Mon Sep 17 00:00:00 2001 From: Thomas Kranitsas Date: Tue, 13 Dec 2022 15:37:09 +0200 Subject: [PATCH 3/9] reploy develop branch --- Verification.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Verification.md b/Verification.md index cffa15d..03ae304 100644 --- a/Verification.md +++ b/Verification.md @@ -94,4 +94,5 @@ Iteration 4/4 Then you can run `npm run test:newman:clear` to delete all testing data by above postman tests. If 'socket hang up' appears while running the `npm run test:newman`. You can increase the `WAIT_TIME` from the `default/test.js`. - Then run `npm run test:newman:clear` before calling `npm run test:newman` again. \ No newline at end of file + Then run `npm run test:newman:clear` before calling `npm run test:newman` again. + \ No newline at end of file From 2f5331b141199f25f73d1d97c83cc8828fcff28f Mon Sep 17 00:00:00 2001 From: Thomas Kranitsas Date: Tue, 13 Dec 2022 15:44:54 +0200 Subject: [PATCH 4/9] fix build error --- .circleci/config.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 932f0ff..817d1d9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,13 +8,15 @@ parameters: type: boolean defaults: &defaults docker: - - image: circleci/python:2.7-stretch-browsers + - image: cimg/python:3.11.0-browsers install_dependency: &install_dependency name: Installation of build and deployment dependencies. command: | + sudo apt update sudo apt install jq python3-pip - sudo pip3 install awscli --upgrade # sudo pip install docker-compose + sudo pip3 install awscli --upgrade + sudo pip3 install docker-compose install_deploysuite: &install_deploysuite name: Installation of install_deploysuite. command: | @@ -23,10 +25,10 @@ install_deploysuite: &install_deploysuite cp ./../buildscript/buildenv.sh . cp ./../buildscript/awsconfiguration.sh . restore_cache_settings_for_build: &restore_cache_settings_for_build - key: docker-node-modules-{{ checksum "package-lock.json" }} + key: docker-node-modules-{{ checksum "yarn.lock" }} save_cache_settings: &save_cache_settings - key: docker-node-modules-{{ checksum "package-lock.json" }} + key: docker-node-modules-{{ checksum "yarn.lock" }} paths: - node_modules From a1f7cd263a84d6484b023008eefff136d4a689b9 Mon Sep 17 00:00:00 2001 From: Marios Kranitsas Date: Mon, 30 Jan 2023 14:21:34 +0200 Subject: [PATCH 5/9] Fix issue that user was able to register on a canselled challenge --- app-constants.js | 3 ++- src/services/ResourceService.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app-constants.js b/app-constants.js index 3db24e1..ce3e323 100644 --- a/app-constants.js +++ b/app-constants.js @@ -10,7 +10,8 @@ const UserRoles = { } const ChallengeStatuses = { - Completed: 'Completed' + Completed: 'Completed', + Active: 'Active', } module.exports = { diff --git a/src/services/ResourceService.js b/src/services/ResourceService.js index 199fde7..42de677 100644 --- a/src/services/ResourceService.js +++ b/src/services/ResourceService.js @@ -231,6 +231,10 @@ async function init (currentUser, challengeId, resource, isCreated) { throw new errors.BadRequestError('Cannot delete resources of a completed challenge!') } + if (_.get(challenge, 'status') !== constants.ChallengeStatuses.Active && isCreated && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) { + throw new errors.BadRequestError(`Cannot create submitter resource on challenge with status ${_.get(challenge, 'status')}`) + } + // Prevent from creating more than 1 submitter resources on tasks if (_.get(challenge, 'task.isTask', false) && isCreated && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) { const existing = await getResources(currentUser, challengeId, config.SUBMITTER_RESOURCE_ROLE_ID, null, null, 1, 1) From f5971921a67bd3e10cc24b77157ec5704b733bd6 Mon Sep 17 00:00:00 2001 From: Thomas Kranitsas Date: Mon, 30 Jan 2023 14:53:47 +0200 Subject: [PATCH 6/9] fix lint --- app-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-constants.js b/app-constants.js index ce3e323..9dc4d3b 100644 --- a/app-constants.js +++ b/app-constants.js @@ -11,7 +11,7 @@ const UserRoles = { const ChallengeStatuses = { Completed: 'Completed', - Active: 'Active', + Active: 'Active' } module.exports = { From f5a6d1a515a859b67d7abe343f75bfd36496f1f2 Mon Sep 17 00:00:00 2001 From: Thomas Kranitsas Date: Tue, 31 Jan 2023 15:50:21 +0200 Subject: [PATCH 7/9] Revert "Prod deployment" --- .circleci/config.yml | 13 +++++-------- Verification.md | 3 +-- app-constants.js | 3 +-- config/test.js | 2 -- src/services/ResourceService.js | 4 ---- test/postman/newman.js | 22 ++++++++++------------ 6 files changed, 17 insertions(+), 30 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 817d1d9..fbc92f8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,15 +8,13 @@ parameters: type: boolean defaults: &defaults docker: - - image: cimg/python:3.11.0-browsers + - image: circleci/python:2.7-stretch-browsers install_dependency: &install_dependency name: Installation of build and deployment dependencies. command: | - sudo apt update sudo apt install jq python3-pip - # sudo pip install docker-compose sudo pip3 install awscli --upgrade - sudo pip3 install docker-compose + # sudo pip install docker-compose install_deploysuite: &install_deploysuite name: Installation of install_deploysuite. command: | @@ -25,10 +23,10 @@ install_deploysuite: &install_deploysuite cp ./../buildscript/buildenv.sh . cp ./../buildscript/awsconfiguration.sh . restore_cache_settings_for_build: &restore_cache_settings_for_build - key: docker-node-modules-{{ checksum "yarn.lock" }} + key: docker-node-modules-{{ checksum "package-lock.json" }} save_cache_settings: &save_cache_settings - key: docker-node-modules-{{ checksum "yarn.lock" }} + key: docker-node-modules-{{ checksum "package-lock.json" }} paths: - node_modules @@ -97,13 +95,12 @@ jobs: - run: *install_deploysuite - run: name: 'newman test' - no_output_timeout: 30m command: | ./awsconfiguration.sh $DEPLOY_ENV source awsenvconf ./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-qa-appvar source buildenvvar - npm install --loglevel verbose + npm i cd mock (npm run mock-challenge-api&) (NODE_ENV=test npm start&) diff --git a/Verification.md b/Verification.md index 03ae304..cffa15d 100644 --- a/Verification.md +++ b/Verification.md @@ -94,5 +94,4 @@ Iteration 4/4 Then you can run `npm run test:newman:clear` to delete all testing data by above postman tests. If 'socket hang up' appears while running the `npm run test:newman`. You can increase the `WAIT_TIME` from the `default/test.js`. - Then run `npm run test:newman:clear` before calling `npm run test:newman` again. - \ No newline at end of file + Then run `npm run test:newman:clear` before calling `npm run test:newman` again. \ No newline at end of file diff --git a/app-constants.js b/app-constants.js index 9dc4d3b..3db24e1 100644 --- a/app-constants.js +++ b/app-constants.js @@ -10,8 +10,7 @@ const UserRoles = { } const ChallengeStatuses = { - Completed: 'Completed', - Active: 'Active' + Completed: 'Completed' } module.exports = { diff --git a/config/test.js b/config/test.js index 0d5f18d..81cb802 100644 --- a/config/test.js +++ b/config/test.js @@ -17,7 +17,5 @@ module.exports = { COPILOT_CREDENTIALS_PASSWORD: process.env.COPILOT_CREDENTIALS_PASSWORD || '', USER_CREDENTIALS_USERNAME: process.env.USER_CREDENTIALS_USERNAME || '', USER_CREDENTIALS_PASSWORD: process.env.USER_CREDENTIALS_PASSWORD || '', - MANAGER_CREDENTIALS_USERNAME: process.env.MANAGER_CREDENTIALS_USERNAME || '', - MANAGER_CREDENTIALS_PASSWORD: process.env.MANAGER_CREDENTIALS_PASSWORD || '', AUTOMATED_TESTING_REPORTERS_FORMAT: process.env.AUTOMATED_TESTING_REPORTERS_FORMAT || ['cli', 'html'] } diff --git a/src/services/ResourceService.js b/src/services/ResourceService.js index 42de677..199fde7 100644 --- a/src/services/ResourceService.js +++ b/src/services/ResourceService.js @@ -231,10 +231,6 @@ async function init (currentUser, challengeId, resource, isCreated) { throw new errors.BadRequestError('Cannot delete resources of a completed challenge!') } - if (_.get(challenge, 'status') !== constants.ChallengeStatuses.Active && isCreated && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) { - throw new errors.BadRequestError(`Cannot create submitter resource on challenge with status ${_.get(challenge, 'status')}`) - } - // Prevent from creating more than 1 submitter resources on tasks if (_.get(challenge, 'task.isTask', false) && isCreated && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) { const existing = await getResources(currentUser, challengeId, config.SUBMITTER_RESOURCE_ROLE_ID, null, null, 1, 1) diff --git a/test/postman/newman.js b/test/postman/newman.js index bd7881e..7f029d5 100644 --- a/test/postman/newman.js +++ b/test/postman/newman.js @@ -183,17 +183,15 @@ async function clearTestData () { /** * Run the postman tests. */ -clearTestData().then(() => { - apiTestLib.runTests(requests, require.resolve('./resource-api.postman_collection.json'), - require.resolve('./resource-api.postman_environment.json')).then(async () => { - logger.info('newman test completed!') - await clearTestData() - }).catch(async (err) => { - logger.logFullError(err) +apiTestLib.runTests(requests, require.resolve('./resource-api.postman_collection.json'), + require.resolve('./resource-api.postman_environment.json')).then(async () => { + logger.info('newman test completed!') + await clearTestData() +}).catch(async (err) => { + logger.logFullError(err) - // Only calling the clean up function when it is not validation error. - if (err.name !== 'ValidationError') { - await clearTestData() - } - }) + // Only calling the clean up function when it is not validation error. + if (err.name !== 'ValidationError') { + await clearTestData() + } }) From 5d70c61743d8407ba8f0e0f291b71585eb7c4a92 Mon Sep 17 00:00:00 2001 From: Thomas Kranitsas Date: Wed, 1 Feb 2023 11:47:14 +0200 Subject: [PATCH 8/9] fix build --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 817d1d9..af6c73a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,7 +20,7 @@ install_dependency: &install_dependency install_deploysuite: &install_deploysuite name: Installation of install_deploysuite. command: | - git clone --branch v1.4 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript + git clone --branch v1.4.14 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript cp ./../buildscript/master_deploy.sh . cp ./../buildscript/buildenv.sh . cp ./../buildscript/awsconfiguration.sh . From 570dfe6a5f0098312215fbb129018c27e1bec607 Mon Sep 17 00:00:00 2001 From: Thomas Kranitsas Date: Wed, 1 Feb 2023 11:49:08 +0200 Subject: [PATCH 9/9] Fix issue with registration on tasks --- src/services/ResourceService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/ResourceService.js b/src/services/ResourceService.js index 42de677..9c22e0d 100644 --- a/src/services/ResourceService.js +++ b/src/services/ResourceService.js @@ -231,7 +231,7 @@ async function init (currentUser, challengeId, resource, isCreated) { throw new errors.BadRequestError('Cannot delete resources of a completed challenge!') } - if (_.get(challenge, 'status') !== constants.ChallengeStatuses.Active && isCreated && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) { + if (!_.get(challenge, 'task.isTask', false) && _.get(challenge, 'status') !== constants.ChallengeStatuses.Active && isCreated && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) { throw new errors.BadRequestError(`Cannot create submitter resource on challenge with status ${_.get(challenge, 'status')}`) }