46 Commits

Author SHA1 Message Date
0b56464a5f 1.0.27 2020-10-20 20:31:28 +00:00
4805687305 fix(core): update 2020-10-20 20:31:28 +00:00
c387a633bb 1.0.26 2020-10-20 20:28:34 +00:00
99efc2d5fe fix(core): update 2020-10-20 20:28:33 +00:00
e146b7741d 1.0.25 2020-09-24 00:59:02 +00:00
02866cbe8d fix(core): update 2020-09-24 00:59:01 +00:00
7a320d27a3 1.0.24 2020-09-24 00:45:24 +00:00
7910f9a856 fix(core): update 2020-09-24 00:45:23 +00:00
05194609fe 1.0.23 2020-09-24 00:32:54 +00:00
eb0ec04199 fix(core): update 2020-09-24 00:32:54 +00:00
ffd5eb2e52 1.0.22 2020-09-23 23:54:46 +00:00
c432079a70 fix(core): update 2020-09-23 23:54:46 +00:00
e2cab0bb59 1.0.21 2020-09-23 23:30:55 +00:00
aaaa8b3ee4 fix(core): update 2020-09-23 23:30:54 +00:00
4cc149069e 1.0.20 2020-07-28 17:24:53 +00:00
6c106a4f22 fix(core): update 2020-07-28 17:24:53 +00:00
85fca378ff 1.0.19 2020-07-28 17:14:17 +00:00
d096a08e42 fix(core): update 2020-07-28 17:14:16 +00:00
a715dd9e8c 1.0.18 2020-07-26 15:02:25 +00:00
ef8bf0a0d8 fix(core): update 2020-07-26 15:02:24 +00:00
f6d8910c45 1.0.17 2020-07-26 14:34:48 +00:00
0917b9dd06 fix(core): update 2020-07-26 14:34:47 +00:00
0455c34cfa 1.0.16 2020-07-26 14:01:17 +00:00
a69fee7985 fix(core): update 2020-07-26 14:01:17 +00:00
3e0d01520e 1.0.15 2020-07-26 13:54:47 +00:00
7c4db19825 fix(core): update 2020-07-26 13:54:46 +00:00
f7205e2f29 1.0.14 2020-07-25 16:58:07 +00:00
0caf4becbe fix(core): update 2020-07-25 16:58:06 +00:00
42af79a271 1.0.13 2020-07-25 16:34:11 +00:00
4dad23896c fix(core): update 2020-07-25 16:34:10 +00:00
03ae15b10d 1.0.12 2020-07-25 15:53:45 +00:00
f66a5a80e1 fix(core): update 2020-07-25 15:53:45 +00:00
4bd3c65588 1.0.11 2020-07-25 15:48:24 +00:00
f29dd9bf1c fix(core): update 2020-07-25 15:48:24 +00:00
2eeb4b7925 1.0.10 2020-07-25 15:47:35 +00:00
7e34275029 fix(core): update 2020-07-25 15:47:34 +00:00
c0e264146b 1.0.9 2020-07-25 15:40:11 +00:00
951772d515 fix(core): update 2020-07-25 15:40:10 +00:00
d786a3b7cd 1.0.8 2020-07-25 13:42:49 +00:00
6e0a48cc49 fix(core): update 2020-07-25 13:42:49 +00:00
88c0fc101b 1.0.7 2020-07-25 13:34:27 +00:00
6ec6869e9c fix(core): update 2020-07-25 13:34:26 +00:00
6df4f8de77 1.0.6 2020-07-05 23:35:55 +00:00
29f4529dd8 fix(core): update 2020-07-05 23:35:55 +00:00
a2392644b1 1.0.5 2020-07-05 23:31:26 +00:00
4a8c3159c0 fix(core): update 2020-07-05 23:31:26 +00:00
7 changed files with 7251 additions and 1134 deletions

View File

@@ -19,23 +19,35 @@ mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
audit:
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high
- npmci command npm audit --audit-level=high --only=dev
tags:
- lossless
- docker
- notpriv
allow_failure: true
# ====================
# test stage
@@ -50,9 +62,7 @@ testStable:
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- priv
testBuild:
stage: test
@@ -63,9 +73,7 @@ testBuild:
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- notpriv
release:
stage: release
@@ -85,6 +93,8 @@ release:
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare

View File

@@ -15,7 +15,7 @@
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm"]
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}

