@contember/engine-http 2.2.0-alpha.17 → 2.2.0-alpha.19

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.
Files changed (221) hide show
  1. package/dist/development/index.cjs +3 -1
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +4 -2
  4. package/dist/development/index.js.map +1 -1
  5. package/dist/development/src/MasterContainer.cjs +5 -4
  6. package/dist/development/src/MasterContainer.cjs.map +1 -1
  7. package/dist/development/src/MasterContainer.js +5 -4
  8. package/dist/development/src/MasterContainer.js.map +1 -1
  9. package/dist/development/src/application/PanelApiMount.cjs.map +1 -1
  10. package/dist/development/src/application/PanelApiMount.js.map +1 -1
  11. package/dist/development/src/application/application.cjs +27 -21
  12. package/dist/development/src/application/application.cjs.map +1 -1
  13. package/dist/development/src/application/application.js +27 -21
  14. package/dist/development/src/application/application.js.map +1 -1
  15. package/dist/development/src/application/compression.cjs +99 -0
  16. package/dist/development/src/application/compression.cjs.map +1 -0
  17. package/dist/development/src/application/compression.js +82 -0
  18. package/dist/development/src/application/compression.js.map +1 -0
  19. package/dist/development/src/application/cors.cjs +52 -0
  20. package/dist/development/src/application/cors.cjs.map +1 -0
  21. package/dist/development/src/application/cors.js +52 -0
  22. package/dist/development/src/application/cors.js.map +1 -0
  23. package/dist/development/src/application/requestBody.cjs +242 -0
  24. package/dist/development/src/application/requestBody.cjs.map +1 -0
  25. package/dist/development/src/application/requestBody.js +242 -0
  26. package/dist/development/src/application/requestBody.js.map +1 -0
  27. package/dist/development/src/application/requestBodyMasking.cjs +97 -0
  28. package/dist/development/src/application/requestBodyMasking.cjs.map +1 -0
  29. package/dist/development/src/application/requestBodyMasking.js +97 -0
  30. package/dist/development/src/application/requestBodyMasking.js.map +1 -0
  31. package/dist/development/src/config/configSchema.cjs +36 -1
  32. package/dist/development/src/config/configSchema.cjs.map +1 -1
  33. package/dist/development/src/config/configSchema.js +36 -1
  34. package/dist/development/src/config/configSchema.js.map +1 -1
  35. package/dist/development/src/config/configTemplate.cjs +5 -0
  36. package/dist/development/src/config/configTemplate.cjs.map +1 -1
  37. package/dist/development/src/config/configTemplate.js +5 -0
  38. package/dist/development/src/config/configTemplate.js.map +1 -1
  39. package/dist/development/src/content/ProjectMembershipResolver.cjs +10 -3
  40. package/dist/development/src/content/ProjectMembershipResolver.cjs.map +1 -1
  41. package/dist/development/src/content/ProjectMembershipResolver.js +10 -3
  42. package/dist/development/src/content/ProjectMembershipResolver.js.map +1 -1
  43. package/dist/development/src/graphql/execution.cjs +3 -9
  44. package/dist/development/src/graphql/execution.cjs.map +1 -1
  45. package/dist/development/src/graphql/execution.js +3 -9
  46. package/dist/development/src/graphql/execution.js.map +1 -1
  47. package/dist/development/src/project/ProjectContainer.cjs +1 -1
  48. package/dist/development/src/project/ProjectContainer.js +1 -1
  49. package/dist/development/src/projectGroup/ProjectGroupContainer.cjs +3 -2
  50. package/dist/development/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
  51. package/dist/development/src/projectGroup/ProjectGroupContainer.js +3 -2
  52. package/dist/development/src/projectGroup/ProjectGroupContainer.js.map +1 -1
  53. package/dist/development/src/providers.cjs +2 -2
  54. package/dist/development/src/providers.cjs.map +1 -1
  55. package/dist/development/src/providers.js +2 -2
  56. package/dist/development/src/providers.js.map +1 -1
  57. package/dist/development/src/transfer/ImportApiMiddlewareFactory.cjs +2 -2
  58. package/dist/development/src/transfer/ImportApiMiddlewareFactory.cjs.map +1 -1
  59. package/dist/development/src/transfer/ImportExecutor.cjs +33 -5
  60. package/dist/development/src/transfer/ImportExecutor.cjs.map +1 -1
  61. package/dist/development/src/transfer/ImportExecutor.js +33 -5
  62. package/dist/development/src/transfer/ImportExecutor.js.map +1 -1
  63. package/dist/development/src/utils/CryptoWrapper.cjs +11 -0
  64. package/dist/development/src/utils/CryptoWrapper.cjs.map +1 -1
  65. package/dist/development/src/utils/CryptoWrapper.js +11 -0
  66. package/dist/development/src/utils/CryptoWrapper.js.map +1 -1
  67. package/dist/development/src/utils/sentry.cjs +32 -49
  68. package/dist/development/src/utils/sentry.cjs.map +1 -1
  69. package/dist/development/src/utils/sentry.js +33 -33
  70. package/dist/development/src/utils/sentry.js.map +1 -1
  71. package/dist/development/src/utils/serverStartup.cjs +5 -3
  72. package/dist/development/src/utils/serverStartup.cjs.map +1 -1
  73. package/dist/development/src/utils/serverStartup.js +5 -3
  74. package/dist/development/src/utils/serverStartup.js.map +1 -1
  75. package/dist/production/index.cjs +3 -1
  76. package/dist/production/index.cjs.map +1 -1
  77. package/dist/production/index.js +4 -2
  78. package/dist/production/index.js.map +1 -1
  79. package/dist/production/src/MasterContainer.cjs +5 -4
  80. package/dist/production/src/MasterContainer.cjs.map +1 -1
  81. package/dist/production/src/MasterContainer.js +5 -4
  82. package/dist/production/src/MasterContainer.js.map +1 -1
  83. package/dist/production/src/application/PanelApiMount.cjs.map +1 -1
  84. package/dist/production/src/application/PanelApiMount.js.map +1 -1
  85. package/dist/production/src/application/application.cjs +27 -21
  86. package/dist/production/src/application/application.cjs.map +1 -1
  87. package/dist/production/src/application/application.js +27 -21
  88. package/dist/production/src/application/application.js.map +1 -1
  89. package/dist/production/src/application/compression.cjs +99 -0
  90. package/dist/production/src/application/compression.cjs.map +1 -0
  91. package/dist/production/src/application/compression.js +82 -0
  92. package/dist/production/src/application/compression.js.map +1 -0
  93. package/dist/production/src/application/cors.cjs +52 -0
  94. package/dist/production/src/application/cors.cjs.map +1 -0
  95. package/dist/production/src/application/cors.js +52 -0
  96. package/dist/production/src/application/cors.js.map +1 -0
  97. package/dist/production/src/application/requestBody.cjs +242 -0
  98. package/dist/production/src/application/requestBody.cjs.map +1 -0
  99. package/dist/production/src/application/requestBody.js +242 -0
  100. package/dist/production/src/application/requestBody.js.map +1 -0
  101. package/dist/production/src/application/requestBodyMasking.cjs +97 -0
  102. package/dist/production/src/application/requestBodyMasking.cjs.map +1 -0
  103. package/dist/production/src/application/requestBodyMasking.js +97 -0
  104. package/dist/production/src/application/requestBodyMasking.js.map +1 -0
  105. package/dist/production/src/config/configSchema.cjs +36 -1
  106. package/dist/production/src/config/configSchema.cjs.map +1 -1
  107. package/dist/production/src/config/configSchema.js +36 -1
  108. package/dist/production/src/config/configSchema.js.map +1 -1
  109. package/dist/production/src/config/configTemplate.cjs +5 -0
  110. package/dist/production/src/config/configTemplate.cjs.map +1 -1
  111. package/dist/production/src/config/configTemplate.js +5 -0
  112. package/dist/production/src/config/configTemplate.js.map +1 -1
  113. package/dist/production/src/content/ProjectMembershipResolver.cjs +10 -3
  114. package/dist/production/src/content/ProjectMembershipResolver.cjs.map +1 -1
  115. package/dist/production/src/content/ProjectMembershipResolver.js +10 -3
  116. package/dist/production/src/content/ProjectMembershipResolver.js.map +1 -1
  117. package/dist/production/src/graphql/execution.cjs +3 -9
  118. package/dist/production/src/graphql/execution.cjs.map +1 -1
  119. package/dist/production/src/graphql/execution.js +3 -9
  120. package/dist/production/src/graphql/execution.js.map +1 -1
  121. package/dist/production/src/project/ProjectContainer.cjs +1 -1
  122. package/dist/production/src/project/ProjectContainer.js +1 -1
  123. package/dist/production/src/projectGroup/ProjectGroupContainer.cjs +3 -2
  124. package/dist/production/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
  125. package/dist/production/src/projectGroup/ProjectGroupContainer.js +3 -2
  126. package/dist/production/src/projectGroup/ProjectGroupContainer.js.map +1 -1
  127. package/dist/production/src/providers.cjs +2 -2
  128. package/dist/production/src/providers.cjs.map +1 -1
  129. package/dist/production/src/providers.js +2 -2
  130. package/dist/production/src/providers.js.map +1 -1
  131. package/dist/production/src/transfer/ImportApiMiddlewareFactory.cjs +2 -2
  132. package/dist/production/src/transfer/ImportApiMiddlewareFactory.cjs.map +1 -1
  133. package/dist/production/src/transfer/ImportExecutor.cjs +33 -5
  134. package/dist/production/src/transfer/ImportExecutor.cjs.map +1 -1
  135. package/dist/production/src/transfer/ImportExecutor.js +33 -5
  136. package/dist/production/src/transfer/ImportExecutor.js.map +1 -1
  137. package/dist/production/src/utils/CryptoWrapper.cjs +11 -0
  138. package/dist/production/src/utils/CryptoWrapper.cjs.map +1 -1
  139. package/dist/production/src/utils/CryptoWrapper.js +11 -0
  140. package/dist/production/src/utils/CryptoWrapper.js.map +1 -1
  141. package/dist/production/src/utils/sentry.cjs +32 -49
  142. package/dist/production/src/utils/sentry.cjs.map +1 -1
  143. package/dist/production/src/utils/sentry.js +33 -33
  144. package/dist/production/src/utils/sentry.js.map +1 -1
  145. package/dist/production/src/utils/serverStartup.cjs +5 -3
  146. package/dist/production/src/utils/serverStartup.cjs.map +1 -1
  147. package/dist/production/src/utils/serverStartup.js +5 -3
  148. package/dist/production/src/utils/serverStartup.js.map +1 -1
  149. package/dist/tests/cases/unit/compression.test.d.ts +2 -0
  150. package/dist/tests/cases/unit/compression.test.d.ts.map +1 -0
  151. package/dist/tests/cases/unit/cors.test.d.ts +2 -0
  152. package/dist/tests/cases/unit/cors.test.d.ts.map +1 -0
  153. package/dist/tests/cases/unit/requestBody.test.d.ts +2 -0
  154. package/dist/tests/cases/unit/requestBody.test.d.ts.map +1 -0
  155. package/dist/tests/cases/unit/requestBodyLogging.test.d.ts +2 -0
  156. package/dist/tests/cases/unit/requestBodyLogging.test.d.ts.map +1 -0
  157. package/dist/tests/cases/unit/requestBodyMasking.test.d.ts +2 -0
  158. package/dist/tests/cases/unit/requestBodyMasking.test.d.ts.map +1 -0
  159. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  160. package/dist/types/MasterContainer.d.ts +8 -1
  161. package/dist/types/MasterContainer.d.ts.map +1 -1
  162. package/dist/types/application/PanelApiMount.d.ts +2 -0
  163. package/dist/types/application/PanelApiMount.d.ts.map +1 -1
  164. package/dist/types/application/application.d.ts +7 -1
  165. package/dist/types/application/application.d.ts.map +1 -1
  166. package/dist/types/application/compression.d.ts +19 -0
  167. package/dist/types/application/compression.d.ts.map +1 -0
  168. package/dist/types/application/cors.d.ts +10 -0
  169. package/dist/types/application/cors.d.ts.map +1 -0
  170. package/dist/types/application/index.d.ts +1 -0
  171. package/dist/types/application/index.d.ts.map +1 -1
  172. package/dist/types/application/requestBody.d.ts +45 -0
  173. package/dist/types/application/requestBody.d.ts.map +1 -0
  174. package/dist/types/application/requestBodyMasking.d.ts +10 -0
  175. package/dist/types/application/requestBodyMasking.d.ts.map +1 -0
  176. package/dist/types/config/configSchema.d.ts +13 -3
  177. package/dist/types/config/configSchema.d.ts.map +1 -1
  178. package/dist/types/config/configTemplate.d.ts.map +1 -1
  179. package/dist/types/content/ProjectMembershipResolver.d.ts.map +1 -1
  180. package/dist/types/graphql/execution.d.ts.map +1 -1
  181. package/dist/types/projectGroup/ProjectGroupContainer.d.ts.map +1 -1
  182. package/dist/types/transfer/ImportExecutor.d.ts +2 -0
  183. package/dist/types/transfer/ImportExecutor.d.ts.map +1 -1
  184. package/dist/types/tsconfig.tsbuildinfo +1 -1
  185. package/dist/types/utils/CryptoWrapper.d.ts +5 -0
  186. package/dist/types/utils/CryptoWrapper.d.ts.map +1 -1
  187. package/dist/types/utils/sentry.d.ts +13 -6
  188. package/dist/types/utils/sentry.d.ts.map +1 -1
  189. package/dist/types/utils/serverStartup.d.ts.map +1 -1
  190. package/package.json +18 -24
  191. package/src/MasterContainer.ts +5 -3
  192. package/src/application/PanelApiMount.ts +2 -0
  193. package/src/application/application.ts +38 -20
  194. package/src/application/compression.ts +118 -0
  195. package/src/application/cors.ts +61 -0
  196. package/src/application/index.ts +1 -0
  197. package/src/application/requestBody.ts +295 -0
  198. package/src/application/requestBodyMasking.ts +117 -0
  199. package/src/config/configSchema.ts +38 -1
  200. package/src/config/configTemplate.ts +5 -0
  201. package/src/content/ProjectMembershipResolver.ts +13 -5
  202. package/src/graphql/execution.ts +3 -9
  203. package/src/projectGroup/ProjectGroupContainer.ts +1 -0
  204. package/src/providers.ts +2 -2
  205. package/src/transfer/ImportExecutor.ts +37 -5
  206. package/src/tsconfig.json +3 -1
  207. package/src/utils/CryptoWrapper.ts +12 -0
  208. package/src/utils/sentry.ts +42 -39
  209. package/src/utils/serverStartup.ts +7 -5
  210. package/tests/cases/unit/compression.test.ts +172 -0
  211. package/tests/cases/unit/cors.test.ts +106 -0
  212. package/tests/cases/unit/crypto.test.ts +16 -0
  213. package/tests/cases/unit/projectMembershipResolver.test.ts +50 -0
  214. package/tests/cases/unit/requestBody.test.ts +333 -0
  215. package/tests/cases/unit/requestBodyLogging.test.ts +89 -0
  216. package/tests/cases/unit/requestBodyMasking.test.ts +102 -0
  217. package/tests/cases/unit/sentryLoggerHandler.test.ts +74 -20
  218. package/tests/cases/unit/serverConfig.test.ts +42 -0
  219. package/dist/tests/cases/unit/sentryIntegrations.test.d.ts +0 -2
  220. package/dist/tests/cases/unit/sentryIntegrations.test.d.ts.map +0 -1
  221. package/tests/cases/unit/sentryIntegrations.test.ts +0 -15
