@webda/core 2.0.0-beta.3 → 2.0.0
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/lib/application.d.ts +5 -5
- package/lib/application.js +71 -84
- package/lib/application.js.map +1 -1
- package/lib/application.spec.js +121 -140
- package/lib/application.spec.js.map +1 -1
- package/lib/core.d.ts +20 -24
- package/lib/core.js +222 -315
- package/lib/core.js.map +1 -1
- package/lib/core.spec.js +332 -406
- package/lib/core.spec.js.map +1 -1
- package/lib/index.d.ts +49 -48
- package/lib/index.js +53 -70
- package/lib/index.js.map +1 -1
- package/lib/models/aclmodel.d.ts +2 -2
- package/lib/models/aclmodel.js +63 -90
- package/lib/models/aclmodel.js.map +1 -1
- package/lib/models/aclmodel.spec.js +127 -152
- package/lib/models/aclmodel.spec.js.map +1 -1
- package/lib/models/coremodel.d.ts +7 -6
- package/lib/models/coremodel.js +65 -113
- package/lib/models/coremodel.js.map +1 -1
- package/lib/models/coremodel.spec.js +88 -107
- package/lib/models/coremodel.spec.js.map +1 -1
- package/lib/models/deployment.js +1 -2
- package/lib/models/ident.d.ts +3 -3
- package/lib/models/ident.js +4 -9
- package/lib/models/ident.js.map +1 -1
- package/lib/models/ident.spec.js +9 -11
- package/lib/models/ident.spec.js.map +1 -1
- package/lib/models/ownermodel.d.ts +2 -2
- package/lib/models/ownermodel.js +39 -62
- package/lib/models/ownermodel.js.map +1 -1
- package/lib/models/ownermodel.spec.js +126 -168
- package/lib/models/ownermodel.spec.js.map +1 -1
- package/lib/models/rolemodel.d.ts +1 -1
- package/lib/models/rolemodel.js +24 -40
- package/lib/models/rolemodel.js.map +1 -1
- package/lib/models/rolemodel.spec.js +44 -63
- package/lib/models/rolemodel.spec.js.map +1 -1
- package/lib/models/user.d.ts +3 -3
- package/lib/models/user.js +3 -8
- package/lib/models/user.js.map +1 -1
- package/lib/models/user.spec.js +14 -16
- package/lib/models/user.spec.js.map +1 -1
- package/lib/queues/filequeue.d.ts +2 -2
- package/lib/queues/filequeue.js +72 -93
- package/lib/queues/filequeue.js.map +1 -1
- package/lib/queues/filequeue.spec.js +53 -70
- package/lib/queues/filequeue.spec.js.map +1 -1
- package/lib/queues/memoryqueue.d.ts +2 -2
- package/lib/queues/memoryqueue.js +37 -61
- package/lib/queues/memoryqueue.js.map +1 -1
- package/lib/queues/memoryqueue.spec.js +142 -165
- package/lib/queues/memoryqueue.spec.js.map +1 -1
- package/lib/queues/pubsubservice.d.ts +2 -2
- package/lib/queues/pubsubservice.js +3 -7
- package/lib/queues/pubsubservice.js.map +1 -1
- package/lib/queues/queue.spec.d.ts +1 -1
- package/lib/queues/queue.spec.js +42 -56
- package/lib/queues/queue.spec.js.map +1 -1
- package/lib/queues/queueservice.d.ts +3 -3
- package/lib/queues/queueservice.js +51 -67
- package/lib/queues/queueservice.js.map +1 -1
- package/lib/router.d.ts +3 -3
- package/lib/router.js +46 -47
- package/lib/router.js.map +1 -1
- package/lib/router.spec.js +64 -61
- package/lib/router.spec.js.map +1 -1
- package/lib/services/asyncevents.d.ts +2 -2
- package/lib/services/asyncevents.js +44 -64
- package/lib/services/asyncevents.js.map +1 -1
- package/lib/services/asyncevents.spec.js +81 -98
- package/lib/services/asyncevents.spec.js.map +1 -1
- package/lib/services/authentication.d.ts +23 -13
- package/lib/services/authentication.js +537 -563
- package/lib/services/authentication.js.map +1 -1
- package/lib/services/authentication.spec.js +411 -447
- package/lib/services/authentication.spec.js.map +1 -1
- package/lib/services/binary.d.ts +7 -5
- package/lib/services/binary.js +211 -244
- package/lib/services/binary.js.map +1 -1
- package/lib/services/binary.spec.d.ts +3 -3
- package/lib/services/binary.spec.js +390 -443
- package/lib/services/binary.spec.js.map +1 -1
- package/lib/services/cloudbinary.d.ts +3 -3
- package/lib/services/cloudbinary.js +45 -70
- package/lib/services/cloudbinary.js.map +1 -1
- package/lib/services/cloudbinary.spec.d.ts +3 -3
- package/lib/services/cloudbinary.spec.js +133 -162
- package/lib/services/cloudbinary.spec.js.map +1 -1
- package/lib/services/configuration.d.ts +1 -1
- package/lib/services/configuration.js +78 -105
- package/lib/services/configuration.js.map +1 -1
- package/lib/services/configuration.spec.js +63 -83
- package/lib/services/configuration.spec.js.map +1 -1
- package/lib/services/cron.d.ts +3 -2
- package/lib/services/cron.js +9 -13
- package/lib/services/cron.js.map +1 -1
- package/lib/services/cron.spec.js +18 -21
- package/lib/services/cron.spec.js.map +1 -1
- package/lib/services/cryptoservice.d.ts +9 -4
- package/lib/services/cryptoservice.js +187 -221
- package/lib/services/cryptoservice.js.map +1 -1
- package/lib/services/cryptoservice.spec.js +88 -115
- package/lib/services/cryptoservice.spec.js.map +1 -1
- package/lib/services/debugmailer.d.ts +1 -1
- package/lib/services/debugmailer.js +13 -34
- package/lib/services/debugmailer.js.map +1 -1
- package/lib/services/debugmailer.spec.js +16 -29
- package/lib/services/debugmailer.spec.js.map +1 -1
- package/lib/services/echo.d.ts +2 -2
- package/lib/services/echo.js +15 -31
- package/lib/services/echo.js.map +1 -1
- package/lib/services/echo.spec.js +27 -40
- package/lib/services/echo.spec.js.map +1 -1
- package/lib/services/filebinary.d.ts +5 -5
- package/lib/services/filebinary.js +165 -210
- package/lib/services/filebinary.js.map +1 -1
- package/lib/services/filebinary.spec.d.ts +2 -1
- package/lib/services/filebinary.spec.js +106 -116
- package/lib/services/filebinary.spec.js.map +1 -1
- package/lib/services/fileconfiguration.d.ts +1 -1
- package/lib/services/fileconfiguration.js +25 -44
- package/lib/services/fileconfiguration.js.map +1 -1
- package/lib/services/fileconfiguration.spec.js +79 -109
- package/lib/services/fileconfiguration.spec.js.map +1 -1
- package/lib/services/invitationservice.d.ts +7 -7
- package/lib/services/invitationservice.js +274 -314
- package/lib/services/invitationservice.js.map +1 -1
- package/lib/services/invitationservice.spec.js +442 -448
- package/lib/services/invitationservice.spec.js.map +1 -1
- package/lib/services/kubernetesconfiguration.d.ts +1 -1
- package/lib/services/kubernetesconfiguration.js +41 -60
- package/lib/services/kubernetesconfiguration.js.map +1 -1
- package/lib/services/kubernetesconfiguration.spec.js +80 -98
- package/lib/services/kubernetesconfiguration.spec.js.map +1 -1
- package/lib/services/mailer.d.ts +4 -4
- package/lib/services/mailer.js +62 -86
- package/lib/services/mailer.js.map +1 -1
- package/lib/services/mailer.spec.js +86 -127
- package/lib/services/mailer.spec.js.map +1 -1
- package/lib/services/notificationservice.d.ts +3 -3
- package/lib/services/notificationservice.js +21 -42
- package/lib/services/notificationservice.js.map +1 -1
- package/lib/services/notificationservice.spec.js +47 -73
- package/lib/services/notificationservice.spec.js.map +1 -1
- package/lib/services/oauth.d.ts +4 -4
- package/lib/services/oauth.js +68 -83
- package/lib/services/oauth.js.map +1 -1
- package/lib/services/oauth.spec.js +130 -156
- package/lib/services/oauth.spec.js.map +1 -1
- package/lib/services/proxy.d.ts +2 -6
- package/lib/services/proxy.js +45 -58
- package/lib/services/proxy.js.map +1 -1
- package/lib/services/proxy.spec.js +34 -53
- package/lib/services/proxy.spec.js.map +1 -1
- package/lib/services/resource.d.ts +2 -2
- package/lib/services/resource.js +12 -18
- package/lib/services/resource.js.map +1 -1
- package/lib/services/resource.spec.js +67 -99
- package/lib/services/resource.spec.js.map +1 -1
- package/lib/services/service.d.ts +26 -3
- package/lib/services/service.js +68 -40
- package/lib/services/service.js.map +1 -1
- package/lib/services/service.spec.js +62 -67
- package/lib/services/service.spec.js.map +1 -1
- package/lib/services/version.d.ts +1 -1
- package/lib/services/version.js +3 -8
- package/lib/services/version.js.map +1 -1
- package/lib/services/version.spec.js +11 -24
- package/lib/services/version.spec.js.map +1 -1
- package/lib/stores/aggregator.d.ts +2 -2
- package/lib/stores/aggregator.js +37 -58
- package/lib/stores/aggregator.js.map +1 -1
- package/lib/stores/file.d.ts +3 -3
- package/lib/stores/file.js +93 -131
- package/lib/stores/file.js.map +1 -1
- package/lib/stores/file.spec.d.ts +2 -2
- package/lib/stores/file.spec.js +261 -289
- package/lib/stores/file.spec.js.map +1 -1
- package/lib/stores/mapper.d.ts +3 -3
- package/lib/stores/mapper.js +110 -137
- package/lib/stores/mapper.js.map +1 -1
- package/lib/stores/mapper.spec.js +131 -150
- package/lib/stores/mapper.spec.js.map +1 -1
- package/lib/stores/memory.d.ts +3 -3
- package/lib/stores/memory.js +98 -144
- package/lib/stores/memory.js.map +1 -1
- package/lib/stores/memory.spec.d.ts +2 -2
- package/lib/stores/memory.spec.js +124 -145
- package/lib/stores/memory.spec.js.map +1 -1
- package/lib/stores/store.d.ts +17 -13
- package/lib/stores/store.js +819 -847
- package/lib/stores/store.js.map +1 -1
- package/lib/stores/store.spec.d.ts +5 -4
- package/lib/stores/store.spec.js +624 -669
- package/lib/stores/store.spec.js.map +1 -1
- package/lib/stores/webdaql/WebdaQLLexer.d.ts +4 -4
- package/lib/stores/webdaql/WebdaQLLexer.js +9 -13
- package/lib/stores/webdaql/WebdaQLLexer.js.map +1 -1
- package/lib/stores/webdaql/WebdaQLParserLexer.d.ts +4 -4
- package/lib/stores/webdaql/WebdaQLParserLexer.js +9 -13
- package/lib/stores/webdaql/WebdaQLParserLexer.js.map +1 -1
- package/lib/stores/webdaql/WebdaQLParserListener.d.ts +2 -2
- package/lib/stores/webdaql/WebdaQLParserListener.js +1 -2
- package/lib/stores/webdaql/WebdaQLParserListener.js.map +1 -1
- package/lib/stores/webdaql/WebdaQLParserParser.d.ts +10 -10
- package/lib/stores/webdaql/WebdaQLParserParser.js +62 -91
- package/lib/stores/webdaql/WebdaQLParserParser.js.map +1 -1
- package/lib/stores/webdaql/WebdaQLParserVisitor.d.ts +2 -2
- package/lib/stores/webdaql/WebdaQLParserVisitor.js +1 -2
- package/lib/stores/webdaql/WebdaQLParserVisitor.js.map +1 -1
- package/lib/stores/webdaql/query.d.ts +4 -5
- package/lib/stores/webdaql/query.js +16 -19
- package/lib/stores/webdaql/query.js.map +1 -1
- package/lib/stores/webdaql/query.spec.js +30 -32
- package/lib/stores/webdaql/query.spec.js.map +1 -1
- package/lib/test.d.ts +3 -3
- package/lib/test.js +73 -100
- package/lib/test.js.map +1 -1
- package/lib/unpackedapplication.d.ts +1 -1
- package/lib/unpackedapplication.js +25 -31
- package/lib/unpackedapplication.js.map +1 -1
- package/lib/utils/abstractdeployer.js +1 -5
- package/lib/utils/abstractdeployer.js.map +1 -1
- package/lib/utils/abstractdeployer.spec.js +6 -8
- package/lib/utils/abstractdeployer.spec.js.map +1 -1
- package/lib/utils/context.d.ts +7 -5
- package/lib/utils/context.js +95 -103
- package/lib/utils/context.js.map +1 -1
- package/lib/utils/context.spec.js +139 -163
- package/lib/utils/context.spec.js.map +1 -1
- package/lib/utils/cookie.d.ts +3 -3
- package/lib/utils/cookie.js +42 -61
- package/lib/utils/cookie.js.map +1 -1
- package/lib/utils/cookie.spec.js +42 -64
- package/lib/utils/cookie.spec.js.map +1 -1
- package/lib/utils/esm.d.ts +4 -0
- package/lib/utils/esm.js +10 -0
- package/lib/utils/esm.js.map +1 -0
- package/lib/utils/httpcontext.d.ts +3 -0
- package/lib/utils/httpcontext.js +48 -65
- package/lib/utils/httpcontext.js.map +1 -1
- package/lib/utils/httpcontext.spec.js +37 -56
- package/lib/utils/httpcontext.spec.js.map +1 -1
- package/lib/utils/logger.d.ts +2 -2
- package/lib/utils/logger.js +15 -28
- package/lib/utils/logger.js.map +1 -1
- package/lib/utils/logger.spec.js +9 -11
- package/lib/utils/logger.spec.js.map +1 -1
- package/lib/utils/serializers.js +17 -20
- package/lib/utils/serializers.js.map +1 -1
- package/lib/utils/serializers.spec.js +43 -44
- package/lib/utils/serializers.spec.js.map +1 -1
- package/lib/utils/session.d.ts +6 -6
- package/lib/utils/session.js +37 -59
- package/lib/utils/session.js.map +1 -1
- package/lib/utils/session.spec.js +38 -51
- package/lib/utils/session.spec.js.map +1 -1
- package/lib/utils/waiter.d.ts +1 -1
- package/lib/utils/waiter.js +32 -52
- package/lib/utils/waiter.js.map +1 -1
- package/lib/utils/waiter.spec.js +75 -92
- package/lib/utils/waiter.spec.js.map +1 -1
- package/package.json +17 -12
- package/test/config-invitation.json +1 -3
- package/test/config.json +1 -2
- package/test/config.old.json +1 -2
- package/test/moddas/annotatedservice.js +5 -5
- package/test/moddas/debugmailer.js +2 -3
- package/test/moddas/fakeservice.js +2 -3
- package/test/moddas/voidstore.js +6 -4
- package/test/models/ident.js +2 -6
- package/test/models/task.js +3 -7
- package/test/package.json +2 -1
- package/webda.module.json +956 -189
|
@@ -1,66 +1,47 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const mocha_1 = require("@testdeck/mocha");
|
|
19
|
-
const assert = require("assert");
|
|
20
|
-
const jwt = require("jsonwebtoken");
|
|
21
|
-
const sinon = require("sinon");
|
|
22
|
-
const test_1 = require("../test");
|
|
23
|
-
const serializers_1 = require("../utils/serializers");
|
|
7
|
+
import { suite, test } from "@testdeck/mocha";
|
|
8
|
+
import * as assert from "assert";
|
|
9
|
+
import jwt from "jsonwebtoken";
|
|
10
|
+
import * as sinon from "sinon";
|
|
11
|
+
import { WebdaTest } from "../test.js";
|
|
12
|
+
import { JSONUtils } from "../utils/serializers.js";
|
|
24
13
|
/**
|
|
25
14
|
*
|
|
26
15
|
*/
|
|
27
|
-
let CryptoServiceTest = class CryptoServiceTest extends
|
|
28
|
-
hmac() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
yield this.webda.getCrypto().hmacVerify(serializers_1.JSONUtils.stringify({ test: "plop" }), hmac);
|
|
35
|
-
});
|
|
16
|
+
let CryptoServiceTest = class CryptoServiceTest extends WebdaTest {
|
|
17
|
+
async hmac() {
|
|
18
|
+
let hmac = await this.webda.getCrypto().hmac({ test: "plop" });
|
|
19
|
+
let hmacString = await this.webda.getCrypto().hmac(JSONUtils.stringify({ test: "plop" }));
|
|
20
|
+
assert.strictEqual(hmac, hmacString);
|
|
21
|
+
await this.webda.getCrypto().hmacVerify({ test: "plop" }, hmac);
|
|
22
|
+
await this.webda.getCrypto().hmacVerify(JSONUtils.stringify({ test: "plop" }), hmac);
|
|
36
23
|
}
|
|
37
|
-
encryption() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
assert.strictEqual(decrypted.test, "plop");
|
|
42
|
-
});
|
|
24
|
+
async encryption() {
|
|
25
|
+
let encrypted = await this.webda.getCrypto().encrypt({ test: "plop" });
|
|
26
|
+
let decrypted = await this.webda.getCrypto().decrypt(encrypted);
|
|
27
|
+
assert.strictEqual(decrypted.test, "plop");
|
|
43
28
|
}
|
|
44
|
-
rotate() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
assert.strictEqual(yield crypto.hmac({ test: "plop" }, oldKey), hmac);
|
|
56
|
-
});
|
|
29
|
+
async rotate() {
|
|
30
|
+
const crypto = this.webda.getCrypto();
|
|
31
|
+
let encrypted = await crypto.encrypt({ test: "plop" });
|
|
32
|
+
let oldKey = crypto.current;
|
|
33
|
+
let hmac = await crypto.hmac({ test: "plop" });
|
|
34
|
+
sinon.stub(crypto, "getNextId").callsFake(this.nextIdStub(crypto));
|
|
35
|
+
await crypto.rotate();
|
|
36
|
+
let decrypted = await crypto.decrypt(encrypted);
|
|
37
|
+
assert.strictEqual(decrypted.test, "plop");
|
|
38
|
+
await crypto.hmacVerify({ test: "plop" }, hmac);
|
|
39
|
+
assert.strictEqual(await crypto.hmac({ test: "plop" }, oldKey), hmac);
|
|
57
40
|
}
|
|
58
|
-
failedRotation() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
yield this.webda.getCrypto().rotate();
|
|
63
|
-
});
|
|
41
|
+
async failedRotation() {
|
|
42
|
+
// Check failed rotate
|
|
43
|
+
await this.webda.getRegistry().patch({ uuid: "keys", current: "123" });
|
|
44
|
+
await this.webda.getCrypto().rotate();
|
|
64
45
|
}
|
|
65
46
|
/**
|
|
66
47
|
* Increment by one every time
|
|
@@ -74,91 +55,83 @@ let CryptoServiceTest = class CryptoServiceTest extends test_1.WebdaTest {
|
|
|
74
55
|
};
|
|
75
56
|
};
|
|
76
57
|
}
|
|
77
|
-
jwks() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
assert.strictEqual(body.keys.length, 2);
|
|
91
|
-
});
|
|
58
|
+
async jwks() {
|
|
59
|
+
const crypto = this.webda.getCrypto();
|
|
60
|
+
crypto.getParameters().url = "/jwk";
|
|
61
|
+
await crypto.resolve().init();
|
|
62
|
+
let ctx = await this.newContext();
|
|
63
|
+
await this.execute(ctx, "test.webda.io", "GET", "/jwk");
|
|
64
|
+
let body = JSON.parse(ctx.getResponseBody());
|
|
65
|
+
sinon.stub(crypto, "getNextId").callsFake(this.nextIdStub(crypto));
|
|
66
|
+
assert.strictEqual(body.keys.length, 1);
|
|
67
|
+
await crypto.rotate();
|
|
68
|
+
await this.execute(ctx, "test.webda.io", "GET", "/jwk");
|
|
69
|
+
body = JSON.parse(ctx.getResponseBody());
|
|
70
|
+
assert.strictEqual(body.keys.length, 2);
|
|
92
71
|
}
|
|
93
|
-
unknownKeys() {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
yield assert.rejects(() => this.webda.getCrypto().decrypt(encrypted), /err/);
|
|
116
|
-
});
|
|
72
|
+
async unknownKeys() {
|
|
73
|
+
const crypto = this.webda.getCrypto();
|
|
74
|
+
// Custom made JWT
|
|
75
|
+
let jwtToken = jwt.sign("TEST", "test");
|
|
76
|
+
await assert.rejects(() => crypto.jwtVerify(jwtToken), /Unknown key/);
|
|
77
|
+
jwtToken = jwt.sign("TEST", "test", { keyid: "B" + crypto.current });
|
|
78
|
+
await assert.rejects(() => crypto.jwtVerify(jwtToken), /Unknown key/);
|
|
79
|
+
assert.ok(!(await crypto.hmacVerify("mydata", "md.ss")));
|
|
80
|
+
let oldKey = crypto.current;
|
|
81
|
+
sinon.stub(crypto, "getNextId").callsFake(this.nextIdStub(crypto));
|
|
82
|
+
await crypto.rotate();
|
|
83
|
+
let encrypted = await this.webda.getCrypto().encrypt({ test: "plop" });
|
|
84
|
+
delete crypto.keys[crypto.current];
|
|
85
|
+
crypto.current = oldKey;
|
|
86
|
+
crypto.age = parseInt(oldKey, 36); // It should be reloaded
|
|
87
|
+
assert.strictEqual((await this.webda.getCrypto().decrypt(encrypted)).test, "plop");
|
|
88
|
+
// Remove again but remove it from the registry now
|
|
89
|
+
await this.webda.getRegistry().removeAttribute("keys", `key_${crypto.current}`);
|
|
90
|
+
delete crypto.keys[crypto.current];
|
|
91
|
+
crypto.current = oldKey;
|
|
92
|
+
crypto.age = parseInt(oldKey, 36);
|
|
93
|
+
await assert.rejects(() => this.webda.getCrypto().decrypt(encrypted), /err/);
|
|
117
94
|
}
|
|
118
|
-
jwt() {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
assert.strictEqual(yield crypto.jwtVerify(token), "plop");
|
|
128
|
-
});
|
|
95
|
+
async jwt() {
|
|
96
|
+
// Test asymetric JWT
|
|
97
|
+
const crypto = this.webda.getCrypto();
|
|
98
|
+
let token = await crypto.jwtSign("plop", { algorithm: "PS256" });
|
|
99
|
+
assert.strictEqual(await crypto.jwtVerify(token), "plop");
|
|
100
|
+
token = await crypto.jwtSign("plop");
|
|
101
|
+
assert.strictEqual(await crypto.jwtVerify(token), "plop");
|
|
102
|
+
token = await crypto.jwtSign("plop", { algorithm: "HS256" });
|
|
103
|
+
assert.strictEqual(await crypto.jwtVerify(token), "plop");
|
|
129
104
|
}
|
|
130
|
-
cov() {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
yield assert.rejects(() => this.webda.getCrypto().getCurrentKeys(), /not initialized/);
|
|
134
|
-
});
|
|
105
|
+
async cov() {
|
|
106
|
+
this.webda.getCrypto().keys = undefined;
|
|
107
|
+
await assert.rejects(() => this.webda.getCrypto().getCurrentKeys(), /not initialized/);
|
|
135
108
|
}
|
|
136
109
|
};
|
|
137
110
|
__decorate([
|
|
138
|
-
|
|
111
|
+
test
|
|
139
112
|
], CryptoServiceTest.prototype, "hmac", null);
|
|
140
113
|
__decorate([
|
|
141
|
-
|
|
114
|
+
test
|
|
142
115
|
], CryptoServiceTest.prototype, "encryption", null);
|
|
143
116
|
__decorate([
|
|
144
|
-
|
|
117
|
+
test
|
|
145
118
|
], CryptoServiceTest.prototype, "rotate", null);
|
|
146
119
|
__decorate([
|
|
147
|
-
|
|
120
|
+
test
|
|
148
121
|
], CryptoServiceTest.prototype, "failedRotation", null);
|
|
149
122
|
__decorate([
|
|
150
|
-
|
|
123
|
+
test
|
|
151
124
|
], CryptoServiceTest.prototype, "jwks", null);
|
|
152
125
|
__decorate([
|
|
153
|
-
|
|
126
|
+
test
|
|
154
127
|
], CryptoServiceTest.prototype, "unknownKeys", null);
|
|
155
128
|
__decorate([
|
|
156
|
-
|
|
129
|
+
test
|
|
157
130
|
], CryptoServiceTest.prototype, "jwt", null);
|
|
158
131
|
__decorate([
|
|
159
|
-
|
|
132
|
+
test
|
|
160
133
|
], CryptoServiceTest.prototype, "cov", null);
|
|
161
134
|
CryptoServiceTest = __decorate([
|
|
162
|
-
|
|
135
|
+
suite
|
|
163
136
|
], CryptoServiceTest);
|
|
164
137
|
//# sourceMappingURL=cryptoservice.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoservice.spec.js","sourceRoot":"","sources":["../../src/services/cryptoservice.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cryptoservice.spec.js","sourceRoot":"","sources":["../../src/services/cryptoservice.spec.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD;;GAEG;AAEH,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,SAAS;IAEvC,KAAK,CAAC,IAAI;QACR,IAAI,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;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AAI;4CAIJ;AAhHG,iBAAiB;IADtB,KAAK;GACA,iBAAiB,CAiHtB"}
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DebugMailer = void 0;
|
|
13
|
-
const mailer_1 = require("./mailer");
|
|
1
|
+
import { AbstractMailer } from "./mailer.js";
|
|
14
2
|
/**
|
|
15
3
|
* Fake Service to help debug mail expedition
|
|
16
4
|
* @WebdaModda
|
|
17
5
|
*/
|
|
18
|
-
class DebugMailer extends
|
|
6
|
+
export default class DebugMailer extends AbstractMailer {
|
|
19
7
|
constructor(webda, name, params) {
|
|
20
8
|
super(webda, name, params);
|
|
21
9
|
this.sent = [];
|
|
@@ -27,11 +15,9 @@ class DebugMailer extends mailer_1.AbstractMailer {
|
|
|
27
15
|
* @param options
|
|
28
16
|
* @param callback
|
|
29
17
|
*/
|
|
30
|
-
send(options, _callback = undefined) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.sent.push(options);
|
|
34
|
-
});
|
|
18
|
+
async send(options, _callback = undefined) {
|
|
19
|
+
this.log("DEBUG", "Send a fake email", options);
|
|
20
|
+
this.sent.push(options);
|
|
35
21
|
}
|
|
36
22
|
/**
|
|
37
23
|
* Just send a new Error exception
|
|
@@ -45,29 +31,22 @@ class DebugMailer extends mailer_1.AbstractMailer {
|
|
|
45
31
|
* @param name
|
|
46
32
|
* @returns
|
|
47
33
|
*/
|
|
48
|
-
hasNotification(_name) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return true;
|
|
52
|
-
});
|
|
34
|
+
async hasNotification(_name) {
|
|
35
|
+
// Load template
|
|
36
|
+
return true;
|
|
53
37
|
}
|
|
54
38
|
/**
|
|
55
39
|
* Just send a new Error exception as async
|
|
56
40
|
*/
|
|
57
|
-
errorAsync() {
|
|
58
|
-
|
|
59
|
-
throw new Error("FakeError");
|
|
60
|
-
});
|
|
41
|
+
async errorAsync() {
|
|
42
|
+
throw new Error("FakeError");
|
|
61
43
|
}
|
|
62
44
|
/**
|
|
63
45
|
* Empty async method
|
|
64
46
|
*/
|
|
65
|
-
async() {
|
|
66
|
-
|
|
67
|
-
// Empty on purpose
|
|
68
|
-
});
|
|
47
|
+
async async() {
|
|
48
|
+
// Empty on purpose
|
|
69
49
|
}
|
|
70
50
|
}
|
|
71
|
-
|
|
72
|
-
exports.DebugMailer = DebugMailer;
|
|
51
|
+
export { DebugMailer };
|
|
73
52
|
//# sourceMappingURL=debugmailer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugmailer.js","sourceRoot":"","sources":["../../src/services/debugmailer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debugmailer.js","sourceRoot":"","sources":["../../src/services/debugmailer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,cAAc;IAGrD,YAAY,KAAK,EAAE,IAAI,EAAE,MAAM;QAC7B,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAH7B,SAAI,GAAU,EAAE,CAAC;QAIf,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS;QACvC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CAAC,KAAa;QACjC,gBAAgB;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,mBAAmB;IACrB,CAAC;CACF;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,42 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
let DebugMailerTest = class DebugMailerTest extends test_1.WebdaTest {
|
|
23
|
-
testSend() {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
let mailer = new debugmailer_1.DebugMailer(this.webda, "test", {});
|
|
26
|
-
mailer.send({ option1: "test" });
|
|
27
|
-
assert.strictEqual(mailer.sent.length, 1);
|
|
28
|
-
assert.strictEqual(mailer.sent[0].option1, "test");
|
|
29
|
-
yield mailer.async();
|
|
30
|
-
assert.throws(() => mailer.error(), /FakeError/);
|
|
31
|
-
yield assert.rejects(() => mailer.errorAsync(), /FakeError/);
|
|
32
|
-
assert.strictEqual(yield mailer.hasNotification(""), true);
|
|
33
|
-
});
|
|
7
|
+
import { suite, test } from "@testdeck/mocha";
|
|
8
|
+
import * as assert from "assert";
|
|
9
|
+
import { WebdaTest } from "../test.js";
|
|
10
|
+
import { DebugMailer } from "./debugmailer.js";
|
|
11
|
+
let DebugMailerTest = class DebugMailerTest extends WebdaTest {
|
|
12
|
+
async testSend() {
|
|
13
|
+
let mailer = new DebugMailer(this.webda, "test", {});
|
|
14
|
+
mailer.send({ option1: "test" });
|
|
15
|
+
assert.strictEqual(mailer.sent.length, 1);
|
|
16
|
+
assert.strictEqual(mailer.sent[0].option1, "test");
|
|
17
|
+
await mailer.async();
|
|
18
|
+
assert.throws(() => mailer.error(), /FakeError/);
|
|
19
|
+
await assert.rejects(() => mailer.errorAsync(), /FakeError/);
|
|
20
|
+
assert.strictEqual(await mailer.hasNotification(""), true);
|
|
34
21
|
}
|
|
35
22
|
};
|
|
36
23
|
__decorate([
|
|
37
|
-
|
|
24
|
+
test
|
|
38
25
|
], DebugMailerTest.prototype, "testSend", null);
|
|
39
26
|
DebugMailerTest = __decorate([
|
|
40
|
-
|
|
27
|
+
suite
|
|
41
28
|
], DebugMailerTest);
|
|
42
29
|
//# sourceMappingURL=debugmailer.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugmailer.spec.js","sourceRoot":"","sources":["../../src/services/debugmailer.spec.ts"],"names":[],"mapp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import { Context } from "../index";
|
|
2
|
-
import { Service, ServiceParameters } from "./service";
|
|
1
|
+
import { Context } from "../index.js";
|
|
2
|
+
import { Service, ServiceParameters } from "./service.js";
|
|
3
3
|
export declare class EchoServiceParameters extends ServiceParameters {
|
|
4
4
|
/**
|
|
5
5
|
* Mime of the result
|
package/lib/services/echo.js
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EchoService = exports.EchoServiceParameters = void 0;
|
|
13
|
-
const service_1 = require("./service");
|
|
14
|
-
class EchoServiceParameters extends service_1.ServiceParameters {
|
|
1
|
+
import { Service, ServiceParameters } from "./service.js";
|
|
2
|
+
export class EchoServiceParameters extends ServiceParameters {
|
|
15
3
|
}
|
|
16
|
-
exports.EchoServiceParameters = EchoServiceParameters;
|
|
17
4
|
/**
|
|
18
5
|
* Return a static string with a static route
|
|
19
6
|
*
|
|
@@ -30,7 +17,7 @@ exports.EchoServiceParameters = EchoServiceParameters;
|
|
|
30
17
|
* ```
|
|
31
18
|
* @WebdaModda
|
|
32
19
|
*/
|
|
33
|
-
class EchoService extends
|
|
20
|
+
export class EchoService extends Service {
|
|
34
21
|
/**
|
|
35
22
|
* Load parameters
|
|
36
23
|
*
|
|
@@ -45,21 +32,18 @@ class EchoService extends service_1.Service {
|
|
|
45
32
|
this.addRoute(this.parameters.url, ["GET"], this.execute);
|
|
46
33
|
}
|
|
47
34
|
/** @ignore */
|
|
48
|
-
execute(ctx) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
});
|
|
35
|
+
async execute(ctx) {
|
|
36
|
+
if (this.parameters.mime) {
|
|
37
|
+
ctx.writeHead(200, {
|
|
38
|
+
"Content-Type": this.parameters.mime
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (typeof this.parameters.result != "string") {
|
|
42
|
+
ctx.write(JSON.stringify(this.parameters.result));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
ctx.write(this.parameters.result);
|
|
46
|
+
}
|
|
62
47
|
}
|
|
63
48
|
}
|
|
64
|
-
exports.EchoService = EchoService;
|
|
65
49
|
//# sourceMappingURL=echo.js.map
|
package/lib/services/echo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"echo.js","sourceRoot":"","sources":["../../src/services/echo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"echo.js","sourceRoot":"","sources":["../../src/services/echo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;CAa3D;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,WAAY,SAAQ,OAA8B;IAC7D;;;;;OAKG;IACH,cAAc,CAAC,MAAW;QACxB,OAAO,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,cAAc;IACd,UAAU;QACR,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED,cAAc;IACd,KAAK,CAAC,OAAO,CAAC,GAAY;QACxB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;YACxB,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE;gBACjB,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI;aACrC,CAAC,CAAC;SACJ;QACD,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,QAAQ,EAAE;YAC7C,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;SACnD;aAAM;YACL,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;SACnC;IACH,CAAC;CACF"}
|
|
@@ -1,53 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
finally {
|
|
34
|
-
stub.restore();
|
|
35
|
-
}
|
|
36
|
-
let ctx = yield this.newContext();
|
|
37
|
-
yield service.execute(ctx);
|
|
38
|
-
assert.strictEqual(ctx.getResponseBody(), "plop");
|
|
39
|
-
service = new echo_1.EchoService(this.webda, "test", { url: "/bouzouf", mime: "mine/json", result: { obj: "plop" } });
|
|
40
|
-
ctx = yield this.newContext();
|
|
41
|
-
yield service.execute(ctx);
|
|
42
|
-
assert.strictEqual(ctx.getResponseHeaders()["Content-Type"], "mine/json");
|
|
43
|
-
assert.strictEqual(ctx.getResponseBody(), '{"obj":"plop"}');
|
|
44
|
-
});
|
|
7
|
+
import { suite, test } from "@testdeck/mocha";
|
|
8
|
+
import * as assert from "assert";
|
|
9
|
+
import * as sinon from "sinon";
|
|
10
|
+
import { WebdaTest } from "../test.js";
|
|
11
|
+
import { EchoService } from "./echo.js";
|
|
12
|
+
let EchoTest = class EchoTest extends WebdaTest {
|
|
13
|
+
async cov() {
|
|
14
|
+
let service = new EchoService(this.webda, "test", { url: "/bouzouf", result: "plop" });
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
let stub = sinon.spy(service, "addRoute");
|
|
17
|
+
try {
|
|
18
|
+
service.initRoutes();
|
|
19
|
+
assert.strictEqual(stub.callCount, 1);
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
stub.restore();
|
|
23
|
+
}
|
|
24
|
+
let ctx = await this.newContext();
|
|
25
|
+
await service.execute(ctx);
|
|
26
|
+
assert.strictEqual(ctx.getResponseBody(), "plop");
|
|
27
|
+
service = new EchoService(this.webda, "test", { url: "/bouzouf", mime: "mine/json", result: { obj: "plop" } });
|
|
28
|
+
ctx = await this.newContext();
|
|
29
|
+
await service.execute(ctx);
|
|
30
|
+
assert.strictEqual(ctx.getResponseHeaders()["Content-Type"], "mine/json");
|
|
31
|
+
assert.strictEqual(ctx.getResponseBody(), '{"obj":"plop"}');
|
|
45
32
|
}
|
|
46
33
|
};
|
|
47
34
|
__decorate([
|
|
48
|
-
|
|
35
|
+
test
|
|
49
36
|
], EchoTest.prototype, "cov", null);
|
|
50
37
|
EchoTest = __decorate([
|
|
51
|
-
|
|
38
|
+
suite
|
|
52
39
|
], EchoTest);
|
|
53
40
|
//# sourceMappingURL=echo.spec.js.map
|