@budibase/backend-core 2.22.2 → 2.22.4
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/dist/index.js +67 -70
- package/dist/index.js.map +3 -3
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/cache/docWritethrough.d.ts +4 -8
- package/dist/src/cache/docWritethrough.js +14 -8
- package/dist/src/cache/docWritethrough.js.map +1 -1
- package/dist/src/db/lucene.js +1 -1
- package/dist/src/db/lucene.js.map +1 -1
- package/dist/src/logging/pino/logger.js +11 -11
- package/dist/src/logging/pino/logger.js.map +1 -1
- package/dist/src/middleware/matchers.js +3 -10
- package/dist/src/middleware/matchers.js.map +1 -1
- package/dist/tests/core/utilities/structures/userGroups.js +1 -1
- package/package.json +4 -4
- package/src/auth/tests/auth.spec.ts +1 -1
- package/src/cache/docWritethrough.ts +19 -11
- package/src/cache/tests/docWritethrough.spec.ts +7 -6
- package/src/cache/tests/user.spec.ts +5 -5
- package/src/context/tests/index.spec.ts +1 -1
- package/src/db/lucene.ts +1 -1
- package/src/logging/pino/logger.ts +13 -13
- package/src/middleware/matchers.ts +3 -11
- package/src/middleware/passport/sso/tests/sso.spec.ts +6 -6
- package/src/middleware/tests/builder.spec.ts +3 -3
- package/src/middleware/tests/matchers.spec.ts +0 -34
- package/src/redis/tests/redis.spec.ts +1 -12
- package/src/redis/tests/redlockImpl.spec.ts +2 -2
- package/src/tenancy/tests/tenancy.spec.ts +2 -2
- package/tests/core/utilities/structures/userGroups.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../src/logging/pino/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0C;AAC1C,8DAAoC;AAGpC,oEAAmC;AACnC,uDAAwC;AACxC,4DAA6C;AAC7C,wDAA6B;AAC7B,sCA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KAAK,CAAA;IACd,CAAC,CAAA;IAED,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,IAAI,QAAQ,CAAA;QACZ,IAAI;YACF,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAA;SACjC;QAAC,OAAO,CAAC,EAAE;YACV,aAAa;SACd;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAA;CACF;AAEY,QAAA,MAAM,GAAG,YAAY,CAAA"}
|
|
@@ -9,7 +9,6 @@ const buildMatcherRegex = (patterns) => {
|
|
|
9
9
|
return patterns.map(pattern => {
|
|
10
10
|
let route = pattern.route;
|
|
11
11
|
const method = pattern.method;
|
|
12
|
-
const strict = pattern.strict ? pattern.strict : false;
|
|
13
12
|
// if there is a param in the route
|
|
14
13
|
// use a wildcard pattern
|
|
15
14
|
const matches = route.match(PARAM_REGEX);
|
|
@@ -20,19 +19,13 @@ const buildMatcherRegex = (patterns) => {
|
|
|
20
19
|
route = route.replace(match, pattern);
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
|
-
return { regex: new RegExp(route), method,
|
|
22
|
+
return { regex: new RegExp(route), method, route };
|
|
24
23
|
});
|
|
25
24
|
};
|
|
26
25
|
exports.buildMatcherRegex = buildMatcherRegex;
|
|
27
26
|
const matches = (ctx, options) => {
|
|
28
|
-
return options.find(({ regex, method,
|
|
29
|
-
|
|
30
|
-
if (strict) {
|
|
31
|
-
urlMatch = ctx.request.url === route;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
urlMatch = regex.test(ctx.request.url);
|
|
35
|
-
}
|
|
27
|
+
return options.find(({ regex, method, route }) => {
|
|
28
|
+
const urlMatch = regex.test(ctx.request.url);
|
|
36
29
|
const methodMatch = method === "ALL"
|
|
37
30
|
? true
|
|
38
31
|
: ctx.request.method.toLowerCase() === method.toLowerCase();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchers.js","sourceRoot":"","sources":["../../../src/middleware/matchers.ts"],"names":[],"mapp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,CAAC,CAAA;AAvBY,QAAA,iBAAiB,qBAuB7B;AAEM,MAAM,OAAO,GAAG,CAAC,GAAc,EAAE,OAAuB,EAAE,EAAE;IACjE,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;QAC/C,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC5C,MAAM,WAAW,GACf,MAAM,KAAK,KAAK;YACd,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,WAAW,EAAE,CAAA;QAC/D,OAAO,QAAQ,IAAI,WAAW,CAAA;IAChC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AATY,QAAA,OAAO,WASnB"}
|
|
@@ -4,7 +4,7 @@ exports.userGroup = void 0;
|
|
|
4
4
|
const generator_1 = require("./generator");
|
|
5
5
|
function userGroup() {
|
|
6
6
|
return {
|
|
7
|
-
name: generator_1.generator.
|
|
7
|
+
name: generator_1.generator.guid(),
|
|
8
8
|
icon: generator_1.generator.word(),
|
|
9
9
|
color: generator_1.generator.word(),
|
|
10
10
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/backend-core",
|
|
3
|
-
"version": "2.22.
|
|
3
|
+
"version": "2.22.4",
|
|
4
4
|
"description": "Budibase backend core libraries used in server and worker",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@budibase/nano": "10.1.5",
|
|
25
25
|
"@budibase/pouchdb-replication-stream": "1.2.10",
|
|
26
|
-
"@budibase/shared-core": "2.22.
|
|
27
|
-
"@budibase/types": "2.22.
|
|
26
|
+
"@budibase/shared-core": "2.22.4",
|
|
27
|
+
"@budibase/types": "2.22.4",
|
|
28
28
|
"@govtechsg/passport-openidconnect": "^1.0.2",
|
|
29
29
|
"aws-cloudfront-sign": "3.0.2",
|
|
30
30
|
"aws-sdk": "2.1030.0",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "be7e99f7fdb36262e4a90563edad1ed53ec4e55e"
|
|
101
101
|
}
|
|
@@ -8,7 +8,7 @@ describe("platformLogout", () => {
|
|
|
8
8
|
await testEnv.withTenant(async () => {
|
|
9
9
|
const ctx = structures.koa.newContext()
|
|
10
10
|
await auth.platformLogout({ ctx, userId: "test" })
|
|
11
|
-
expect(events.auth.logout).
|
|
11
|
+
expect(events.auth.logout).toHaveBeenCalledTimes(1)
|
|
12
12
|
})
|
|
13
13
|
})
|
|
14
14
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyDocument, Database } from "@budibase/types"
|
|
2
2
|
|
|
3
|
-
import { JobQueue, createQueue } from "../queue"
|
|
3
|
+
import { JobQueue, Queue, createQueue } from "../queue"
|
|
4
4
|
import * as dbUtils from "../db"
|
|
5
5
|
|
|
6
6
|
interface ProcessDocMessage {
|
|
@@ -12,18 +12,26 @@ interface ProcessDocMessage {
|
|
|
12
12
|
const PERSIST_MAX_ATTEMPTS = 100
|
|
13
13
|
let processor: DocWritethroughProcessor | undefined
|
|
14
14
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export class DocWritethroughProcessor {
|
|
16
|
+
private static _queue: Queue
|
|
17
|
+
|
|
18
|
+
public static get queue() {
|
|
19
|
+
if (!DocWritethroughProcessor._queue) {
|
|
20
|
+
DocWritethroughProcessor._queue = createQueue<ProcessDocMessage>(
|
|
21
|
+
JobQueue.DOC_WRITETHROUGH_QUEUE,
|
|
22
|
+
{
|
|
23
|
+
jobOptions: {
|
|
24
|
+
attempts: PERSIST_MAX_ATTEMPTS,
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return DocWritethroughProcessor._queue
|
|
21
31
|
}
|
|
22
|
-
)
|
|
23
32
|
|
|
24
|
-
class DocWritethroughProcessor {
|
|
25
33
|
init() {
|
|
26
|
-
|
|
34
|
+
DocWritethroughProcessor.queue.process(async message => {
|
|
27
35
|
try {
|
|
28
36
|
await this.persistToDb(message.data)
|
|
29
37
|
} catch (err: any) {
|
|
@@ -76,7 +84,7 @@ export class DocWritethrough {
|
|
|
76
84
|
}
|
|
77
85
|
|
|
78
86
|
async patch(data: Record<string, any>) {
|
|
79
|
-
await
|
|
87
|
+
await DocWritethroughProcessor.queue.add({
|
|
80
88
|
dbName: this.db.name,
|
|
81
89
|
docId: this.docId,
|
|
82
90
|
data,
|
|
@@ -6,7 +6,7 @@ import { getDB } from "../../db"
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
DocWritethrough,
|
|
9
|
-
|
|
9
|
+
DocWritethroughProcessor,
|
|
10
10
|
init,
|
|
11
11
|
} from "../docWritethrough"
|
|
12
12
|
|
|
@@ -15,7 +15,7 @@ import InMemoryQueue from "../../queue/inMemoryQueue"
|
|
|
15
15
|
const initialTime = Date.now()
|
|
16
16
|
|
|
17
17
|
async function waitForQueueCompletion() {
|
|
18
|
-
const queue: InMemoryQueue =
|
|
18
|
+
const queue: InMemoryQueue = DocWritethroughProcessor.queue as never
|
|
19
19
|
await queue.waitForCompletion()
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -235,11 +235,11 @@ describe("docWritethrough", () => {
|
|
|
235
235
|
return acc
|
|
236
236
|
}, {})
|
|
237
237
|
}
|
|
238
|
-
const queueMessageSpy = jest.spyOn(
|
|
238
|
+
const queueMessageSpy = jest.spyOn(DocWritethroughProcessor.queue, "add")
|
|
239
239
|
|
|
240
240
|
await config.doInTenant(async () => {
|
|
241
241
|
let patches = await parallelPatch(5)
|
|
242
|
-
expect(queueMessageSpy).
|
|
242
|
+
expect(queueMessageSpy).toHaveBeenCalledTimes(5)
|
|
243
243
|
|
|
244
244
|
await waitForQueueCompletion()
|
|
245
245
|
expect(await db.get(documentId)).toEqual(
|
|
@@ -247,7 +247,7 @@ describe("docWritethrough", () => {
|
|
|
247
247
|
)
|
|
248
248
|
|
|
249
249
|
patches = { ...patches, ...(await parallelPatch(40)) }
|
|
250
|
-
expect(queueMessageSpy).
|
|
250
|
+
expect(queueMessageSpy).toHaveBeenCalledTimes(45)
|
|
251
251
|
|
|
252
252
|
await waitForQueueCompletion()
|
|
253
253
|
expect(await db.get(documentId)).toEqual(
|
|
@@ -255,7 +255,7 @@ describe("docWritethrough", () => {
|
|
|
255
255
|
)
|
|
256
256
|
|
|
257
257
|
patches = { ...patches, ...(await parallelPatch(10)) }
|
|
258
|
-
expect(queueMessageSpy).
|
|
258
|
+
expect(queueMessageSpy).toHaveBeenCalledTimes(55)
|
|
259
259
|
|
|
260
260
|
await waitForQueueCompletion()
|
|
261
261
|
expect(await db.get(documentId)).toEqual(
|
|
@@ -265,6 +265,7 @@ describe("docWritethrough", () => {
|
|
|
265
265
|
})
|
|
266
266
|
|
|
267
267
|
// This is not yet supported
|
|
268
|
+
// eslint-disable-next-line jest/no-disabled-tests
|
|
268
269
|
it.skip("patches will execute in order", async () => {
|
|
269
270
|
let incrementalValue = 0
|
|
270
271
|
const keyToOverride = generator.word()
|
|
@@ -55,8 +55,8 @@ describe("user cache", () => {
|
|
|
55
55
|
})),
|
|
56
56
|
})
|
|
57
57
|
|
|
58
|
-
expect(UserDB.bulkGet).
|
|
59
|
-
expect(UserDB.bulkGet).
|
|
58
|
+
expect(UserDB.bulkGet).toHaveBeenCalledTimes(1)
|
|
59
|
+
expect(UserDB.bulkGet).toHaveBeenCalledWith(userIdsToRequest)
|
|
60
60
|
})
|
|
61
61
|
|
|
62
62
|
it("on a second all, all of them are retrieved from cache", async () => {
|
|
@@ -82,7 +82,7 @@ describe("user cache", () => {
|
|
|
82
82
|
),
|
|
83
83
|
})
|
|
84
84
|
|
|
85
|
-
expect(UserDB.bulkGet).
|
|
85
|
+
expect(UserDB.bulkGet).toHaveBeenCalledTimes(1)
|
|
86
86
|
})
|
|
87
87
|
|
|
88
88
|
it("when some users are cached, only the missing ones are retrieved from db", async () => {
|
|
@@ -110,8 +110,8 @@ describe("user cache", () => {
|
|
|
110
110
|
),
|
|
111
111
|
})
|
|
112
112
|
|
|
113
|
-
expect(UserDB.bulkGet).
|
|
114
|
-
expect(UserDB.bulkGet).
|
|
113
|
+
expect(UserDB.bulkGet).toHaveBeenCalledTimes(1)
|
|
114
|
+
expect(UserDB.bulkGet).toHaveBeenCalledWith([
|
|
115
115
|
userIdsToRequest[1],
|
|
116
116
|
userIdsToRequest[2],
|
|
117
117
|
userIdsToRequest[4],
|
|
@@ -246,7 +246,7 @@ describe("context", () => {
|
|
|
246
246
|
context.doInAppMigrationContext(db.generateAppID(), async () => {
|
|
247
247
|
await otherContextCall()
|
|
248
248
|
})
|
|
249
|
-
).rejects.
|
|
249
|
+
).rejects.toThrow(
|
|
250
250
|
"The context cannot be changed, a migration is currently running"
|
|
251
251
|
)
|
|
252
252
|
}
|
package/src/db/lucene.ts
CHANGED
|
@@ -247,7 +247,7 @@ export class QueryBuilder<T> {
|
|
|
247
247
|
}
|
|
248
248
|
// Escape characters
|
|
249
249
|
if (!this.#noEscaping && escape && originalType === "string") {
|
|
250
|
-
value = `${value}`.replace(/[
|
|
250
|
+
value = `${value}`.replace(/[ /#+\-&|!(){}\]^"~*?:\\]/g, "\\$&")
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
// Wrap in quotes
|
|
@@ -10,6 +10,18 @@ import { formats } from "dd-trace/ext"
|
|
|
10
10
|
|
|
11
11
|
import { localFileDestination } from "../system"
|
|
12
12
|
|
|
13
|
+
function isPlainObject(obj: any) {
|
|
14
|
+
return typeof obj === "object" && obj !== null && !(obj instanceof Error)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function isError(obj: any) {
|
|
18
|
+
return obj instanceof Error
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function isMessage(obj: any) {
|
|
22
|
+
return typeof obj === "string"
|
|
23
|
+
}
|
|
24
|
+
|
|
13
25
|
// LOGGER
|
|
14
26
|
|
|
15
27
|
let pinoInstance: pino.Logger | undefined
|
|
@@ -71,23 +83,11 @@ if (!env.DISABLE_PINO_LOGGER) {
|
|
|
71
83
|
err?: Error
|
|
72
84
|
}
|
|
73
85
|
|
|
74
|
-
function isPlainObject(obj: any) {
|
|
75
|
-
return typeof obj === "object" && obj !== null && !(obj instanceof Error)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function isError(obj: any) {
|
|
79
|
-
return obj instanceof Error
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function isMessage(obj: any) {
|
|
83
|
-
return typeof obj === "string"
|
|
84
|
-
}
|
|
85
|
-
|
|
86
86
|
/**
|
|
87
87
|
* Backwards compatibility between console logging statements
|
|
88
88
|
* and pino logging requirements.
|
|
89
89
|
*/
|
|
90
|
-
|
|
90
|
+
const getLogParams = (args: any[]): [MergingObject, string] => {
|
|
91
91
|
let error = undefined
|
|
92
92
|
let objects: any[] = []
|
|
93
93
|
let message = ""
|
|
@@ -11,7 +11,6 @@ export const buildMatcherRegex = (
|
|
|
11
11
|
return patterns.map(pattern => {
|
|
12
12
|
let route = pattern.route
|
|
13
13
|
const method = pattern.method
|
|
14
|
-
const strict = pattern.strict ? pattern.strict : false
|
|
15
14
|
|
|
16
15
|
// if there is a param in the route
|
|
17
16
|
// use a wildcard pattern
|
|
@@ -24,24 +23,17 @@ export const buildMatcherRegex = (
|
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
return { regex: new RegExp(route), method,
|
|
26
|
+
return { regex: new RegExp(route), method, route }
|
|
28
27
|
})
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
export const matches = (ctx: BBContext, options: RegexMatcher[]) => {
|
|
32
|
-
return options.find(({ regex, method,
|
|
33
|
-
|
|
34
|
-
if (strict) {
|
|
35
|
-
urlMatch = ctx.request.url === route
|
|
36
|
-
} else {
|
|
37
|
-
urlMatch = regex.test(ctx.request.url)
|
|
38
|
-
}
|
|
39
|
-
|
|
31
|
+
return options.find(({ regex, method, route }) => {
|
|
32
|
+
const urlMatch = regex.test(ctx.request.url)
|
|
40
33
|
const methodMatch =
|
|
41
34
|
method === "ALL"
|
|
42
35
|
? true
|
|
43
36
|
: ctx.request.method.toLowerCase() === method.toLowerCase()
|
|
44
|
-
|
|
45
37
|
return urlMatch && methodMatch
|
|
46
38
|
})
|
|
47
39
|
}
|
|
@@ -114,11 +114,11 @@ describe("sso", () => {
|
|
|
114
114
|
// tenant id added
|
|
115
115
|
ssoUser.tenantId = context.getTenantId()
|
|
116
116
|
|
|
117
|
-
expect(mockSaveUser).
|
|
117
|
+
expect(mockSaveUser).toHaveBeenCalledWith(ssoUser, {
|
|
118
118
|
hashPassword: false,
|
|
119
119
|
requirePassword: false,
|
|
120
120
|
})
|
|
121
|
-
expect(mockDone).
|
|
121
|
+
expect(mockDone).toHaveBeenCalledWith(null, ssoUser)
|
|
122
122
|
})
|
|
123
123
|
})
|
|
124
124
|
})
|
|
@@ -159,11 +159,11 @@ describe("sso", () => {
|
|
|
159
159
|
// existing id preserved
|
|
160
160
|
ssoUser._id = existingUser._id
|
|
161
161
|
|
|
162
|
-
expect(mockSaveUser).
|
|
162
|
+
expect(mockSaveUser).toHaveBeenCalledWith(ssoUser, {
|
|
163
163
|
hashPassword: false,
|
|
164
164
|
requirePassword: false,
|
|
165
165
|
})
|
|
166
|
-
expect(mockDone).
|
|
166
|
+
expect(mockDone).toHaveBeenCalledWith(null, ssoUser)
|
|
167
167
|
})
|
|
168
168
|
})
|
|
169
169
|
|
|
@@ -187,11 +187,11 @@ describe("sso", () => {
|
|
|
187
187
|
// existing id preserved
|
|
188
188
|
ssoUser._id = existingUser._id
|
|
189
189
|
|
|
190
|
-
expect(mockSaveUser).
|
|
190
|
+
expect(mockSaveUser).toHaveBeenCalledWith(ssoUser, {
|
|
191
191
|
hashPassword: false,
|
|
192
192
|
requirePassword: false,
|
|
193
193
|
})
|
|
194
|
-
expect(mockDone).
|
|
194
|
+
expect(mockDone).toHaveBeenCalledWith(null, ssoUser)
|
|
195
195
|
})
|
|
196
196
|
})
|
|
197
197
|
})
|
|
@@ -24,13 +24,13 @@ function buildUserCtx(user: ContextUser) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function passed(throwFn: jest.Func, nextFn: jest.Func) {
|
|
27
|
-
expect(throwFn).not.
|
|
28
|
-
expect(nextFn).
|
|
27
|
+
expect(throwFn).not.toHaveBeenCalled()
|
|
28
|
+
expect(nextFn).toHaveBeenCalled()
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function threw(throwFn: jest.Func) {
|
|
32
32
|
// cant check next, the throw function doesn't actually throw - so it still continues
|
|
33
|
-
expect(throwFn).
|
|
33
|
+
expect(throwFn).toHaveBeenCalled()
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
describe("adminOnly middleware", () => {
|
|
@@ -34,23 +34,6 @@ describe("matchers", () => {
|
|
|
34
34
|
expect(!!matchers.matches(ctx, built)).toBe(true)
|
|
35
35
|
})
|
|
36
36
|
|
|
37
|
-
it("doesn't wildcard path with strict", () => {
|
|
38
|
-
const pattern = [
|
|
39
|
-
{
|
|
40
|
-
route: "/api/tests",
|
|
41
|
-
method: "POST",
|
|
42
|
-
strict: true,
|
|
43
|
-
},
|
|
44
|
-
]
|
|
45
|
-
const ctx = structures.koa.newContext()
|
|
46
|
-
ctx.request.url = "/api/tests/id/something/else"
|
|
47
|
-
ctx.request.method = "POST"
|
|
48
|
-
|
|
49
|
-
const built = matchers.buildMatcherRegex(pattern)
|
|
50
|
-
|
|
51
|
-
expect(!!matchers.matches(ctx, built)).toBe(false)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
37
|
it("matches with param", () => {
|
|
55
38
|
const pattern = [
|
|
56
39
|
{
|
|
@@ -67,23 +50,6 @@ describe("matchers", () => {
|
|
|
67
50
|
expect(!!matchers.matches(ctx, built)).toBe(true)
|
|
68
51
|
})
|
|
69
52
|
|
|
70
|
-
// TODO: Support the below behaviour
|
|
71
|
-
// Strict does not work when a param is present
|
|
72
|
-
// it("matches with param with strict", () => {
|
|
73
|
-
// const pattern = [{
|
|
74
|
-
// route: "/api/tests/:testId",
|
|
75
|
-
// method: "GET",
|
|
76
|
-
// strict: true
|
|
77
|
-
// }]
|
|
78
|
-
// const ctx = structures.koa.newContext()
|
|
79
|
-
// ctx.request.url = "/api/tests/id"
|
|
80
|
-
// ctx.request.method = "GET"
|
|
81
|
-
//
|
|
82
|
-
// const built = matchers.buildMatcherRegex(pattern)
|
|
83
|
-
//
|
|
84
|
-
// expect(!!matchers.matches(ctx, built)).toBe(true)
|
|
85
|
-
// })
|
|
86
|
-
|
|
87
53
|
it("doesn't match by path", () => {
|
|
88
54
|
const pattern = [
|
|
89
55
|
{
|
|
@@ -147,17 +147,6 @@ describe("redis", () => {
|
|
|
147
147
|
expect(results).toEqual([1, 2, 3, 4, 5])
|
|
148
148
|
})
|
|
149
149
|
|
|
150
|
-
it("can increment on a new key", async () => {
|
|
151
|
-
const key1 = structures.uuid()
|
|
152
|
-
const key2 = structures.uuid()
|
|
153
|
-
|
|
154
|
-
const result1 = await redis.increment(key1)
|
|
155
|
-
expect(result1).toBe(1)
|
|
156
|
-
|
|
157
|
-
const result2 = await redis.increment(key2)
|
|
158
|
-
expect(result2).toBe(1)
|
|
159
|
-
})
|
|
160
|
-
|
|
161
150
|
it("can increment multiple times in parallel", async () => {
|
|
162
151
|
const key = structures.uuid()
|
|
163
152
|
const results = await Promise.all(
|
|
@@ -184,7 +173,7 @@ describe("redis", () => {
|
|
|
184
173
|
const key = structures.uuid()
|
|
185
174
|
await redis.store(key, value)
|
|
186
175
|
|
|
187
|
-
await expect(redis.increment(key)).rejects.
|
|
176
|
+
await expect(redis.increment(key)).rejects.toThrow(
|
|
188
177
|
"ERR value is not an integer or out of range"
|
|
189
178
|
)
|
|
190
179
|
})
|
|
@@ -96,8 +96,8 @@ describe("redlockImpl", () => {
|
|
|
96
96
|
task: mockTask,
|
|
97
97
|
executionTimeMs: lockTtl * 2,
|
|
98
98
|
})
|
|
99
|
-
).rejects.
|
|
100
|
-
`Unable to fully release the lock on resource
|
|
99
|
+
).rejects.toThrow(
|
|
100
|
+
`Unable to fully release the lock on resource "lock:${config.tenantId}_persist_writethrough".`
|
|
101
101
|
)
|
|
102
102
|
}
|
|
103
103
|
)
|
|
@@ -158,8 +158,8 @@ describe("getTenantIDFromCtx", () => {
|
|
|
158
158
|
],
|
|
159
159
|
}
|
|
160
160
|
expect(getTenantIDFromCtx(ctx, mockOpts)).toBeUndefined()
|
|
161
|
-
expect(ctx.throw).
|
|
162
|
-
expect(ctx.throw).
|
|
161
|
+
expect(ctx.throw).toHaveBeenCalledTimes(1)
|
|
162
|
+
expect(ctx.throw).toHaveBeenCalledWith(403, "Tenant id not set")
|
|
163
163
|
})
|
|
164
164
|
|
|
165
165
|
it("returns undefined if allowNoTenant is true", () => {
|