@@ -0,0 +1,333 @@
1
+ import { afterAll, beforeAll, describe, expect, test } from 'bun:test'
2
+ import Koa from 'koa'
3
+ import { IncomingHttpHeaders, IncomingMessage, request, Server } from 'node:http'
4
+ import { AddressInfo, connect, Socket } from 'node:net'
5
+ import { brotliCompressSync, deflateSync, gzipSync } from 'node:zlib'
6
+ import {
7
+ createRequestBodyMiddleware,
8
+ parseByteSize,
9
+ parseFormBody,
10
+ parseJsonBody,
11
+ parseMediaType,
12
+ readRequestText,
13
+ } from '../../../src/application/requestBody.js'
14
+
15
+ describe('parseByteSize', () => {
16
+ test('reads plain bytes and binary units', () => {
17
+ expect(parseByteSize('0')).toBe(0)
18
+ expect(parseByteSize('100')).toBe(100)
19
+ expect(parseByteSize('100b')).toBe(100)
20
+ expect(parseByteSize('56kb')).toBe(56 * 1024)
21
+ expect(parseByteSize('1mb')).toBe(1048576)
22
+ expect(parseByteSize('1.5 MB')).toBe(1572864)
23
+ expect(parseByteSize(' 2gb ')).toBe(2 * 1024 ** 3)
24
+ })
25
+
26
+ test('rejects anything else', () => {
27
+ for (const value of ['', 'mb', '-1', '+1mb', '1e3', '0x10', '10 megabytes', '1.mb', '99999pb']) {
28
+ expect(parseByteSize(value)).toBeUndefined()
29
+ }
30
+ })
31
+ })
32
+
33
+ describe('parseMediaType', () => {
34
+ test('lower-cases the type and drops valid parameters', () => {
35
+ expect(parseMediaType('application/json')).toBe('application/json')
36
+ expect(parseMediaType('Application/JSON')).toBe('application/json')
37
+ expect(parseMediaType('application/json; charset=utf-8')).toBe('application/json')
38
+ expect(parseMediaType('application/json;charset="utf-8"')).toBe('application/json')
39
+ expect(parseMediaType('application/json ; charset=utf-8')).toBe('application/json')
40
+ expect(parseMediaType('text/plain; a=1; b="x\\"y"')).toBe('text/plain')
41
+ })
42
+
43
+ test('accepts one trailing semicolon', () => {
44
+ expect(parseMediaType('application/json;')).toBe('application/json')
45
+ })
46
+
47
+ test('rejects malformed values', () => {
48
+ for (const value of ['', 'json', 'application/json, text/plain', 'application/json; charset', 'application/json;;', 'a/b; x="open', '/json']) {
49
+ expect(parseMediaType(value)).toBeUndefined()
50
+ }
51
+ })
52
+ })
53
+
54
+ describe('parseJsonBody', () => {
55
+ test('accepts objects and arrays, and an empty body as {}', () => {
56
+ expect(parseJsonBody('{"a":1}')).toEqual({ ok: true, value: { a: 1 } })
57
+ expect(parseJsonBody(' \n\t[1]')).toEqual({ ok: true, value: [1] })
58
+ expect(parseJsonBody('')).toEqual({ ok: true, value: {} })
59
+ })
60
+
61
+ test('rejects other JSON values and invalid JSON', () => {
62
+ for (const text of ['1', '"a"', 'null', 'true', '{bad', '\v{}']) {
63
+ expect(parseJsonBody(text)).toEqual({ ok: false })
64
+ }
65
+ })
66
+
67
+ test('rejects a __proto__ key at any depth, in any escaped spelling', () => {
68
+ expect(parseJsonBody('{"__proto__":{"admin":true}}')).toEqual({ ok: false })
69
+ expect(parseJsonBody('{"a":[{"b":{"\\u005f\\u005fproto\\u005F_" : 1}}]}')).toEqual({ ok: false })
70
+ })
71
+
72
+ test('keeps a __proto__ string value and other prototype-like keys', () => {
73
+ expect(parseJsonBody('{"a":"\\"__proto__\\":"}')).toEqual({ ok: true, value: { a: '"__proto__":' } })
74
+ expect(parseJsonBody('{"constructor":{"prototype":{}}}')).toEqual({ ok: true, value: { constructor: { prototype: {} } } })
75
+ })
76
+
77
+ test('scans deeply nested input without overflowing the stack', () => {
78
+ const depth = 100_000
79
+ const text = `${'['.repeat(depth)}{"__proto__":1}${']'.repeat(depth)}`
80
+ expect(parseJsonBody(text)).toEqual({ ok: false })
81
+ })
82
+ })
83
+
84
+ describe('parseFormBody', () => {
85
+ test('decodes pairs and collects repeated keys', () => {
86
+ expect(parseFormBody('a=1&b=x+y&b=%E2%9C%93&c')).toEqual({ a: '1', b: ['x y', '✓'], c: '' })
87
+ })
88
+
89
+ test('drops prototype keys and empty keys', () => {
90
+ const parsed = parseFormBody('__proto__=1&constructor=2&toString=3&=4&ok=5')
91
+ expect(parsed).toEqual({ ok: '5' })
92
+ expect(Object.getPrototypeOf(parsed)).toBe(Object.prototype)
93
+ })
94
+
95
+ test('reads at most 1000 pairs', () => {
96
+ const parsed = parseFormBody(Array.from({ length: 1500 }, (_, i) => `k${i}=${i}`).join('&'))
97
+ expect(Object.keys(parsed)).toHaveLength(1000)
98
+ expect(parsed.k999).toBe('999')
99
+ })
100
+ })
101
+
102
+ type Response = { status: number; headers: IncomingHttpHeaders; body: string }
103
+
104
+ const send = (port: number, headers: Record<string, string>, body?: string | Buffer, method = 'POST', path = '/'): Promise<Response> =>
105
+ new Promise((resolve, reject) => {
106
+ const req = request({ host: '127.0.0.1', port, path, method, headers }, res => {
107
+ let text = ''
108
+ res.setEncoding('utf8')
109
+ res.on('data', chunk => text += chunk)
110
+ res.on('end', () => resolve({ status: res.statusCode ?? 0, headers: res.headers, body: text }))
111
+ })
112
+ req.on('error', reject)
113
+ req.end(body)
114
+ })
115
+
116
+ /** Writes a raw HTTP request and resolves with the response's status line. */
117
+ const sendRaw = (port: number, raw: string | Buffer): Promise<string> =>
118
+ new Promise((resolve, reject) => {
119
+ const socket = connect(port, '127.0.0.1')
120
+ let response = ''
121
+ socket.on('data', chunk => {
122
+ response += chunk
123
+ if (response.includes('\r\n')) {
124
+ resolve(response.slice(0, response.indexOf('\r\n')))
125
+ socket.destroy()
126
+ }
127
+ })
128
+ socket.on('error', reject)
129
+ socket.write(raw)
130
+ })
131
+
132
+ /** Raw, because the HTTP client adds a Content-Length to a chunked body. */
133
+ const sendChunked = (port: number, contentType: string, body: string | Buffer, extraHeaders: readonly string[] = []): Promise<string> => {
134
+ const headers = ['POST / HTTP/1.1', 'Host: localhost', `Content-Type: ${contentType}`, 'Transfer-Encoding: chunked', ...extraHeaders, '', '']
135
+ return sendRaw(
136
+ port,
137
+ Buffer.concat([Buffer.from(`${headers.join('\r\n')}${Buffer.byteLength(body).toString(16)}\r\n`), Buffer.from(body), Buffer.from('\r\n0\r\n\r\n')]),
138
+ )
139
+ }
140
+
141
+ const waitFor = async (condition: () => boolean): Promise<void> => {
142
+ const deadline = Date.now() + 2000
143
+ while (!condition() && Date.now() < deadline) {
144
+ await new Promise(resolve => setTimeout(resolve, 10))
145
+ }
146
+ }
147
+
148
+ describe('request body middleware', () => {
149
+ let server: Server
150
+ let port: number
151
+ const errors: Error[] = []
152
+ let streamedBody: string | undefined
153
+
154
+ beforeAll(async () => {
155
+ const koa = new Koa()
156
+ koa.silent = true
157
+ koa.on('error', error => errors.push(error))
158
+ koa.use(createRequestBodyMiddleware({ json: 1000, form: 50 }))
159
+ koa.use(async ctx => {
160
+ if (ctx.get('Content-Type') === 'application/x-ndjson') {
161
+ let text = ''
162
+ for await (const chunk of ctx.req) {
163
+ text += chunk
164
+ }
165
+ streamedBody = text
166
+ }
167
+ ctx.body = { body: ctx.request.body }
168
+ })
169
+ server = koa.listen(0)
170
+ await new Promise(resolve => server.once('listening', resolve))
171
+ port = (server.address() as AddressInfo).port
172
+ })
173
+
174
+ afterAll(() => {
175
+ server.close()
176
+ })
177
+
178
+ const json = { 'Content-Type': 'application/json' }
179
+
180
+ test('parses JSON and form bodies', async () => {
181
+ expect((await send(port, json, '{"a":1}')).body).toBe('{"body":{"a":1}}')
182
+ expect((await send(port, { 'Content-Type': 'application/x-www-form-urlencoded' }, 'a=1')).body).toBe('{"body":{"a":"1"}}')
183
+ expect((await send(port, { 'Content-Type': 'application/vnd.api+json' }, '{"b":2}')).body).toBe('{"body":{"b":2}}')
184
+ })
185
+
186
+ test('other content types are not read', async () => {
187
+ expect((await send(port, { 'Content-Type': 'text/plain' }, '{"a":1}')).body).toBe('{"body":{}}')
188
+ expect((await send(port, {}, undefined, 'GET')).body).toBe('{"body":{}}')
189
+ const response = await send(port, { 'Content-Type': 'application/x-ndjson' }, '{"a":1}\n{"a":2}\n')
190
+ expect(response.body).toBe('{"body":{}}')
191
+ expect(streamedBody).toBe('{"a":1}\n{"a":2}\n')
192
+ })
193
+
194
+ test('invalid JSON and a __proto__ key are 400', async () => {
195
+ expect(await send(port, json, '{bad')).toMatchObject({ status: 400, body: 'Bad Request' })
196
+ expect(await send(port, json, '"str"')).toMatchObject({ status: 400 })
197
+ expect(await send(port, json, '{"__proto__":{}}')).toMatchObject({ status: 400 })
198
+ })
199
+
200
+ test('limits are 413, by Content-Length and by the bytes received', async () => {
201
+ const tooLong = `{"a":"${'x'.repeat(1000)}"}`
202
+ expect(await send(port, json, tooLong)).toMatchObject({ status: 413, body: 'request entity too large' })
203
+ expect(await sendChunked(port, 'application/json', tooLong)).toStartWith('HTTP/1.1 413 ')
204
+ expect(await sendChunked(port, 'application/json', '{"a":1}')).toStartWith('HTTP/1.1 200 ')
205
+ // a declared length over the limit is refused before any of the body arrives
206
+ const declaredOnly = ['POST / HTTP/1.1', 'Host: localhost', 'Content-Type: application/json', 'Content-Length: 2000', '', '']
207
+ expect(await sendRaw(port, declaredOnly.join('\r\n'))).toStartWith('HTTP/1.1 413 ')
208
+ expect(await send(port, { 'Content-Type': 'application/x-www-form-urlencoded' }, `a=${'x'.repeat(50)}`)).toMatchObject({ status: 413 })
209
+ expect(await send(port, json, `{"a":"${'x'.repeat(992)}"}`)).toMatchObject({ status: 200 })
210
+ })
211
+
212
+ test('compressed bodies are decompressed, and the limit applies after decompression', async () => {
213
+ expect((await send(port, { ...json, 'Content-Encoding': 'gzip' }, gzipSync('{"g":1}'))).body).toBe('{"body":{"g":1}}')
214
+ expect((await send(port, { ...json, 'Content-Encoding': 'deflate' }, deflateSync('{"d":1}'))).body).toBe('{"body":{"d":1}}')
215
+ expect((await send(port, { ...json, 'Content-Encoding': 'br' }, brotliCompressSync('{"b":1}'))).body).toBe('{"body":{"b":1}}')
216
+ const bomb = gzipSync(`{"a":"${'x'.repeat(100_000)}"}`)
217
+ expect(bomb.length).toBeLessThan(1000)
218
+ expect(await send(port, { ...json, 'Content-Encoding': 'gzip' }, bomb)).toMatchObject({ status: 413 })
219
+ })
220
+
221
+ test('compressed input is capped too, even when it inflates to nothing', async () => {
222
+ // 200 empty gzip members: about 4 KB on the wire, 0 bytes decompressed
223
+ const emptyMembers = Buffer.concat(Array.from({ length: 200 }, () => gzipSync('')))
224
+ expect(await send(port, { ...json, 'Content-Encoding': 'gzip' }, emptyMembers)).toMatchObject({ status: 413 })
225
+ expect(await sendChunked(port, 'application/json', emptyMembers, ['Content-Encoding: gzip'])).toStartWith('HTTP/1.1 413 ')
226
+ expect((await send(port, { ...json, 'Content-Encoding': 'gzip' }, Buffer.concat([gzipSync(''), gzipSync('{"a":1}')]))).body).toBe(
227
+ '{"body":{"a":1}}',
228
+ )
229
+ })
230
+
231
+ test('an unknown encoding is 415, a corrupt one 400', async () => {
232
+ expect(await send(port, { ...json, 'Content-Encoding': 'compress' }, '{}')).toMatchObject({ status: 415, body: 'Unsupported Media Type' })
233
+ expect(await send(port, { ...json, 'Content-Encoding': 'gzip' }, 'not gzip')).toMatchObject({ status: 400 })
234
+ })
235
+
236
+ test('a body cut short fails with 400 instead of hanging', async () => {
237
+ errors.length = 0
238
+ for (const encoding of [undefined, 'gzip']) {
239
+ const socket = connect(port, '127.0.0.1')
240
+ const headers = [`POST / HTTP/1.1`, 'Host: localhost', 'Content-Type: application/json', 'Content-Length: 800']
241
+ const prefix = encoding ? gzipSync('{"a":"' + 'x'.repeat(10)).subarray(0, 10) : Buffer.from('{"a":')
242
+ socket.write([...headers, ...(encoding ? [`Content-Encoding: ${encoding}`] : []), '', ''].join('\r\n'))
243
+ socket.write(prefix)
244
+ await new Promise(resolve => setTimeout(resolve, 50))
245
+ socket.destroy()
246
+ }
247
+ await waitFor(() => errors.length >= 2)
248
+ expect(errors.map(it => [Reflect.get(it, 'status'), it.message])).toEqual([[400, 'request aborted'], [400, 'request aborted']])
249
+ })
250
+ })
251
+
252
+ describe('readRequestText on a request that cannot emit anymore', () => {
253
+ test('a closed request is 400 at once', async () => {
254
+ const closed = new IncomingMessage(new Socket())
255
+ closed.headers = {}
256
+ closed.destroy()
257
+ await expect(readRequestText(closed, 100)).rejects.toMatchObject({ failure: { status: 400, message: 'request aborted' } })
258
+ })
259
+
260
+ test('a consumed request is 500 at once', async () => {
261
+ const consumed = new IncomingMessage(new Socket())
262
+ consumed.headers = {}
263
+ consumed.push('{}')
264
+ consumed.push(null)
265
+ consumed.resume()
266
+ await new Promise(resolve => consumed.once('end', resolve))
267
+ await expect(readRequestText(consumed, 100)).rejects.toMatchObject({ failure: { status: 500 } })
268
+ })
269
+
270
+ test('an unknown encoding rejects rather than throws', async () => {
271
+ const compressed = new IncomingMessage(new Socket())
272
+ compressed.headers = { 'content-encoding': 'compress' }
273
+ await expect(readRequestText(compressed, 100)).rejects.toMatchObject({ failure: { status: 415 } })
274
+ })
275
+ })
276
+
277
+ describe('request body middleware after other middlewares', () => {
278
+ let server: Server
279
+ let port: number
280
+ const errors: Error[] = []
281
+ const completed: string[] = []
282
+
283
+ beforeAll(async () => {
284
+ const koa = new Koa()
285
+ koa.silent = true
286
+ koa.on('error', error => errors.push(error))
287
+ koa.use(async (ctx, next) => {
288
+ if (ctx.path === '/slow') {
289
+ await new Promise(resolve => setTimeout(resolve, 100))
290
+ } else if (ctx.path === '/consumed') {
291
+ for await (const _ of ctx.req) {
292
+ // drained by an earlier middleware
293
+ }
294
+ } else if (ctx.path === '/preset') {
295
+ ctx.request.body = { preset: true }
296
+ }
297
+ await next()
298
+ })
299
+ koa.use(createRequestBodyMiddleware({ json: 1000, form: 50 }))
300
+ koa.use(async ctx => {
301
+ completed.push(ctx.path)
302
+ ctx.body = { body: ctx.request.body }
303
+ })
304
+ server = koa.listen(0)
305
+ await new Promise(resolve => server.once('listening', resolve))
306
+ port = (server.address() as AddressInfo).port
307
+ })
308
+
309
+ afterAll(() => {
310
+ server.close()
311
+ })
312
+
313
+ const json = { 'Content-Type': 'application/json' }
314
+
315
+ test('a body set earlier is kept', async () => {
316
+ expect((await send(port, json, '{"a":1}', 'POST', '/preset')).body).toBe('{"body":{"preset":true}}')
317
+ })
318
+
319
+ test('a body already read is a 500, not a pending request', async () => {
320
+ expect(await send(port, json, '{"a":1}', 'POST', '/consumed')).toMatchObject({ status: 500 })
321
+ })
322
+
323
+ test('a client gone before the parser runs does not leave the request pending', async () => {
324
+ errors.length = 0
325
+ const socket = connect(port, '127.0.0.1')
326
+ socket.write(['POST /slow HTTP/1.1', 'Host: localhost', 'Content-Type: application/json', 'Content-Length: 7', '', '{"a":1}'].join('\r\n'))
327
+ await new Promise(resolve => setTimeout(resolve, 20))
328
+ socket.destroy()
329
+ // Node reports the abort (400); Bun still delivers the buffered body, so the request completes
330
+ await waitFor(() => errors.length > 0 || completed.includes('/slow'))
331
+ expect(errors.length > 0 || completed.includes('/slow')).toBe(true)
332
+ })
333
+ })
@@ -0,0 +1,89 @@
1
+ import { expect, test } from 'bun:test'
2
+ import { createLogger, TestLoggerHandler } from '@contember/logger'
3
+ import { VerifyResult } from '@contember/engine-tenant-api'
4
+ import { Application, LoggerRequestBody } from '../../../src/application/application.js'
5
+ import { Authenticator } from '../../../src/common/Authorizator.js'
6
+ import { HttpResponse } from '../../../src/common/HttpResponse.js'
7
+ import { serverConfigSchema } from '../../../src/config/configSchema.js'
8
+ import { ProjectGroupContainer } from '../../../src/projectGroup/ProjectGroupContainer.js'
9
+ import { ProjectGroupResolver } from '../../../src/projectGroup/ProjectGroupResolver.js'
10
+ import { createMock } from '../../utils.js'
11
+
12
+ const unavailable = (): never => {
13
+ throw new Error('This service is not available in the request logging test')
14
+ }
15
+
16
+ const createTestApplication = () => {
17
+ const loggerHandler = new TestLoggerHandler()
18
+ const logger = createLogger(loggerHandler)
19
+ const groupContainer: ProjectGroupContainer = {
20
+ slug: 'group',
21
+ logger,
22
+ authenticator: createMock<Authenticator>({
23
+ authenticate: async () => new VerifyResult('identity', 'api-key', ['person'], null),
24
+ }),
25
+ get projectMembershipResolver() {
26
+ return unavailable()
27
+ },
28
+ get projectContainerResolver() {
29
+ return unavailable()
30
+ },
31
+ get projectSchemaResolver() {
32
+ return unavailable()
33
+ },
34
+ get projectInitializer() {
35
+ return unavailable()
36
+ },
37
+ get tenantContainer() {
38
+ return unavailable()
39
+ },
40
+ get tenantGraphQLHandler() {
41
+ return unavailable()
42
+ },
43
+ get systemContainer() {
44
+ return unavailable()
45
+ },
46
+ get systemGraphQLHandler() {
47
+ return unavailable()
48
+ },
49
+ }
50
+ const projectGroupResolver = createMock<ProjectGroupResolver>({
51
+ resolveContainer: async () => groupContainer,
52
+ })
53
+ const application = new Application(projectGroupResolver, serverConfigSchema({ port: 0 }), false, undefined, logger)
54
+ return { application, loggerHandler }
55
+ }
56
+
57
+ test('request logs and error reports carry the body with credentials masked', async () => {
58
+ const { application, loggerHandler } = createTestApplication()
59
+ application.addRoute('tenant', '/tenant', ({ logger }) => {
60
+ // An error flushes the request's buffered debug entries, which is where the body used to appear.
61
+ logger.error(new Error('Resolver failed'))
62
+ return new HttpResponse(200, 'ok')
63
+ }, { carriesCredentials: true })
64
+ const running = await application.listen()
65
+ const address = running.server.address()
66
+ try {
67
+ if (address === null || typeof address === 'string') {
68
+ throw new Error('The test server did not bind to a TCP port')
69
+ }
70
+ const query = 'mutation SignIn($email: String!, $password: String!) { signIn(email: $email, password: $password) { ok } }'
71
+ const response = await fetch(`http://127.0.0.1:${address.port}/tenant`, {
72
+ method: 'POST',
73
+ headers: { 'content-type': 'application/json' },
74
+ body: JSON.stringify({ query, operationName: 'SignIn', variables: { email: 'john@example.com', password: 'secret-password' } }),
75
+ })
76
+ expect(response.status).toBe(200)
77
+
78
+ const expectedBody = { query, operationName: 'SignIn', variables: { email: 'john@example.com', password: '[redacted]' } }
79
+ const error = loggerHandler.messages.find(it => it.error instanceof Error && it.error.message === 'Resolver failed')
80
+ expect(error?.loggerAttributes[LoggerRequestBody]).toEqual(expectedBody)
81
+ const started = loggerHandler.messages.find(it => it.message === 'Request processing started')
82
+ expect(started?.ownAttributes.body).toEqual(expectedBody)
83
+
84
+ const logged = loggerHandler.messages.map(it => [it.ownAttributes, it.loggerAttributes[LoggerRequestBody]])
85
+ expect(JSON.stringify(logged)).not.toContain('secret-password')
86
+ } finally {
87
+ await running.close()
88
+ }
89
+ })
@@ -0,0 +1,102 @@
1
+ import { describe, expect, test } from 'bun:test'
2
+ import { maskRequestBody, maskRequestUri } from '../../../src/application/requestBodyMasking.js'
3
+
4
+ describe('maskRequestBody', () => {
5
+ test('masks a variable passed to a secret argument, whatever its name', () => {
6
+ const query = 'mutation($e: String!, $p: String!) { signIn(email: $e, password: $p) { ok } }'
7
+ expect(maskRequestBody({ query, variables: { e: 'john@example.com', p: 'secret-password' } }, true)).toEqual({
8
+ query,
9
+ variables: { e: 'john@example.com', p: '[redacted]' },
10
+ })
11
+ })
12
+
13
+ test('masks secret literals inlined in the query and keeps the rest', () => {
14
+ const masked = maskRequestBody({
15
+ query: 'mutation { signInPasswordless(requestId: "request-1", token: "link-token", mfaOtp: "123456") { ok } }',
16
+ }, true)
17
+ expect(masked).toEqual({
18
+ query: 'mutation {\n signInPasswordless(\n requestId: "request-1"\n token: "[redacted]"\n mfaOtp: "[redacted]"\n ) {\n ok\n }\n}',
19
+ })
20
+ })
21
+
22
+ test('masks secret fields inside input objects, inline and as variables', () => {
23
+ const query = 'mutation($config: Json!) { addIDP(identityProvider: "sso", type: "oidc", configuration: $config) { ok } }'
24
+ expect(maskRequestBody({ query, variables: { config: { clientId: 'client', clientSecret: 'client-secret' } } }, true)).toEqual({
25
+ query,
26
+ variables: { config: { clientId: 'client', clientSecret: '[redacted]' } },
27
+ })
28
+ const inline = maskRequestBody({
29
+ query: 'mutation { updateIDP(identityProvider: "sso", configuration: { clientSecret: "client-secret" }) { ok } }',
30
+ }, true)
31
+ expect(JSON.stringify(inline)).not.toContain('client-secret')
32
+ })
33
+
34
+ test('masks the value of a project secret, which is secret only on that field', () => {
35
+ const query = 'mutation($v: String!) { setProjectSecret(projectSlug: "blog", key: "s3.secret", value: $v) { ok } }'
36
+ expect(maskRequestBody({ query, variables: { v: 's3-secret-value' } }, true)).toEqual({ query, variables: { v: '[redacted]' } })
37
+ const inline = maskRequestBody(
38
+ { query: 'mutation { setProjectSecret(projectSlug: "blog", key: "s3.secret", value: "s3-secret-value") { ok } }' },
39
+ true,
40
+ )
41
+ expect(JSON.stringify(inline)).not.toContain('s3-secret-value')
42
+ const other = 'query { configuration { value } }'
43
+ expect(maskRequestBody({ query: other }, true)).toEqual({ query: other })
44
+ })
45
+
46
+ test('masks every string of a secret list', () => {
47
+ const query = 'mutation($secrets: [ProjectSecret!]) { createProject(projectSlug: "blog", secrets: $secrets) { ok } }'
48
+ expect(maskRequestBody({ query, variables: { secrets: [{ key: 'db.password', value: 'db-secret' }] } }, true)).toEqual({
49
+ query,
50
+ variables: { secrets: [{ key: '[redacted]', value: '[redacted]' }] },
51
+ })
52
+ })
53
+
54
+ test('replaces a query it cannot parse when it may inline a secret', () => {
55
+ expect(maskRequestBody({ query: 'mutation { signIn(password: "secret-password" ' }, true)).toEqual({ query: '[redacted]' })
56
+ })
57
+
58
+ test('masks secret keys of a body that is not a GraphQL request', () => {
59
+ expect(maskRequestBody({ token: 'abc', name: 'x' }, true)).toEqual({ token: '[redacted]', name: 'x' })
60
+ expect(maskRequestBody(undefined, true)).toBeUndefined()
61
+ })
62
+
63
+ test('masks the default value of a variable bound to a secret argument', () => {
64
+ const masked = maskRequestBody({ query: 'mutation($p: String = "default-secret") { signIn(email: "a", password: $p) { ok } }' }, true)
65
+ expect(JSON.stringify(masked)).not.toContain('default-secret')
66
+ })
67
+
68
+ test('masks every variable when the query naming a secret cannot be parsed', () => {
69
+ const body = { query: 'mutation($p: String!) { signIn(email: "a", password: $p) { ok }', variables: { p: 'secret-password' } }
70
+ expect(maskRequestBody(body, true)).toEqual({ query: '[redacted]', variables: { p: '[redacted]' } })
71
+ })
72
+
73
+ test('masks the IdP callback data, inline and as a variable', () => {
74
+ const query = 'mutation($d: Json) { signInIDP(identityProvider: "sso", data: $d) { ok } }'
75
+ const data = { url: 'https://app/cb?code=AUTHCODE', parameters: { id_token: 'IDTOKEN' }, redirectUrl: 'https://app/cb' }
76
+ expect(JSON.stringify(maskRequestBody({ query, variables: { d: data } }, true))).not.toMatch(/AUTHCODE|IDTOKEN/)
77
+ const inline = maskRequestBody({
78
+ query: 'mutation { signInIDP(identityProvider: "sso", idpResponse: { url: "https://app/cb?code=AUTHCODE" }) { ok } }',
79
+ }, true)
80
+ expect(JSON.stringify(inline)).not.toContain('AUTHCODE')
81
+ })
82
+
83
+ test('masks actions variables', () => {
84
+ const query = 'mutation($a: [VariableInput!]!) { setVariables(args: $a) { ok } }'
85
+ expect(maskRequestBody({ query, variables: { a: [{ name: 'webhookToken', value: 'hook-secret' }] } }, true)).toEqual({
86
+ query,
87
+ variables: { a: [{ name: '[redacted]', value: '[redacted]' }] },
88
+ })
89
+ })
90
+
91
+ test('masks a GraphQL request sent as a query string, whose variables are a JSON string', () => {
92
+ const query = { query: 'mutation($p: String!) { signIn(email: "a", password: $p) { ok } }', variables: '{"p":"secret-password"}' }
93
+ expect(JSON.stringify(maskRequestBody(query, true))).not.toContain('secret-password')
94
+ expect(maskRequestUri('/tenant?query=mutation&variables=x', true)).toBe('/tenant?[redacted]')
95
+ expect(maskRequestUri('/content/blog/live?x=1', false)).toBe('/content/blog/live?x=1')
96
+ })
97
+
98
+ test('leaves the project data of routes without credentials as sent', () => {
99
+ const body = { query: 'query { listProduct(filter: { code: { eq: "PROD-1" } }) { token } }' }
100
+ expect(maskRequestBody(body, false)).toBe(body)
101
+ })
102
+ })
@@ -1,31 +1,85 @@
1
- import { afterAll, beforeAll, expect, test } from 'bun:test'
2
- import * as Sentry from '@sentry/node'
1
+ import { describe, expect, test } from 'bun:test'
3
2
  import { createLogger, LogLevels } from '@contember/logger'
