@nathapp/na-cli 1.0.0-rc.4 → 1.0.0-rc.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +135 -0
- package/Makefile +16 -9
- package/README.md +18 -2
- package/alias-script.sh +30 -0
- package/dist/index.js +106 -128
- package/dist/index.js.map +1 -1
- package/dist/templates/db-schema/.gitignore-rename +1 -0
- package/dist/templates/db-schema/.gitlab-ci.yml +139 -0
- package/dist/templates/db-schema/001_Schema.sql +1 -0
- package/dist/templates/db-schema/DEV_MODE.txt +1 -0
- package/dist/templates/db-schema/Dockerfile +3 -0
- package/dist/templates/db-schema/Email-Templates/Individual/README.md +1 -0
- package/dist/templates/db-schema/GET_VERSION.sql +47 -0
- package/dist/templates/db-schema/Makefile +885 -0
- package/dist/templates/db-schema/README.md +117 -0
- package/dist/templates/db-schema/SET_VERSION.sql +5 -0
- package/dist/templates/db-schema/docker-compose.yaml +47 -0
- package/dist/templates/db-schema/package.json +3 -0
- package/dist/templates/db-schema/push.sh +0 -0
- package/dist/templates/db-schema/samples/899_DB_Grant_User.sql +9 -0
- package/dist/templates/db-schema/samples/990_SAMPLE_Init_Data.sql +27 -0
- package/dist/templates/k8s-deployment/.gitignore-rename +1 -0
- package/dist/templates/k8s-deployment/.gitlab-ci.yml +128 -0
- package/dist/templates/k8s-deployment/.helmignore +23 -0
- package/dist/templates/k8s-deployment/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/Makefile +196 -0
- package/dist/templates/k8s-deployment/README.md +32 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/script/Makefile +12 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/values.yaml +51 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/deployment.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/ingress.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/pv.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/pvc.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/sc.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/service.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/statefulset.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/values.yaml +15 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/script/Makefile +8 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/values.yaml +42 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/deployment.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/ingress.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/pv.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/pvc.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/sc.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/service.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/statefulset.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/values.yaml +12 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/script/Makefile +49 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/script/_env.yaml +2 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/values.yaml +36 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/cluster-role-binding.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/cronjob.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/deployment.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/ingress.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/pv.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/pvc.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/sc.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/service-account.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/service.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/statefulset.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/values.yaml +47 -0
- package/dist/templates/k8s-deployment/services/charts/tests/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/Makefile +9 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/fixtures/index.json +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/login/login-spec.js +47 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/login/loginEmailWrong-spec.js +14 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/login/loginPasswordWrong-spec.js +14 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/profile/updatePassword-spec.js +15 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/profile/updateProfile-spec.js +25 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/test-script.spec.js +9 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/plugins/index.js +22 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/support/commands.js +258 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/support/index.js +35 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/support/misc.js +8 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress.json +4 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/templates/pod.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/values.yaml +70 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/.helmignore +2 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/script/Makefile +14 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/templates/pod.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/_t-0100-readiness-liveness.ts +84 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/hub.ts +372 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-contact.ts +158 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-contract.ts +328 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-kyc.ts +304 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-onboard-app.ts +823 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-onboard-web.ts +493 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-profile.ts +277 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-whitelist.ts +133 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/resources/live.jpg +0 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/resources/mykad_front.jpg +0 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/resources/profile.jpg +0 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/t-0200-start.ts +172 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/values.yaml +59 -0
- package/dist/templates/k8s-deployment/templates/_cluster-role-binding.tpl +20 -0
- package/dist/templates/k8s-deployment/templates/_configmap.tpl +37 -0
- package/dist/templates/k8s-deployment/templates/_cronjob.tpl +225 -0
- package/dist/templates/k8s-deployment/templates/_deployment.tpl +246 -0
- package/dist/templates/k8s-deployment/templates/_helpers.tpl +31 -0
- package/dist/templates/k8s-deployment/templates/_ingress.tpl +77 -0
- package/dist/templates/k8s-deployment/templates/_job.tpl +233 -0
- package/dist/templates/k8s-deployment/templates/_pod.tpl +214 -0
- package/dist/templates/k8s-deployment/templates/_pv.tpl +42 -0
- package/dist/templates/k8s-deployment/templates/_pvc.tpl +27 -0
- package/dist/templates/k8s-deployment/templates/_root.tpl +314 -0
- package/dist/templates/k8s-deployment/templates/_sc.tpl +19 -0
- package/dist/templates/k8s-deployment/templates/_secret.tpl +15 -0
- package/dist/templates/k8s-deployment/templates/_service-account.tpl +8 -0
- package/dist/templates/k8s-deployment/templates/_service.tpl +40 -0
- package/dist/templates/k8s-deployment/templates/_statefulset.tpl +244 -0
- package/dist/templates/k8s-deployment/templates/root-cm.yaml +10 -0
- package/dist/templates/k8s-deployment/templates/root-pull-secret.yaml +11 -0
- package/dist/templates/k8s-deployment/templates/root-secret.yaml +24 -0
- package/dist/templates/k8s-deployment/values.yaml +38 -0
- package/dist/templates/k8s-helm-chart/Chart.yaml +23 -0
- package/dist/templates/k8s-helm-chart/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-helm-chart/templates/cluster-role-binding.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/cronjob.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/deployment.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/ingress.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/pv.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/pvc.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/sc.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/secret.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/service-account.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/service.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/statefulset.yaml +1 -0
- package/dist/templates/k8s-helm-chart/values.yaml +41 -0
- package/dist/templates/mxw-base-api-express/.dockerignore +2 -0
- package/dist/templates/mxw-base-api-express/.env +10 -0
- package/dist/templates/mxw-base-api-express/.gitignore-rename +3 -0
- package/dist/templates/mxw-base-api-express/.gitlab-ci.yml +174 -0
- package/dist/templates/mxw-base-api-express/.nvmrc +1 -0
- package/dist/templates/mxw-base-api-express/Dockerfile +14 -0
- package/dist/templates/mxw-base-api-express/Makefile +84 -0
- package/dist/templates/mxw-base-api-express/README.md +71 -0
- package/dist/templates/mxw-base-api-express/package.json +55 -0
- package/dist/templates/mxw-base-api-express/src/app-service.test.ts +94 -0
- package/dist/templates/mxw-base-api-express/src/app-service.ts +498 -0
- package/dist/templates/mxw-base-api-express/src/auth/auth-user.test.ts +215 -0
- package/dist/templates/mxw-base-api-express/src/auth/auth-user.ts +86 -0
- package/dist/templates/mxw-base-api-express/src/auth/auth.ts +81 -0
- package/dist/templates/mxw-base-api-express/src/core-service.ts +72 -0
- package/dist/templates/mxw-base-api-express/src/crud.ts +84 -0
- package/dist/templates/mxw-base-api-express/src/http-handler.ts +71 -0
- package/dist/templates/mxw-base-api-express/src/server.ts +54 -0
- package/dist/templates/mxw-base-api-express/src/test.ts +38 -0
- package/dist/templates/mxw-base-api-express/src/utils/api-utilities.ts +52 -0
- package/dist/templates/mxw-base-api-express/src/utils/file-utilities.ts +55 -0
- package/dist/templates/mxw-base-api-express/tsconfig.json +32 -0
- package/dist/templates/nestjs-api/.dockerignore +2 -0
- package/dist/templates/nestjs-api/.env +12 -0
- package/dist/templates/nestjs-api/.eslintrc.js +25 -0
- package/dist/templates/nestjs-api/.gitignore-rename +35 -0
- package/dist/templates/nestjs-api/.gitlab-ci.yml +174 -0
- package/dist/templates/nestjs-api/.nvmrc +1 -0
- package/dist/templates/nestjs-api/.prettierrc +4 -0
- package/dist/templates/nestjs-api/Dockerfile +19 -0
- package/dist/templates/nestjs-api/Makefile +84 -0
- package/dist/templates/nestjs-api/README.md +67 -0
- package/dist/templates/nestjs-api/nest-cli.json +8 -0
- package/dist/templates/nestjs-api/package.json +75 -0
- package/dist/templates/nestjs-api/src/app.controller.spec.ts +22 -0
- package/dist/templates/nestjs-api/src/app.controller.ts +27 -0
- package/dist/templates/nestjs-api/src/app.module.ts +10 -0
- package/dist/templates/nestjs-api/src/app.service.ts +12 -0
- package/dist/templates/nestjs-api/src/main.ts +31 -0
- package/dist/templates/nestjs-api/test/app.e2e-spec.ts +24 -0
- package/dist/templates/nestjs-api/test/jest-e2e.json +9 -0
- package/dist/templates/nestjs-api/tsconfig.build.json +4 -0
- package/dist/templates/nestjs-api/tsconfig.json +22 -0
- package/dist/templates/nestjs-library/.eslintrc.js +24 -0
- package/dist/templates/nestjs-library/.gitignore-rename +39 -0
- package/dist/templates/nestjs-library/.gitlab-ci.yml +135 -0
- package/dist/templates/nestjs-library/.npmignore-rename +30 -0
- package/dist/templates/nestjs-library/.prettierrc +6 -0
- package/dist/templates/nestjs-library/LICENSE +21 -0
- package/dist/templates/nestjs-library/Makefile +60 -0
- package/dist/templates/nestjs-library/README.md +3 -0
- package/dist/templates/nestjs-library/index.d.ts +1 -0
- package/dist/templates/nestjs-library/index.js +6 -0
- package/dist/templates/nestjs-library/index.ts +1 -0
- package/dist/templates/nestjs-library/lib/index.ts +2 -0
- package/dist/templates/nestjs-library/package.json +43 -0
- package/dist/templates/nestjs-library/tsconfig.build.json +4 -0
- package/dist/templates/nestjs-library/tsconfig.json +18 -0
- package/dist/templates/ts-library/.dockerignore +2 -0
- package/dist/templates/ts-library/.eslintrc.js +24 -0
- package/dist/templates/ts-library/.gitignore-rename +37 -0
- package/dist/templates/ts-library/.gitlab-ci.yml +135 -0
- package/dist/templates/ts-library/.npmignore-rename +30 -0
- package/dist/templates/ts-library/.prettierrc +6 -0
- package/dist/templates/ts-library/LICENSE +21 -0
- package/dist/templates/ts-library/Makefile +58 -0
- package/dist/templates/ts-library/README.md +1 -0
- package/dist/templates/ts-library/index.d.ts +1 -0
- package/dist/templates/ts-library/index.js +6 -0
- package/dist/templates/ts-library/index.ts +1 -0
- package/dist/templates/ts-library/lib/index.ts +1 -0
- package/dist/templates/ts-library/lib/samples/index.ts +5 -0
- package/dist/templates/ts-library/lib/samples/samples-function.ts +3 -0
- package/dist/templates/ts-library/package.json +34 -0
- package/dist/templates/ts-library/test/jest-e2e.json +9 -0
- package/dist/templates/ts-library/test/sample.e2e-spec.ts +10 -0
- package/dist/templates/ts-library/tsconfig.build.json +4 -0
- package/dist/templates/ts-library/tsconfig.json +18 -0
- package/dist/utils/env.js +146 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/template.js +362 -1
- package/dist/utils/template.js.map +1 -1
- package/package.json +9 -5
- package/src/index.ts +0 -182
- package/src/utils/template.ts +0 -9
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { describe, it } from 'mocha';
|
|
4
|
+
import chai, { expect } from 'chai';
|
|
5
|
+
import chaihttp from 'chai-http';
|
|
6
|
+
|
|
7
|
+
import HubService, { User, challengeIt, goodRet, badRet, serviceUrl, getActivationToken, isKycPassed } from "./hub";
|
|
8
|
+
import { checkFormat, checkNumber, checkString, hexlify, isUndefinedOrNullOrEmpty, notAllowNullOrEmpty } from 'mxw-libs-utils';
|
|
9
|
+
import { utils } from 'mxw-sdk-js';
|
|
10
|
+
import { stringify } from 'querystring';
|
|
11
|
+
import md5 from 'md5';
|
|
12
|
+
|
|
13
|
+
chai.use(chaihttp);
|
|
14
|
+
|
|
15
|
+
let indent = " ";
|
|
16
|
+
|
|
17
|
+
export function webOnboard(user: User, challenge: boolean) {
|
|
18
|
+
describe('Suite: Individual Web Onboard: ' + user.code + " (" + user.email + ")", function () {
|
|
19
|
+
let activationToken: string;
|
|
20
|
+
|
|
21
|
+
challengeIt("Check email address before register: " + user.email, function (params) {
|
|
22
|
+
let url = serviceUrl("/auth-web/api");
|
|
23
|
+
|
|
24
|
+
return chai.request(url).post("/register/verify/email")
|
|
25
|
+
.type("application/json")
|
|
26
|
+
.set("no-captcha", "true")
|
|
27
|
+
.send(params).then((res) => {
|
|
28
|
+
badRet(res);
|
|
29
|
+
});
|
|
30
|
+
}, {
|
|
31
|
+
email: ""
|
|
32
|
+
}, challenge);
|
|
33
|
+
|
|
34
|
+
it("Check email address before register: " + user.email, function () {
|
|
35
|
+
let url = serviceUrl("/auth-web/api");
|
|
36
|
+
|
|
37
|
+
return chai.request(url).post("/register/verify/email")
|
|
38
|
+
.type("application/json")
|
|
39
|
+
.set("no-captcha", "true")
|
|
40
|
+
.send({
|
|
41
|
+
email: user.email
|
|
42
|
+
}).then((res) => {
|
|
43
|
+
if (0 < user.id) {
|
|
44
|
+
badRet(res, "3201"); // A user with the specified email already exists
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
goodRet(res);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
challengeIt("Register", function (params) {
|
|
53
|
+
let url = serviceUrl("/auth-web/api");
|
|
54
|
+
|
|
55
|
+
return chai.request(url).post("/register")
|
|
56
|
+
.type("application/json")
|
|
57
|
+
.set("no-captcha", "true")
|
|
58
|
+
.send(params).then((res) => {
|
|
59
|
+
badRet(res);
|
|
60
|
+
});
|
|
61
|
+
}, {
|
|
62
|
+
email: "",
|
|
63
|
+
pwd: ""
|
|
64
|
+
}, challenge);
|
|
65
|
+
|
|
66
|
+
it("Register", function () {
|
|
67
|
+
let url = serviceUrl("/auth-web/api");
|
|
68
|
+
|
|
69
|
+
return chai.request(url).post("/register")
|
|
70
|
+
.type("application/json")
|
|
71
|
+
.set("no-captcha", "true")
|
|
72
|
+
.send({
|
|
73
|
+
email: user.email,
|
|
74
|
+
pwd: user.password
|
|
75
|
+
}).then((res) => {
|
|
76
|
+
if (0 < user.id) {
|
|
77
|
+
badRet(res, "3201"); // A user with the specified email already exists
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
goodRet(res);
|
|
81
|
+
if (!HubService.Instance.silent) { console.log(indent, "Registered with", user.email, ":", user.password) }
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("Check activation email", function () {
|
|
87
|
+
if (0 < user.id) {
|
|
88
|
+
this.skip();
|
|
89
|
+
}
|
|
90
|
+
return getActivationToken(user.username, "/bdss/u/activation/").then((token) => {
|
|
91
|
+
activationToken = token;
|
|
92
|
+
if (!HubService.Instance.silent) { console.log(indent, "Activation token:", activationToken) }
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
challengeIt("Activation", function (params) {
|
|
97
|
+
if (isUndefinedOrNullOrEmpty(activationToken)) {
|
|
98
|
+
this.skip();
|
|
99
|
+
}
|
|
100
|
+
let url = serviceUrl("/auth-web/api");
|
|
101
|
+
|
|
102
|
+
return chai.request(url).post("/register/verify/activate")
|
|
103
|
+
.type("application/json")
|
|
104
|
+
.set("no-captcha", "true")
|
|
105
|
+
.send(params)
|
|
106
|
+
.then((res) => {
|
|
107
|
+
badRet(res);
|
|
108
|
+
});
|
|
109
|
+
}, {
|
|
110
|
+
accessKey: ""
|
|
111
|
+
}, challenge);
|
|
112
|
+
|
|
113
|
+
it("Activation", function () {
|
|
114
|
+
let url = serviceUrl("/auth-web/api");
|
|
115
|
+
|
|
116
|
+
return chai.request(url).post("/register/verify/activate")
|
|
117
|
+
.type("application/json")
|
|
118
|
+
.set("no-captcha", "true")
|
|
119
|
+
.send({
|
|
120
|
+
accessKey: activationToken
|
|
121
|
+
})
|
|
122
|
+
.then((res) => {
|
|
123
|
+
if (0 < user.id) {
|
|
124
|
+
badRet(res, "ParameterMissing");
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
goodRet(res);
|
|
128
|
+
expect(res.body).have.property("data").have.property("userId").is.a("number");
|
|
129
|
+
expect(res.body).have.property("data").have.property("usrLogin").is.eq(user.email);
|
|
130
|
+
expect(res.body).have.property("data").have.property("token").is.a("string").lengthOf.greaterThan(0);
|
|
131
|
+
|
|
132
|
+
user.id = res.body.data.userId;
|
|
133
|
+
if (!HubService.Instance.silent) { console.log(indent, "Activated userId:", user.id, "username:", user.email, "password:", user.password) }
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
if (challenge) {
|
|
139
|
+
it("Register - should not allowed re-register", function () {
|
|
140
|
+
let url = serviceUrl("/auth-web/api");
|
|
141
|
+
|
|
142
|
+
return chai.request(url).post("/register")
|
|
143
|
+
.type("application/json")
|
|
144
|
+
.set("no-captcha", "true")
|
|
145
|
+
.send({
|
|
146
|
+
email: user.email,
|
|
147
|
+
pwd: user.password
|
|
148
|
+
}).then((res) => {
|
|
149
|
+
badRet(res);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
challengeIt("Login", function (params) {
|
|
155
|
+
let url = serviceUrl("/auth-web/api");
|
|
156
|
+
|
|
157
|
+
return chai.request(url).post("/login")
|
|
158
|
+
.type("application/json")
|
|
159
|
+
.set("no-captcha", "true")
|
|
160
|
+
.send(params)
|
|
161
|
+
.then((res) => {
|
|
162
|
+
badRet(res);
|
|
163
|
+
});
|
|
164
|
+
}, {
|
|
165
|
+
username: "",
|
|
166
|
+
pwd: ""
|
|
167
|
+
}, challenge);
|
|
168
|
+
|
|
169
|
+
if (challenge) {
|
|
170
|
+
it("Login - challenge wrong password", function () {
|
|
171
|
+
let url = serviceUrl("/auth-web/api");
|
|
172
|
+
|
|
173
|
+
return chai.request(url).post("/login")
|
|
174
|
+
.type("application/json")
|
|
175
|
+
.set("no-captcha", "true")
|
|
176
|
+
.send({
|
|
177
|
+
username: user.email,
|
|
178
|
+
pwd: hexlify(utils.randomBytes(5)).substr(2)
|
|
179
|
+
}).then((res) => {
|
|
180
|
+
badRet(res);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("Login - challenge wrong useername", function () {
|
|
185
|
+
let url = serviceUrl("/auth-web/api");
|
|
186
|
+
|
|
187
|
+
return chai.request(url).post("/login")
|
|
188
|
+
.type("application/json")
|
|
189
|
+
.set("no-captcha", "true")
|
|
190
|
+
.send({
|
|
191
|
+
username: hexlify(utils.randomBytes(5)).substr(2) + user.email,
|
|
192
|
+
pwd: user.password
|
|
193
|
+
}).then((res) => {
|
|
194
|
+
badRet(res);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
it("Login", function () {
|
|
200
|
+
let url = serviceUrl("/auth-web/api");
|
|
201
|
+
|
|
202
|
+
return chai.request(url).post("/login")
|
|
203
|
+
.type("application/json")
|
|
204
|
+
.set("no-captcha", "true")
|
|
205
|
+
.send({
|
|
206
|
+
username: user.email,
|
|
207
|
+
pwd: user.password
|
|
208
|
+
})
|
|
209
|
+
.then((res) => {
|
|
210
|
+
if (isUndefinedOrNullOrEmpty(activationToken)) {
|
|
211
|
+
badRet(res, "3211"); // Set Password
|
|
212
|
+
|
|
213
|
+
return getActivationToken(user.username, "/bdss/u/first-login/").then((token) => {
|
|
214
|
+
return chai.request(url).post("/first-time/login")
|
|
215
|
+
.type("application/json")
|
|
216
|
+
.set("no-captcha", "true")
|
|
217
|
+
.send({
|
|
218
|
+
type: 1,
|
|
219
|
+
pwd: user.password,
|
|
220
|
+
accessKey: token
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
return res;
|
|
225
|
+
}).then((res) => {
|
|
226
|
+
goodRet(res);
|
|
227
|
+
expect(res.body).have.property("data").have.property("userId").is.eq(user.id);
|
|
228
|
+
expect(res.body).have.property("data").have.property("usrLogin").is.eq(user.email);
|
|
229
|
+
expect(res.body).have.property("data").have.property("token").is.a("string").lengthOf.greaterThan(0);
|
|
230
|
+
|
|
231
|
+
user.jwt = res.body.data.token;
|
|
232
|
+
|
|
233
|
+
if (!HubService.Instance.silent) { console.log(indent, "Login with username:", user.email, "password:", user.password) }
|
|
234
|
+
if (!HubService.Instance.silent) { console.log(indent, "JWT:", user.jwt) }
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function webReauth(user: User, challenge: boolean) {
|
|
241
|
+
describe('Suite: Individual Web Reauth: ' + user.code + " (" + user.email + ")", function () {
|
|
242
|
+
let activationToken: string;
|
|
243
|
+
let secAnswer: string;
|
|
244
|
+
|
|
245
|
+
challenge = false; // TODO
|
|
246
|
+
|
|
247
|
+
it("Brute force login", function () {
|
|
248
|
+
let promises = Promise.resolve();
|
|
249
|
+
|
|
250
|
+
for (let i = 0; 3 > i; i++) {
|
|
251
|
+
promises = promises.then(() => {
|
|
252
|
+
return chai.request(serviceUrl("/auth-web/api")).post("/login")
|
|
253
|
+
.type("application/json")
|
|
254
|
+
.set("no-captcha", "true")
|
|
255
|
+
.send({
|
|
256
|
+
username: user.email,
|
|
257
|
+
pwd: utils.sha256(utils.toUtf8Bytes(hexlify(utils.randomBytes(5)).substr(2)))
|
|
258
|
+
})
|
|
259
|
+
.then((res) => {
|
|
260
|
+
badRet(res, "1102", "Incorrect username or password"); // Incorrect username or password
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return promises.then(() => {
|
|
266
|
+
return chai.request(serviceUrl("/auth-web/api")).post("/login")
|
|
267
|
+
.type("application/json")
|
|
268
|
+
.set("no-captcha", "true")
|
|
269
|
+
.send({
|
|
270
|
+
username: user.email,
|
|
271
|
+
pwd: utils.sha256(utils.toUtf8Bytes(hexlify(utils.randomBytes(5)).substr(2)))
|
|
272
|
+
})
|
|
273
|
+
.then((res) => {
|
|
274
|
+
badRet(res, "1105", "Your Account Is Locked"); // Your Account Is Locked
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it("Check Reauth activation email", function () {
|
|
280
|
+
return getActivationToken(user.username, "/bdss/u/re-auth/").then((token) => {
|
|
281
|
+
activationToken = token;
|
|
282
|
+
if (!HubService.Instance.silent) { console.log(indent, "Reauth activation token:", activationToken) }
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it("Reauth security answer", function () {
|
|
287
|
+
let token: {
|
|
288
|
+
email: string,
|
|
289
|
+
userId: number,
|
|
290
|
+
expiry: number,
|
|
291
|
+
kyc: number,
|
|
292
|
+
twoFa: number,
|
|
293
|
+
apiKey: string
|
|
294
|
+
} = checkFormat({
|
|
295
|
+
email: notAllowNullOrEmpty(checkString),
|
|
296
|
+
userId: checkNumber,
|
|
297
|
+
expiry: checkNumber,
|
|
298
|
+
kyc: checkNumber,
|
|
299
|
+
twoFa: checkNumber,
|
|
300
|
+
apiKey: notAllowNullOrEmpty(checkString),
|
|
301
|
+
}, JSON.parse(utils.toUtf8String(utils.base64.decode(activationToken))));
|
|
302
|
+
|
|
303
|
+
expect(token.kyc).is.eq(isKycPassed(user.kyc.status) ? 1 : 0, "KYC status mismatched");
|
|
304
|
+
|
|
305
|
+
if (0 == token.kyc) {
|
|
306
|
+
this.skip();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
secAnswer = md5((6 <= user.username.length) ? user.username.substr(user.username.length - 6) : user.username);
|
|
310
|
+
|
|
311
|
+
return chai.request(serviceUrl("/auth-web/api")).post("/verify/scrt/answer")
|
|
312
|
+
.type("application/json")
|
|
313
|
+
.set("no-captcha", "true")
|
|
314
|
+
.send({
|
|
315
|
+
accessKey: activationToken,
|
|
316
|
+
answer: secAnswer
|
|
317
|
+
})
|
|
318
|
+
.then((res) => {
|
|
319
|
+
goodRet(res);
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
if (challenge) {
|
|
324
|
+
it("Reauth configure password - challenge wrong security answer", function () {
|
|
325
|
+
let newPwd = utils.sha256(utils.toUtf8Bytes(hexlify(utils.randomBytes(5)).substr(2)));
|
|
326
|
+
|
|
327
|
+
return chai.request(serviceUrl("/auth-web/api")).post("/reauth/pwd")
|
|
328
|
+
.type("application/json")
|
|
329
|
+
.set("no-captcha", "true")
|
|
330
|
+
.send({
|
|
331
|
+
accessKey: activationToken,
|
|
332
|
+
pwd: newPwd,
|
|
333
|
+
answer: hexlify(utils.randomBytes(3)).substr(2)
|
|
334
|
+
})
|
|
335
|
+
.then((res) => {
|
|
336
|
+
badRet(res);
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
it("Reauth configure password", function () {
|
|
342
|
+
let newPwd = utils.sha256(utils.toUtf8Bytes(hexlify(utils.randomBytes(5)).substr(2)));
|
|
343
|
+
|
|
344
|
+
return chai.request(serviceUrl("/auth-web/api")).post("/reauth/pwd")
|
|
345
|
+
.type("application/json")
|
|
346
|
+
.set("no-captcha", "true")
|
|
347
|
+
.send({
|
|
348
|
+
accessKey: activationToken,
|
|
349
|
+
pwd: newPwd,
|
|
350
|
+
answer: secAnswer
|
|
351
|
+
})
|
|
352
|
+
.then((res) => {
|
|
353
|
+
goodRet(res);
|
|
354
|
+
expect(res.body).have.property("data").property("userId").is.a("number").is.eq(user.id);
|
|
355
|
+
expect(res.body).have.property("data").property("usrLogin").is.a("string").is.eq(user.email);
|
|
356
|
+
expect(res.body).have.property("data").property("token").is.a("string").lengthOf.greaterThan(0);
|
|
357
|
+
|
|
358
|
+
user.password = newPwd;
|
|
359
|
+
user.jwt = res.body.data.token;
|
|
360
|
+
if (!HubService.Instance.silent) { console.log(indent, "Reauth changed password:", user.password) }
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export function changePassword(user: User, challenge: boolean) {
|
|
367
|
+
describe('Suite: Individual Web Change Password', function () {
|
|
368
|
+
challengeIt("Change password", function (params) {
|
|
369
|
+
let url = serviceUrl("/user/api");
|
|
370
|
+
|
|
371
|
+
return chai.request(url).put("/chg/pwd")
|
|
372
|
+
.type("application/json")
|
|
373
|
+
.set("Authorization", "Bearer " + user.jwt)
|
|
374
|
+
.send(params)
|
|
375
|
+
.then((res) => {
|
|
376
|
+
badRet(res);
|
|
377
|
+
});
|
|
378
|
+
}, {
|
|
379
|
+
oldPwd: "",
|
|
380
|
+
newPwd: ""
|
|
381
|
+
}, challenge);
|
|
382
|
+
|
|
383
|
+
if (challenge) {
|
|
384
|
+
it("Change password - challenge without JWT", function () {
|
|
385
|
+
let url = serviceUrl("/user/api");
|
|
386
|
+
let newPwd = utils.sha256(utils.toUtf8Bytes(hexlify(utils.randomBytes(5)).substr(2)));
|
|
387
|
+
|
|
388
|
+
return chai.request(url).put("/chg/pwd")
|
|
389
|
+
.type("application/json")
|
|
390
|
+
.send({
|
|
391
|
+
oldPwd: user.password,
|
|
392
|
+
newPwd
|
|
393
|
+
})
|
|
394
|
+
.then((res) => {
|
|
395
|
+
badRet(res, "Unauthorised");
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it("Change password - challenge with non existing password", function () {
|
|
400
|
+
let url = serviceUrl("/user/api");
|
|
401
|
+
|
|
402
|
+
return chai.request(url).put("/chg/pwd")
|
|
403
|
+
.type("application/json")
|
|
404
|
+
.set("Authorization", "Bearer " + user.jwt)
|
|
405
|
+
.send({
|
|
406
|
+
oldPwd: utils.sha256(utils.toUtf8Bytes(user.password + hexlify(utils.randomBytes(2)).substr(2))),
|
|
407
|
+
newPwd: utils.sha256(utils.toUtf8Bytes(hexlify(utils.randomBytes(5)).substr(2)))
|
|
408
|
+
})
|
|
409
|
+
.then((res) => {
|
|
410
|
+
badRet(res, "1102"); // Incorrect username or password
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it("Change password - challenge with empty existing password", function () {
|
|
415
|
+
let url = serviceUrl("/user/api");
|
|
416
|
+
|
|
417
|
+
return chai.request(url).put("/chg/pwd")
|
|
418
|
+
.type("application/json")
|
|
419
|
+
.set("Authorization", "Bearer " + user.jwt)
|
|
420
|
+
.send({
|
|
421
|
+
oldPwd: "",
|
|
422
|
+
newPwd: utils.sha256(utils.toUtf8Bytes(hexlify(utils.randomBytes(5)).substr(2)))
|
|
423
|
+
})
|
|
424
|
+
.then((res) => {
|
|
425
|
+
badRet(res, "InvalidFormat");
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
it("Change password - challenge with empty new password", function () {
|
|
430
|
+
let url = serviceUrl("/user/api");
|
|
431
|
+
|
|
432
|
+
return chai.request(url).put("/chg/pwd")
|
|
433
|
+
.type("application/json")
|
|
434
|
+
.set("Authorization", "Bearer " + user.jwt)
|
|
435
|
+
.send({
|
|
436
|
+
oldPwd: user.password,
|
|
437
|
+
newPwd: ""
|
|
438
|
+
})
|
|
439
|
+
.then((res) => {
|
|
440
|
+
badRet(res, "InvalidFormat");
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
it("Change password - challenge with new short password", function () {
|
|
445
|
+
let url = serviceUrl("/user/api");
|
|
446
|
+
|
|
447
|
+
return chai.request(url).put("/chg/pwd")
|
|
448
|
+
.type("application/json")
|
|
449
|
+
.set("Authorization", "Bearer " + user.jwt)
|
|
450
|
+
.send({
|
|
451
|
+
oldPwd: user.password,
|
|
452
|
+
newPwd: hexlify(utils.randomBytes(1)).substr(2)
|
|
453
|
+
})
|
|
454
|
+
.then((res) => {
|
|
455
|
+
badRet(res, "InvalidFormat");
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
it("Change password - challenge with new long password", function () {
|
|
460
|
+
let url = serviceUrl("/user/api");
|
|
461
|
+
|
|
462
|
+
return chai.request(url).put("/chg/pwd")
|
|
463
|
+
.type("application/json")
|
|
464
|
+
.set("Authorization", "Bearer " + user.jwt)
|
|
465
|
+
.send({
|
|
466
|
+
oldPwd: user.password,
|
|
467
|
+
newPwd: hexlify(utils.randomBytes(100)).substr(2)
|
|
468
|
+
})
|
|
469
|
+
.then((res) => {
|
|
470
|
+
badRet(res, "InvalidFormat");
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
it("Change password", function () {
|
|
476
|
+
let url = serviceUrl("/user/api");
|
|
477
|
+
let newPwd = utils.sha256(utils.toUtf8Bytes(hexlify(utils.randomBytes(5)).substr(2)));
|
|
478
|
+
|
|
479
|
+
return chai.request(url).put("/chg/pwd")
|
|
480
|
+
.type("application/json")
|
|
481
|
+
.set("Authorization", "Bearer " + user.jwt)
|
|
482
|
+
.send({
|
|
483
|
+
oldPwd: user.password,
|
|
484
|
+
newPwd
|
|
485
|
+
})
|
|
486
|
+
.then((res) => {
|
|
487
|
+
goodRet(res);
|
|
488
|
+
user.password = newPwd;
|
|
489
|
+
if (!HubService.Instance.silent) { console.log(indent, "Changed password:", user.password) }
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
}
|