[add] testing via mocha
This commit is contained in:
parent
7743d513e4
commit
a9faec506d
13 changed files with 3382 additions and 156 deletions
6
lib/node/node_modules/.package-lock.json
generated
vendored
6
lib/node/node_modules/.package-lock.json
generated
vendored
|
@ -106,6 +106,12 @@
|
||||||
"node": ">= 6"
|
"node": ">= 6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/mocha": {
|
||||||
|
"version": "10.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.6.tgz",
|
||||||
|
"integrity": "sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/abbrev": {
|
"node_modules/abbrev": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
|
21
lib/node/node_modules/@types/mocha/LICENSE
generated
vendored
Normal file
21
lib/node/node_modules/@types/mocha/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
15
lib/node/node_modules/@types/mocha/README.md
generated
vendored
Normal file
15
lib/node/node_modules/@types/mocha/README.md
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/mocha`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for mocha (https://mochajs.org).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mocha.
|
||||||
|
|
||||||
|
### Additional Details
|
||||||
|
* Last updated: Wed, 22 Nov 2023 00:24:48 GMT
|
||||||
|
* Dependencies: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by [Kazi Manzur Rashid](https://github.com/kazimanzurrashid), [otiai10](https://github.com/otiai10), [Vadim Macagon](https://github.com/enlight), [Andrew Bradley](https://github.com/cspotcode), [Dmitrii Sorin](https://github.com/1999), [Noah Hummel](https://github.com/strangedev), and [nicojs](https://github.com/nicojs).
|
2916
lib/node/node_modules/@types/mocha/index.d.ts
generated
vendored
Normal file
2916
lib/node/node_modules/@types/mocha/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
55
lib/node/node_modules/@types/mocha/package.json
generated
vendored
Normal file
55
lib/node/node_modules/@types/mocha/package.json
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
{
|
||||||
|
"name": "@types/mocha",
|
||||||
|
"version": "10.0.6",
|
||||||
|
"description": "TypeScript definitions for mocha",
|
||||||
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mocha",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Kazi Manzur Rashid",
|
||||||
|
"githubUsername": "kazimanzurrashid",
|
||||||
|
"url": "https://github.com/kazimanzurrashid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "otiai10",
|
||||||
|
"githubUsername": "otiai10",
|
||||||
|
"url": "https://github.com/otiai10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Vadim Macagon",
|
||||||
|
"githubUsername": "enlight",
|
||||||
|
"url": "https://github.com/enlight"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Andrew Bradley",
|
||||||
|
"githubUsername": "cspotcode",
|
||||||
|
"url": "https://github.com/cspotcode"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Dmitrii Sorin",
|
||||||
|
"githubUsername": "1999",
|
||||||
|
"url": "https://github.com/1999"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Noah Hummel",
|
||||||
|
"githubUsername": "strangedev",
|
||||||
|
"url": "https://github.com/strangedev"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "nicojs",
|
||||||
|
"githubUsername": "nicojs",
|
||||||
|
"url": "https://github.com/nicojs"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index.d.ts",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/mocha"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {},
|
||||||
|
"typesPublisherContentHash": "de34ee99a18094486419f8e3b6c2a3f81f623ecdcbc5f6f4cfe46236c7df5831",
|
||||||
|
"typeScriptVersion": "4.5"
|
||||||
|
}
|
7
lib/node/package-lock.json
generated
7
lib/node/package-lock.json
generated
|
@ -5,6 +5,7 @@
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/mocha": "^10.0.6",
|
||||||
"bcrypt": "^5.1.1",
|
"bcrypt": "^5.1.1",
|
||||||
"nodemailer": "^6.9.13",
|
"nodemailer": "^6.9.13",
|
||||||
"sqlite3": "^5.1.7",
|
"sqlite3": "^5.1.7",
|
||||||
|
@ -114,6 +115,12 @@
|
||||||
"node": ">= 6"
|
"node": ">= 6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/mocha": {
|
||||||
|
"version": "10.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.6.tgz",
|
||||||
|
"integrity": "sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/abbrev": {
|
"node_modules/abbrev": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/mocha": "^10.0.6",
|
||||||
"bcrypt": "^5.1.1",
|
"bcrypt": "^5.1.1",
|
||||||
"nodemailer": "^6.9.13",
|
"nodemailer": "^6.9.13",
|
||||||
"sqlite3": "^5.1.7",
|
"sqlite3": "^5.1.7",
|
||||||
|
|
12
readme.md
12
readme.md
|
@ -18,6 +18,18 @@
|
||||||
- `tools/build` ausführen
|
- `tools/build` ausführen
|
||||||
|
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
### Voraussetzungen
|
||||||
|
|
||||||
|
- [mocha](https://mochajs.org/) (Debian-Paket-Name: `mocha`)
|
||||||
|
|
||||||
|
|
||||||
|
### Anweisungen
|
||||||
|
|
||||||
|
- `tools/test` ausführen
|
||||||
|
|
||||||
|
|
||||||
## Betrieb
|
## Betrieb
|
||||||
|
|
||||||
### Voraussetzungen
|
### Voraussetzungen
|
||||||
|
|
266
source/conf.ts
266
source/conf.ts
|
@ -123,6 +123,147 @@ namespace _espe.conf
|
||||||
var _data : (null | type_conf) = null;
|
var _data : (null | type_conf) = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export function inject(
|
||||||
|
conf_raw : any
|
||||||
|
) : void
|
||||||
|
{
|
||||||
|
_data = {
|
||||||
|
"general": (
|
||||||
|
((node_general) => ({
|
||||||
|
"verbosity": (node_general["verbosity"] ?? "notice"),
|
||||||
|
"verification_secret": (node_general["verification_secret"] ?? null),
|
||||||
|
})) (conf_raw["general"] ?? {})
|
||||||
|
),
|
||||||
|
"server": (
|
||||||
|
((node_server) => ({
|
||||||
|
"port": (node_server["port"] ?? 7979),
|
||||||
|
"path_base": (node_server["path_base"] ?? ""),
|
||||||
|
})) (conf_raw["server"] ?? {})
|
||||||
|
),
|
||||||
|
"database": (
|
||||||
|
((node_database) => {
|
||||||
|
const kind : string = (node_database["kind"] ?? "sqlite");
|
||||||
|
const node_database_data_raw = (node_database["data"] ?? {});
|
||||||
|
switch (kind) {
|
||||||
|
case "sqlite": {
|
||||||
|
return {
|
||||||
|
"kind": kind,
|
||||||
|
"data": {
|
||||||
|
"path": (node_database_data_raw["path"] ?? "data.sqlite"),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "postgresql": {
|
||||||
|
return {
|
||||||
|
"kind": kind,
|
||||||
|
"data": node_database_data_raw,
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw (new Error("unhandled"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) (conf_raw["database"] ?? {})
|
||||||
|
),
|
||||||
|
"email_sending": (
|
||||||
|
((node_email_sending) => {
|
||||||
|
const kind : string = (node_email_sending["kind"] ?? "regular");
|
||||||
|
const data_raw = (node_email_sending["data"] ?? {});
|
||||||
|
switch (kind) {
|
||||||
|
case "regular": {
|
||||||
|
return {
|
||||||
|
"kind": kind,
|
||||||
|
"data": {
|
||||||
|
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
||||||
|
"sender": data_raw["sender"],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "redirect": {
|
||||||
|
return {
|
||||||
|
"kind": kind,
|
||||||
|
"data": {
|
||||||
|
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
||||||
|
"sender": data_raw["sender"],
|
||||||
|
"target": data_raw["target"],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "console": {
|
||||||
|
return {
|
||||||
|
"kind": kind,
|
||||||
|
"data": {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "drop": {
|
||||||
|
return {
|
||||||
|
"kind": kind,
|
||||||
|
"data": {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw (new Error("unhandled"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) (conf_raw["email_sending"] ?? {})
|
||||||
|
),
|
||||||
|
"session_management": (
|
||||||
|
((node_session_management) => ({
|
||||||
|
"in_memory": (node_session_management["in_memory"] ?? true),
|
||||||
|
"drop_all_at_start": (node_session_management["drop_all_at_start"] ?? true),
|
||||||
|
"lifetime": (node_session_management["lifetime"] ?? 900),
|
||||||
|
})) (conf_raw["session_management"] ?? {})
|
||||||
|
),
|
||||||
|
"settings": (
|
||||||
|
((node_settings) => ({
|
||||||
|
"target_domain": (node_settings["target_domain"] ?? "example.org"),
|
||||||
|
"prefix_for_numberbased_email_addresses": (node_settings["prefix_for_numberbased_email_addresses"] ?? "member-"),
|
||||||
|
"registration_email": {
|
||||||
|
"subject": ((node_settings["registration_email"] ?? {})["subject"] ?? "Registration"),
|
||||||
|
"body": ((node_settings["registration_email"] ?? {})["body"] ?? "URL: {{url}}"),
|
||||||
|
},
|
||||||
|
"password_policy": (
|
||||||
|
((node_settings_password_policy) => ({
|
||||||
|
"minimum_length": (
|
||||||
|
("minimum_length" in node_settings_password_policy)
|
||||||
|
? node_settings_password_policy["minimum_length"]
|
||||||
|
: 8
|
||||||
|
),
|
||||||
|
"maximum_length": (
|
||||||
|
("maximum_length" in node_settings_password_policy)
|
||||||
|
? node_settings_password_policy["maximum_length"]
|
||||||
|
: 240
|
||||||
|
),
|
||||||
|
"must_contain_letter": (node_settings_password_policy["must_contain_letter"] ?? true),
|
||||||
|
"must_contain_number": (node_settings_password_policy["must_contain_number"] ?? true),
|
||||||
|
"must_contain_special_character": (node_settings_password_policy["must_contain_special_character"] ?? true),
|
||||||
|
})) (node_settings["password_policy"] ?? {})
|
||||||
|
),
|
||||||
|
"name_index": (
|
||||||
|
((node_settings_password_policy) => ({
|
||||||
|
"veil": (node_settings_password_policy["veil"] ?? false),
|
||||||
|
"salt": (node_settings_password_policy["salt"] ?? null),
|
||||||
|
})) (node_settings["name_index"] ?? {})
|
||||||
|
),
|
||||||
|
})) (conf_raw["settings"] ?? {})
|
||||||
|
),
|
||||||
|
"admins": (conf_raw["admins"] ?? []),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo mandatory fields
|
* @todo mandatory fields
|
||||||
*/
|
*/
|
||||||
|
@ -147,130 +288,7 @@ namespace _espe.conf
|
||||||
return Promise.reject<void>("configuration file could not be read");
|
return Promise.reject<void>("configuration file could not be read");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_data = {
|
inject(conf_raw);
|
||||||
"general": (
|
|
||||||
((node_general) => ({
|
|
||||||
"verbosity": (node_general["verbosity"] ?? "notice"),
|
|
||||||
"verification_secret": (node_general["verification_secret"] ?? null),
|
|
||||||
})) (conf_raw["general"] ?? {})
|
|
||||||
),
|
|
||||||
"server": (
|
|
||||||
((node_server) => ({
|
|
||||||
"port": (node_server["port"] ?? 7979),
|
|
||||||
"path_base": (node_server["path_base"] ?? ""),
|
|
||||||
})) (conf_raw["server"] ?? {})
|
|
||||||
),
|
|
||||||
"database": (
|
|
||||||
((node_database) => {
|
|
||||||
const kind : string = (node_database["kind"] ?? "sqlite");
|
|
||||||
const node_database_data_raw = (node_database["data"] ?? {});
|
|
||||||
switch (kind) {
|
|
||||||
case "sqlite": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"path": (node_database_data_raw["path"] ?? "data.sqlite"),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "postgresql": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": node_database_data_raw,
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw (new Error("unhandled"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) (conf_raw["database"] ?? {})
|
|
||||||
),
|
|
||||||
"email_sending": (
|
|
||||||
((node_email_sending) => {
|
|
||||||
const kind : string = (node_email_sending["kind"] ?? "regular");
|
|
||||||
const data_raw = (node_email_sending["data"] ?? {});
|
|
||||||
switch (kind) {
|
|
||||||
case "regular": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
|
||||||
"sender": data_raw["sender"],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "redirect": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
|
||||||
"sender": data_raw["sender"],
|
|
||||||
"target": data_raw["target"],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "console": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "drop": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw (new Error("unhandled"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) (conf_raw["email_sending"] ?? {})
|
|
||||||
),
|
|
||||||
"session_management": (
|
|
||||||
((node_session_management) => ({
|
|
||||||
"in_memory": (node_session_management["in_memory"] ?? true),
|
|
||||||
"drop_all_at_start": (node_session_management["drop_all_at_start"] ?? true),
|
|
||||||
"lifetime": (node_session_management["lifetime"] ?? 900),
|
|
||||||
})) (conf_raw["session_management"] ?? {})
|
|
||||||
),
|
|
||||||
"settings": (
|
|
||||||
((node_settings) => ({
|
|
||||||
"target_domain": (node_settings["target_domain"] ?? "example.org"),
|
|
||||||
"prefix_for_numberbased_email_addresses": (node_settings["prefix_for_numberbased_email_addresses"] ?? "member-"),
|
|
||||||
"registration_email": {
|
|
||||||
"subject": ((node_settings["registration_email"] ?? {})["subject"] ?? "Registration"),
|
|
||||||
"body": ((node_settings["registration_email"] ?? {})["body"] ?? "URL: {{url}}"),
|
|
||||||
},
|
|
||||||
"password_policy": (
|
|
||||||
((node_settings_password_policy) => ({
|
|
||||||
"minimum_length": (node_settings_password_policy["minimum_length"] ?? 8),
|
|
||||||
"maximum_length": (node_settings_password_policy["maximum_length"] ?? 240),
|
|
||||||
"must_contain_letter": (node_settings_password_policy["must_contain_letter"] ?? true),
|
|
||||||
"must_contain_number": (node_settings_password_policy["must_contain_number"] ?? true),
|
|
||||||
"must_contain_special_character": (node_settings_password_policy["must_contain_special_character"] ?? true),
|
|
||||||
})) (node_settings["password_policy"] ?? {})
|
|
||||||
),
|
|
||||||
"name_index": (
|
|
||||||
((node_settings_password_policy) => ({
|
|
||||||
"veil": (node_settings_password_policy["veil"] ?? false),
|
|
||||||
"salt": (node_settings_password_policy["salt"] ?? null),
|
|
||||||
})) (node_settings["name_index"] ?? {})
|
|
||||||
),
|
|
||||||
})) (conf_raw["settings"] ?? {})
|
|
||||||
),
|
|
||||||
"admins": (conf_raw["admins"] ?? []),
|
|
||||||
};
|
|
||||||
// process.stderr.write(JSON.stringify(_data, undefined, "\t"));
|
// process.stderr.write(JSON.stringify(_data, undefined, "\t"));
|
||||||
return Promise.resolve<void>(undefined);
|
return Promise.resolve<void>(undefined);
|
||||||
}
|
}
|
||||||
|
|
130
source/tests.mocha.ts
Normal file
130
source/tests.mocha.ts
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
const nm_assert = require("assert");
|
||||||
|
|
||||||
|
describe(
|
||||||
|
"member.validate_password",
|
||||||
|
() => {
|
||||||
|
const cases : Array<
|
||||||
|
{
|
||||||
|
name : string;
|
||||||
|
input : {
|
||||||
|
conf : any;
|
||||||
|
password : string;
|
||||||
|
};
|
||||||
|
output : Array<
|
||||||
|
{
|
||||||
|
incident : string;
|
||||||
|
details : Record<string, any>;
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
}
|
||||||
|
> = [
|
||||||
|
{
|
||||||
|
"name": "minimum_length:negative",
|
||||||
|
"input": {
|
||||||
|
"conf": {
|
||||||
|
"settings": {
|
||||||
|
"password_policy": {
|
||||||
|
"minimum_length": 5,
|
||||||
|
"maximum_length": null,
|
||||||
|
"must_contain_letter": false,
|
||||||
|
"must_contain_number": false,
|
||||||
|
"must_contain_special_character": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"password": "abcde"
|
||||||
|
},
|
||||||
|
"output": [
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "minimum_lengt:positive",
|
||||||
|
"input": {
|
||||||
|
"conf": {
|
||||||
|
"settings": {
|
||||||
|
"password_policy": {
|
||||||
|
"minimum_length": 5,
|
||||||
|
"maximum_length": null,
|
||||||
|
"must_contain_letter": false,
|
||||||
|
"must_contain_number": false,
|
||||||
|
"must_contain_special_character": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"password": "abcd"
|
||||||
|
},
|
||||||
|
"output": [
|
||||||
|
{
|
||||||
|
"incident": "too_short",
|
||||||
|
"details": {
|
||||||
|
"minimum_length": 5,
|
||||||
|
"actual_length": 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "maximum_length:negative",
|
||||||
|
"input": {
|
||||||
|
"conf": {
|
||||||
|
"settings": {
|
||||||
|
"password_policy": {
|
||||||
|
"minimum_length": null,
|
||||||
|
"maximum_length": 5,
|
||||||
|
"must_contain_letter": false,
|
||||||
|
"must_contain_number": false,
|
||||||
|
"must_contain_special_character": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"password": "abcde"
|
||||||
|
},
|
||||||
|
"output": [
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "maximum_lengt:positive",
|
||||||
|
"input": {
|
||||||
|
"conf": {
|
||||||
|
"settings": {
|
||||||
|
"password_policy": {
|
||||||
|
"minimum_length": null,
|
||||||
|
"maximum_length": 5,
|
||||||
|
"must_contain_letter": false,
|
||||||
|
"must_contain_number": false,
|
||||||
|
"must_contain_special_character": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"password": "abcdef"
|
||||||
|
},
|
||||||
|
"output": [
|
||||||
|
{
|
||||||
|
"incident": "too_long",
|
||||||
|
"details": {
|
||||||
|
"maximum_length": 5,
|
||||||
|
"actual_length": 6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
];
|
||||||
|
cases.forEach(
|
||||||
|
case_ => {
|
||||||
|
it(
|
||||||
|
case_.name,
|
||||||
|
() => {
|
||||||
|
_espe.conf.inject(case_.input.conf);
|
||||||
|
const result : Array<
|
||||||
|
{
|
||||||
|
incident : string;
|
||||||
|
details : Record<string, any>;
|
||||||
|
}
|
||||||
|
> = _espe.service.member.validate_password(case_.input.password);
|
||||||
|
nm_assert.deepEqual(result, case_.output);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
13
tools/build
13
tools/build
|
@ -1,5 +1,14 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
## args
|
||||||
|
|
||||||
|
if [ $# -ge 1 ] ; then arg1=$1 && shift ; else arg1="" ; fi
|
||||||
|
|
||||||
|
|
||||||
## exec
|
## exec
|
||||||
|
|
||||||
make --file=tools/makefile
|
targets=""
|
||||||
|
targets="${targets} build/espe"
|
||||||
|
if [ ${arg1} == "-t" ] ; then targets="${targets} test" ; fi
|
||||||
|
|
||||||
|
make --file=tools/makefile ${targets}
|
||||||
|
|
|
@ -15,8 +15,13 @@ cmd_cp := cp
|
||||||
## rules
|
## rules
|
||||||
|
|
||||||
.PHONY: default
|
.PHONY: default
|
||||||
default: node_modules ${dir_build}/espe
|
default: main
|
||||||
|
|
||||||
|
.PHONY: main
|
||||||
|
main: node_modules ${dir_build}/espe
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: ${dir_build}/espe-test.mocha.js
|
||||||
|
|
||||||
.PHONY: node_modules
|
.PHONY: node_modules
|
||||||
node_modules:
|
node_modules:
|
||||||
|
@ -24,38 +29,65 @@ node_modules:
|
||||||
@ ${cmd_log} "node modules …"
|
@ ${cmd_log} "node modules …"
|
||||||
@ ${cmd_cp} -r -u ${dir_lib}/node/node_modules/* ${dir_build}/node_modules/
|
@ ${cmd_cp} -r -u ${dir_lib}/node/node_modules/* ${dir_build}/node_modules/
|
||||||
|
|
||||||
${dir_temp}/espe-unlinked.js: \
|
${dir_temp}/espe-core.js ${dir_temp}/espe-core.d.ts: \
|
||||||
${dir_lib}/plankton/plankton.d.ts \
|
${dir_lib}/plankton/plankton.d.ts \
|
||||||
${dir_source}/helpers.ts \
|
${dir_source}/helpers.ts \
|
||||||
${dir_source}/database.ts \
|
${dir_source}/database.ts \
|
||||||
${dir_source}/types.ts \
|
${dir_source}/types.ts \
|
||||||
${dir_source}/repositories/name_index.ts \
|
${dir_source}/repositories/name_index.ts \
|
||||||
${dir_source}/repositories/member.ts \
|
${dir_source}/repositories/member.ts \
|
||||||
${dir_source}/services/name_index.ts \
|
${dir_source}/services/name_index.ts \
|
||||||
${dir_source}/services/member.ts \
|
${dir_source}/services/member.ts \
|
||||||
${dir_source}/service-admin.ts \
|
${dir_source}/service-admin.ts \
|
||||||
${dir_source}/api/base.ts \
|
${dir_source}/api/base.ts \
|
||||||
${dir_source}/api/actions/session_begin.ts \
|
${dir_source}/api/actions/session_begin.ts \
|
||||||
${dir_source}/api/actions/session_end.ts \
|
${dir_source}/api/actions/session_end.ts \
|
||||||
${dir_source}/api/actions/email.ts \
|
${dir_source}/api/actions/member_project.ts \
|
||||||
${dir_source}/api/actions/verification_get.ts \
|
${dir_source}/api/actions/member_summon.ts \
|
||||||
${dir_source}/api/actions/verification_check.ts \
|
${dir_source}/api/actions/member_info.ts \
|
||||||
${dir_source}/api/actions/member_project.ts \
|
${dir_source}/api/actions/member_register.ts \
|
||||||
${dir_source}/api/actions/member_summon.ts \
|
${dir_source}/api/actions/member_list.ts \
|
||||||
${dir_source}/api/actions/member_info.ts \
|
${dir_source}/api/actions/member_read.ts \
|
||||||
${dir_source}/api/actions/member_register.ts \
|
${dir_source}/api/actions/member_modify.ts \
|
||||||
${dir_source}/api/actions/member_list.ts \
|
${dir_source}/api/functions.ts \
|
||||||
${dir_source}/api/actions/member_read.ts \
|
${dir_source}/conf.ts
|
||||||
${dir_source}/api/actions/member_modify.ts \
|
@ ${cmd_log} "compile | core …"
|
||||||
${dir_source}/api/functions.ts \
|
@ ${cmd_mkdir} $(dir $@)
|
||||||
${dir_source}/conf.ts \
|
@ tsc --lib es2020 $^ --outFile ${dir_temp}/espe-core.js --declaration
|
||||||
${dir_source}/main.ts
|
|
||||||
@ ${cmd_log} "compile …"
|
${dir_temp}/espe-main-raw.js: \
|
||||||
|
${dir_lib}/plankton/plankton.d.ts \
|
||||||
|
${dir_temp}/espe-core.d.ts \
|
||||||
|
${dir_source}/main.ts
|
||||||
|
@ ${cmd_log} "compile | main …"
|
||||||
@ ${cmd_mkdir} $(dir $@)
|
@ ${cmd_mkdir} $(dir $@)
|
||||||
@ tsc --lib es2020 $^ --outFile $@
|
@ tsc --lib es2020 $^ --outFile $@
|
||||||
|
|
||||||
${dir_build}/espe: ${dir_source}/head.js ${dir_lib}/plankton/plankton.js ${dir_temp}/espe-unlinked.js
|
${dir_temp}/espe-test-raw.js: \
|
||||||
@ ${cmd_log} "link …"
|
${dir_lib}/plankton/plankton.d.ts \
|
||||||
|
${dir_temp}/espe-core.d.ts \
|
||||||
|
${dir_lib}/node/node_modules/@types/mocha/index.d.ts \
|
||||||
|
${dir_source}/tests.mocha.ts
|
||||||
|
@ ${cmd_log} "compile | test …"
|
||||||
|
@ ${cmd_mkdir} $(dir $@)
|
||||||
|
@ tsc --lib es2020 $^ --outFile $@
|
||||||
|
|
||||||
|
${dir_build}/espe: \
|
||||||
|
${dir_source}/head.js \
|
||||||
|
${dir_lib}/plankton/plankton.js \
|
||||||
|
${dir_temp}/espe-core.js \
|
||||||
|
${dir_temp}/espe-main-raw.js
|
||||||
|
@ ${cmd_log} "link | main …"
|
||||||
|
@ ${cmd_mkdir} $(dir $@)
|
||||||
|
@ ${cmd_cat} $^ > $@
|
||||||
|
@ ${cmd_chmod} +x $@
|
||||||
|
|
||||||
|
${dir_build}/espe-test.mocha.js: \
|
||||||
|
${dir_source}/head.js \
|
||||||
|
${dir_lib}/plankton/plankton.js \
|
||||||
|
${dir_temp}/espe-core.js \
|
||||||
|
${dir_temp}/espe-test-raw.js
|
||||||
|
@ ${cmd_log} "link | test …"
|
||||||
@ ${cmd_mkdir} $(dir $@)
|
@ ${cmd_mkdir} $(dir $@)
|
||||||
@ ${cmd_cat} $^ > $@
|
@ ${cmd_cat} $^ > $@
|
||||||
@ ${cmd_chmod} +x $@
|
@ ${cmd_chmod} +x $@
|
||||||
|
|
4
tools/test
Executable file
4
tools/test
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
tools/build -t
|
||||||
|
mocha build/espe-test.mocha.js
|
Loading…
Add table
Reference in a new issue