3
+ import { createSentryClient, SentryEvent } from '@contember/sentry-client'
4
+ import { LoggerRequestBody } from '../../../src/application/index.js'
4
5
  import { SentryLoggerHandler } from '../../../src/utils/sentry.js'
5
6
 
6
- const captured: Sentry.Event[] = []
7
-
8
- beforeAll(() => {
9
- Sentry.init({
7
+ const setup = () => {
8
+ const events: SentryEvent[] = []
9
+ const client = createSentryClient({
10
10
  dsn: 'https://public@sentry.invalid/1',
11
- defaultIntegrations: false,
12
- beforeSend: event => {
13
- captured.push(event)
14
- return null
11
+ contextLines: 0,
12
+ // a fake ingest: the event is the third line of the envelope
13
+ fetch: async (_url, init) => {
14
+ events.push(JSON.parse(String(init.body).split('\n')[2]))
15
+ return new Response('{}')
15
16
  },
16
17
  })
17
- })
18
+ const logger = createLogger(new SentryLoggerHandler(LogLevels.warn, client))
19
+ return { logger, events, flush: () => client.flush(2000) }
20
+ }
18
21
 
19
- afterAll(async () => {
20
- await Sentry.close()
21
- })
22
+ describe('SentryLoggerHandler', () => {
23
+ test('tags an event with both the project group and the project', async () => {
24
+ const { logger, events, flush } = setup()
25
+ logger.child({ projectGroup: 'group', project: 'blog' }).warn(new Error('Webhook request failed'))
26
+ await flush()
27
+
28
+ expect(events).toHaveLength(1)
29
+ expect(events[0].tags).toEqual({ projectGroup: 'group', project: 'blog' })
30
+ })
31
+
32
+ test('reports the request of the log entry', async () => {
33
+ const { logger, events, flush } = setup()
34
+ const requestLogger = logger.child({
35
+ module: 'content',
36
+ requestId: 'r1',
37
+ user: 'identity-1',
38
+ uri: '/content/blog/live',
39
+ traceId: '0af7651916cd43dd8448eb211c80319c',
40
+ spanId: 'b7ad6b7169203331',
41
+ [LoggerRequestBody]: { query: '{ listArticle { id } }', variables: { password: '***' } },
42
+ })
43
+ requestLogger.error(new TypeError('Query failed'))
44
+ await flush()
45
+
46
+ expect(events).toHaveLength(1)
47
+ expect(events[0]).toMatchObject({
48
+ level: 'error',
49
+ tags: { module: 'content' },
50
+ user: { id: 'identity-1' },
51
+ extra: { requestId: 'r1' },
52
+ request: { url: '/content/blog/live', data: { query: '{ listArticle { id } }', variables: { password: '***' } } },
53
+ contexts: { trace: { trace_id: '0af7651916cd43dd8448eb211c80319c', span_id: 'b7ad6b7169203331' } },
54
+ })
55
+ expect(events[0].exception?.values.at(-1)).toMatchObject({ type: 'TypeError', value: 'Query failed' })
56
+ })
57
+
58
+ test('reports the request URI the request logger set', async () => {
59
+ const { logger, events, flush } = setup()
60
+ logger.child({ uri: '/tenant?token=********' }).error(new Error('Sign-in failed'))
61
+ await flush()
22
62
 
23
- test('tags an event with both the project group and the project', async () => {
24
- const logger = createLogger(new SentryLoggerHandler(LogLevels.warn)).child({ projectGroup: 'group', project: 'blog' })
63
+ expect(events[0].request?.url).toBe('/tenant?token=********')
64
+ })
25
65
 
26
- logger.warn(new Error('Webhook request failed'))
27
- await Sentry.flush(1_000)
66
+ test('maps the log level', async () => {
67
+ const { logger, events, flush } = setup()
68
+ logger.warn(new Error('warn'))
69
+ logger.error(new Error('error'))
70
+ logger.crit(new Error('crit'))
71
+ await flush()
28
72
 
29
- expect(captured).toHaveLength(1)
30
- expect(captured[0].tags).toMatchObject({ projectGroup: 'group', project: 'blog' })
73
+ expect(events.map(it => it.level)).toEqual(['warning', 'error', 'fatal'])
74
+ expect(events.every(it => it.contexts?.trace === undefined)).toBe(true)
75
+ })
76
+
77
+ test('ignores entries without an error and entries below warn', async () => {
78
+ const { logger, events, flush } = setup()
79
+ logger.warn('only a message')
80
+ logger.info(new Error('info'))
81
+ await flush()
82
+
83
+ expect(events).toEqual([])
84
+ })
31
85
  })