8205
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@apiglobal/test-sdk",
"version": "1.0.4",
"version": "1.0.27",
"private": false,
"description": "an sdk for testing ag handlers",
"main": "dist_ts/index.js",
@@ -12,16 +12,20 @@
"build": "(tsbuild --web)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^14.0.14",
"tslint": "^6.1.2",
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.14.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@apiglobal/sdk": "^1.0.9",
"@pushrocks/smartexpress": "^3.0.73"
"@apiglobal/sdk": "^1.0.18",
"@apiglobal/typedrequest": "^1.0.54",
"@apiglobal/typedrequest-interfaces": "^1.0.15",
"@pushrocks/qenv": "^4.0.10",
"@pushrocks/smartexpress": "^3.0.81",
"@pushrocks/smartobject": "^1.0.4"
},
"files": [
"ts/**/*",
@@ -34,5 +38,8 @@
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

View File

@@ -1,17 +1,88 @@
import * as plugins from './test-sdk.plugins';
import { AgTestServer } from './test-sdk.classes.testserver';
import { AAgHandler } from '@apiglobal/sdk';
export { AgTestServer };
let testServer: AgTestServer;
export const createTestServer = async (handlerArg: plugins.agSdk.AAgHandler<any>) => {
testServer = new AgTestServer(handlerArg);
let handler: AAgHandler<any>;
export const createTestServer = async (handlerArg: {
new (envManagerArg: plugins.agSdk.AgEnvironment): plugins.agSdk.AAgHandler<any>;
}) => {
class AgEnvironement extends plugins.agSdk.AgEnvironment {
public qenv = new plugins.qenv.Qenv('./', './.nogit');
public async getEnvVar(nameArg: string) {
return this.qenv.getEnvVarOnDemand(nameArg);
}
}
handler = new handlerArg(new AgEnvironement());
console.log(`now checking requirements for handler with slug ${handler.slug}...`);
await handler.checkRequirements();
testServer = new AgTestServer(handler);
await testServer.start();
return testServer;
};
export const testFire = <
A extends plugins.agSdk.AAgHandler<any>,
T extends plugins.typedrequestInterfaces.ITypedRequest
>(
slugArg: A['slug'],
methodArg: T['method'],
requestArg: T['request']
) => {
if (!testServer) {
throw new Error('you need to create and start a testServer first!');
}
if (testServer.server.serverStatus !== 'running') {
throw new Error('you need to start the testServer first!');
}
const typedRequest = new plugins.typedrequest.TypedRequest<T>(
`http://localhost:${testServer.server.options.port}/${slugArg}`,
methodArg
);
const responsePromise = typedRequest.fire(requestArg);
const expect = async (expectedResponseArg: T['response']) => {
const actualResponse = await responsePromise;
const comparisonResult = plugins.smartobject.compareObjects(
expectedResponseArg,
actualResponse
);
let throwErrorBool = false;
if (comparisonResult.divergingProperties.length > 0) {
console.log(`The following properties diverged:`);
console.log(comparisonResult.divergingProperties);
for (const divProperty of comparisonResult.divergingProperties) {
if (expectedResponseArg[divProperty] !== 'maydiverge') {
throwErrorBool = true;
} else {
console.log(`${divProperty} may diverge, not throwing for this one`);
}
}
}
if (comparisonResult.missingProperties.length > 0) {
console.log(`The following properties diverged:`);
console.log(comparisonResult.divergingProperties);
throwErrorBool = true;
}
if (throwErrorBool) {
console.log('Result: response did not comply');
console.log('-> expected:');
console.log(expectedResponseArg);
console.log('-> but actually received:');
console.log(actualResponse);
throw new Error('response did not comply');
}
return actualResponse;
};
return {
expect,
};
};
export const stopTestServer = async () => {
if (testServer) {
await testServer.stop();
await handler.stop();
}
};

View File

@@ -6,37 +6,47 @@ export class AgTestServer {
constructor(handlerArg?: plugins.agSdk.AAgHandler<any>) {
if (handlerArg) {
this.handlers.push(handlerArg);
this.addAgHandler(handlerArg);
}
}
public async addAgHandler(handlerArg: plugins.agSdk.AAgHandler<any>) {
this.handlers.push(handlerArg);
console.log(`added handler with slug ${handlerArg.slug}`);
if (this.server && this.server.serverStatus === 'running') {
await this.stop();
await this.start();
}
}
public async start() {
this.server = new plugins.smartexpress.Server({
cors: true,
forceSsl: false,
defaultAnswer: async () => 'apiglobal testserver',
domain: 'localhost',
forceSsl: false,
port: 3000,
});
for (const handlerArg of this.handlers) {
console.log(`found handler with slug ${handlerArg.slug}`);
await handlerArg.start();
console.log(`started handler with slug ${handlerArg.slug}`);
const slugroute = `/${handlerArg.slug}`;
this.server.addRoute(
`/${handlerArg.slug}`,
slugroute,
new plugins.smartexpress.HandlerTypedRouter(handlerArg.typedrouter)
);
console.log(`added slugroute ${slugroute}`);
}
await this.server.start();
}
public async stop() {
if (this.server) {
const previousServer = this.server;
this.server = null;
await this.server.startedPromise;
await this.server.stop();
await previousServer.startedPromise;
await previousServer.stop();
}
}
}

View File

@@ -1,9 +1,13 @@
// apiglobal scope
import * as agSdk from '@apiglobal/sdk';
import * as typedrequest from '@apiglobal/typedrequest';
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
export { agSdk };
export { agSdk, typedrequest, typedrequestInterfaces };
// pushrocks scope
import * as qenv from '@pushrocks/qenv';
import * as smartexpress from '@pushrocks/smartexpress';
import * as smartobject from '@pushrocks/smartobject';
export { smartexpress };
export { qenv, smartexpress, smartobject };