@tsed/platform-test-sdk 8.0.1 → 8.0.3
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/package.json +15 -14
- package/src/components/PlatformTestSdk.ts +30 -0
- package/src/data/file.txt +1 -0
- package/src/data/response.data.json +3 -0
- package/src/data/swagger.json +32 -0
- package/src/errors/CustomBadRequest.ts +16 -0
- package/src/errors/CustomInternalError.ts +16 -0
- package/src/index.ts +40 -0
- package/src/interfaces/PlatformTestingSdkOpts.ts +10 -0
- package/src/interfaces/index.ts +4 -0
- package/src/modules/feature/FeatureModule.ts +10 -0
- package/src/modules/feature/controllers/FeatureController.ts +11 -0
- package/src/tests/exports.ts +71 -0
- package/src/tests/testAcceptMime.ts +99 -0
- package/src/tests/testAuth.ts +345 -0
- package/src/tests/testBodyParams.ts +488 -0
- package/src/tests/testCache.ts +283 -0
- package/src/tests/testChildrenControllers.ts +59 -0
- package/src/tests/testCookies.ts +41 -0
- package/src/tests/testCustom404.ts +35 -0
- package/src/tests/testDeepQueryParams.ts +125 -0
- package/src/tests/testErrors.ts +233 -0
- package/src/tests/testHandlers.ts +94 -0
- package/src/tests/testHeaderParams.ts +158 -0
- package/src/tests/testHeaders.ts +78 -0
- package/src/tests/testInheritanceController.ts +206 -0
- package/src/tests/testLocals.ts +53 -0
- package/src/tests/testLocation.ts +40 -0
- package/src/tests/testMiddlewares.ts +155 -0
- package/src/tests/testModule.ts +50 -0
- package/src/tests/testMulter.ts +158 -0
- package/src/tests/testPathParams.ts +127 -0
- package/src/tests/testQueryParams.ts +238 -0
- package/src/tests/testRedirect.ts +129 -0
- package/src/tests/testResponse.ts +533 -0
- package/src/tests/testResponseFilter.ts +106 -0
- package/src/tests/testRouting.ts +71 -0
- package/src/tests/testScopeRequest.ts +116 -0
- package/src/tests/testSession.ts +108 -0
- package/src/tests/testStatics.ts +63 -0
- package/src/tests/testStream.ts +62 -0
- package/src/tests/testView.ts +74 -0
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import "@tsed/ajv";
|
|
2
|
+
|
|
3
|
+
import {Controller} from "@tsed/di";
|
|
4
|
+
import {PlatformTest} from "@tsed/platform-http/testing";
|
|
5
|
+
import {BodyParams, Context, HeaderParams, RawBodyParams} from "@tsed/platform-params";
|
|
6
|
+
import {
|
|
7
|
+
Consumes,
|
|
8
|
+
Default,
|
|
9
|
+
Description,
|
|
10
|
+
GenericOf,
|
|
11
|
+
Generics,
|
|
12
|
+
Maximum,
|
|
13
|
+
Minimum,
|
|
14
|
+
Nullable,
|
|
15
|
+
Post,
|
|
16
|
+
Property,
|
|
17
|
+
Required,
|
|
18
|
+
Status
|
|
19
|
+
} from "@tsed/schema";
|
|
20
|
+
import SuperTest from "supertest";
|
|
21
|
+
import {afterAll, beforeAll, describe, expect, it} from "vitest";
|
|
22
|
+
|
|
23
|
+
import {PlatformTestingSdkOpts} from "../interfaces/index.js";
|
|
24
|
+
|
|
25
|
+
enum MyEnum {
|
|
26
|
+
TITLE,
|
|
27
|
+
AGE
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class NestedModel {
|
|
31
|
+
@Property()
|
|
32
|
+
id: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class NullModel {
|
|
36
|
+
@Property()
|
|
37
|
+
prop1: string;
|
|
38
|
+
|
|
39
|
+
@Property()
|
|
40
|
+
prop2: number;
|
|
41
|
+
|
|
42
|
+
@Property()
|
|
43
|
+
prop3: Date;
|
|
44
|
+
|
|
45
|
+
@Nullable(NestedModel)
|
|
46
|
+
prop4: NestedModel;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class FindQuery {
|
|
50
|
+
@Property()
|
|
51
|
+
a?: string;
|
|
52
|
+
|
|
53
|
+
@Property()
|
|
54
|
+
b?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Generics("T")
|
|
58
|
+
class PaginationQuery<T> {
|
|
59
|
+
// things about pagination
|
|
60
|
+
@Minimum(0)
|
|
61
|
+
@Default(0)
|
|
62
|
+
offset?: number;
|
|
63
|
+
|
|
64
|
+
@Minimum(1)
|
|
65
|
+
@Maximum(1000)
|
|
66
|
+
@Default(50)
|
|
67
|
+
limit?: number;
|
|
68
|
+
|
|
69
|
+
@Property("T")
|
|
70
|
+
where?: T;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
class Param1Type {
|
|
74
|
+
@Required()
|
|
75
|
+
value1!: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
class Param2Type {
|
|
79
|
+
@Required()
|
|
80
|
+
value2!: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@Controller("/body-params")
|
|
84
|
+
class TestBodyParamsCtrl {
|
|
85
|
+
@Post("/scenario-1")
|
|
86
|
+
@Status(201)
|
|
87
|
+
@Description("retrieve body and header content-type")
|
|
88
|
+
testScenario1(@HeaderParams("Content-type") contentType: string, @BodyParams() payload: any) {
|
|
89
|
+
return {payload, contentType};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@Post("/scenario-2")
|
|
93
|
+
@Description("Extract field from body payload as string[]")
|
|
94
|
+
testScenario2(@BodyParams("test") value: string[]): any {
|
|
95
|
+
return {value};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@Post("/scenario-3")
|
|
99
|
+
@Description("Extract body payload as string[]")
|
|
100
|
+
testScenario3(@BodyParams() value: string[]): any {
|
|
101
|
+
return {value};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@Post("/scenario-4")
|
|
105
|
+
@Description("Extract field from body payload as string[] with required annotation")
|
|
106
|
+
testScenario4(@Required() @BodyParams("test") value: string[]): any {
|
|
107
|
+
return {value};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@Post("/scenario-4b")
|
|
111
|
+
@Description("Extract field from body payload as string")
|
|
112
|
+
testScenario4b(@Required() @BodyParams("test") value: string): any {
|
|
113
|
+
return {value};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@Post("/scenario-4c")
|
|
117
|
+
@Description("Extract field from body payload as number with required annotation")
|
|
118
|
+
testScenario4c(@Required() @BodyParams("test") value: number): any {
|
|
119
|
+
return {value};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@Post("/scenario-5")
|
|
123
|
+
@Description("Extract raw body payload as Buffer")
|
|
124
|
+
testScenario5(@RawBodyParams() raw: Buffer, @BodyParams() payload: any, @Context() context: Context): any {
|
|
125
|
+
return {value: raw.toString("utf8")};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@Post("/scenario-6")
|
|
129
|
+
testScenario6(@BodyParams("type", String) type: keyof typeof MyEnum): any {
|
|
130
|
+
return {type};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@Post("/scenario-7")
|
|
134
|
+
testScenario7(@BodyParams("test") value: string): any {
|
|
135
|
+
return {value};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@Post("/scenario-8")
|
|
139
|
+
testScenario8(@BodyParams() model: NullModel) {
|
|
140
|
+
return {model};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@Post("/scenario-9")
|
|
144
|
+
testScenario9(@BodyParams() @GenericOf(FindQuery) q: PaginationQuery<FindQuery>) {
|
|
145
|
+
return {q};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@Post("/scenario-10")
|
|
149
|
+
testScenario10(
|
|
150
|
+
@Required() @BodyParams("param1", Param1Type) param1: Param1Type,
|
|
151
|
+
@Required() @BodyParams("param2", Param2Type) param2: Param2Type
|
|
152
|
+
) {
|
|
153
|
+
return {param1, param2};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@Post("/scenario-11")
|
|
157
|
+
@Consumes("application/x-www-form-urlencoded")
|
|
158
|
+
testScenario11(@Required() @BodyParams("client_id") client_id: string) {
|
|
159
|
+
return {client_id};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function testBodyParams(options: PlatformTestingSdkOpts) {
|
|
164
|
+
let request: SuperTest.Agent;
|
|
165
|
+
|
|
166
|
+
beforeAll(
|
|
167
|
+
PlatformTest.bootstrap(options.server, {
|
|
168
|
+
...options,
|
|
169
|
+
mount: {
|
|
170
|
+
"/rest": [TestBodyParamsCtrl]
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
);
|
|
174
|
+
beforeAll(() => {
|
|
175
|
+
request = SuperTest(PlatformTest.callback());
|
|
176
|
+
});
|
|
177
|
+
afterAll(PlatformTest.reset);
|
|
178
|
+
|
|
179
|
+
describe("Scenario 1: POST /rest/body-params/scenario-1", () => {
|
|
180
|
+
it("should return a 201 response", async () => {
|
|
181
|
+
const response = await request
|
|
182
|
+
.post("/rest/body-params/scenario-1")
|
|
183
|
+
.set({
|
|
184
|
+
"Content-Type": "application/json"
|
|
185
|
+
})
|
|
186
|
+
.send({
|
|
187
|
+
id: "id"
|
|
188
|
+
})
|
|
189
|
+
.expect(201);
|
|
190
|
+
|
|
191
|
+
expect(response.body).toEqual({
|
|
192
|
+
contentType: "application/json",
|
|
193
|
+
payload: {
|
|
194
|
+
id: "id"
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
describe("Scenario2: with expression Array<string>", () => {
|
|
200
|
+
it("should return value", async () => {
|
|
201
|
+
const response = await request
|
|
202
|
+
.post("/rest/body-params/scenario-2")
|
|
203
|
+
.send({
|
|
204
|
+
test: ["value"]
|
|
205
|
+
})
|
|
206
|
+
.expect(200);
|
|
207
|
+
|
|
208
|
+
expect(response.body).toEqual({value: ["value"]});
|
|
209
|
+
});
|
|
210
|
+
it("should return an empty array (1)", async () => {
|
|
211
|
+
const response = await request.post("/rest/body-params/scenario-2").send().expect(200);
|
|
212
|
+
|
|
213
|
+
expect(response.body).toEqual({});
|
|
214
|
+
});
|
|
215
|
+
it("should return an empty value (2)", async () => {
|
|
216
|
+
const response = await request.post("/rest/body-params/scenario-2").send({}).expect(200);
|
|
217
|
+
|
|
218
|
+
expect(response.body).toEqual({});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
describe("Scenario3: without expression Array<string>", () => {
|
|
222
|
+
it("should return value", async () => {
|
|
223
|
+
const response = await request.post("/rest/body-params/scenario-3").send(["value"]).expect(200);
|
|
224
|
+
|
|
225
|
+
expect(response.body).toEqual({value: ["value"]});
|
|
226
|
+
});
|
|
227
|
+
it("should return an empty array (1)", async () => {
|
|
228
|
+
const response = await request.post("/rest/body-params/scenario-3").send({}).expect(200);
|
|
229
|
+
|
|
230
|
+
expect(response.body).toEqual({value: [{}]});
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
describe("Scenario4: with expression required Array<string>", () => {
|
|
234
|
+
it("should return value", async () => {
|
|
235
|
+
const response = await request
|
|
236
|
+
.post("/rest/body-params/scenario-4")
|
|
237
|
+
.send({test: ["value"]})
|
|
238
|
+
.expect(200);
|
|
239
|
+
|
|
240
|
+
expect(response.body).toEqual({value: ["value"]});
|
|
241
|
+
});
|
|
242
|
+
it("should throw an exception", async () => {
|
|
243
|
+
const response = await request.post("/rest/body-params/scenario-4").send().expect(400);
|
|
244
|
+
|
|
245
|
+
expect(response.body).toEqual({
|
|
246
|
+
name: "REQUIRED_VALIDATION_ERROR",
|
|
247
|
+
message: "Bad request on parameter \"request.body.test\".\nIt should have required parameter 'test'",
|
|
248
|
+
status: 400,
|
|
249
|
+
errors: [
|
|
250
|
+
{
|
|
251
|
+
requestPath: "body",
|
|
252
|
+
dataPath: ".test",
|
|
253
|
+
keyword: "required",
|
|
254
|
+
message: "It should have required parameter 'test'",
|
|
255
|
+
modelName: "body",
|
|
256
|
+
params: {missingProperty: "test"},
|
|
257
|
+
schemaPath: "#/required"
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
describe("Scenario4b: with expression required String", () => {
|
|
264
|
+
it("should return value", async () => {
|
|
265
|
+
const response = await request.post("/rest/body-params/scenario-4b").send({test: "value"}).expect(200);
|
|
266
|
+
|
|
267
|
+
expect(response.body).toEqual({value: "value"});
|
|
268
|
+
});
|
|
269
|
+
it("should throw an exception when nothing is sent", async () => {
|
|
270
|
+
const response = await request.post("/rest/body-params/scenario-4b").send().expect(400);
|
|
271
|
+
|
|
272
|
+
expect(response.body).toEqual({
|
|
273
|
+
name: "REQUIRED_VALIDATION_ERROR",
|
|
274
|
+
message: "Bad request on parameter \"request.body.test\".\nIt should have required parameter 'test'",
|
|
275
|
+
status: 400,
|
|
276
|
+
errors: [
|
|
277
|
+
{
|
|
278
|
+
requestPath: "body",
|
|
279
|
+
dataPath: ".test",
|
|
280
|
+
keyword: "required",
|
|
281
|
+
message: "It should have required parameter 'test'",
|
|
282
|
+
modelName: "body",
|
|
283
|
+
params: {missingProperty: "test"},
|
|
284
|
+
schemaPath: "#/required"
|
|
285
|
+
}
|
|
286
|
+
]
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
it("should throw an exception when nothing is an empty string is sent", async () => {
|
|
290
|
+
const response = await request.post("/rest/body-params/scenario-4b").send({test: ""}).expect(400);
|
|
291
|
+
|
|
292
|
+
expect(response.body).toEqual({
|
|
293
|
+
name: "REQUIRED_VALIDATION_ERROR",
|
|
294
|
+
message: "Bad request on parameter \"request.body.test\".\nIt should have required parameter 'test'",
|
|
295
|
+
status: 400,
|
|
296
|
+
errors: [
|
|
297
|
+
{
|
|
298
|
+
dataPath: ".test",
|
|
299
|
+
requestPath: "body",
|
|
300
|
+
keyword: "required",
|
|
301
|
+
message: "It should have required parameter 'test'",
|
|
302
|
+
modelName: "body",
|
|
303
|
+
params: {missingProperty: "test"},
|
|
304
|
+
schemaPath: "#/required"
|
|
305
|
+
}
|
|
306
|
+
]
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
describe("Scenario4c: with expression required Number", () => {
|
|
311
|
+
it("should return value (with 1)", async () => {
|
|
312
|
+
const response = await request.post("/rest/body-params/scenario-4c").send({test: 1}).expect(200);
|
|
313
|
+
|
|
314
|
+
expect(response.body).toEqual({value: 1});
|
|
315
|
+
});
|
|
316
|
+
it("should return value (with 0)", async () => {
|
|
317
|
+
const response = await request.post("/rest/body-params/scenario-4c").send({test: 0}).expect(200);
|
|
318
|
+
|
|
319
|
+
expect(response.body).toEqual({value: 0});
|
|
320
|
+
});
|
|
321
|
+
it("should throw an exception when nothing is sent", async () => {
|
|
322
|
+
const response = await request.post("/rest/body-params/scenario-4b").send().expect(400);
|
|
323
|
+
|
|
324
|
+
expect(response.body).toEqual({
|
|
325
|
+
name: "REQUIRED_VALIDATION_ERROR",
|
|
326
|
+
message: "Bad request on parameter \"request.body.test\".\nIt should have required parameter 'test'",
|
|
327
|
+
status: 400,
|
|
328
|
+
errors: [
|
|
329
|
+
{
|
|
330
|
+
dataPath: ".test",
|
|
331
|
+
requestPath: "body",
|
|
332
|
+
keyword: "required",
|
|
333
|
+
message: "It should have required parameter 'test'",
|
|
334
|
+
modelName: "body",
|
|
335
|
+
params: {missingProperty: "test"},
|
|
336
|
+
schemaPath: "#/required"
|
|
337
|
+
}
|
|
338
|
+
]
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
describe("Scenario5: with raw payload", () => {
|
|
343
|
+
it("should return value", async () => {
|
|
344
|
+
const response = await request.post("/rest/body-params/scenario-5").send('{"test": ["value"]}').expect(200);
|
|
345
|
+
|
|
346
|
+
expect(response.body).toEqual({
|
|
347
|
+
value: '{"test": ["value"]}'
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
describe("Scenario6: Enum", () => {
|
|
352
|
+
it("should return value", async () => {
|
|
353
|
+
const response = await request.post("/rest/body-params/scenario-6").send({
|
|
354
|
+
type: "TITLE"
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
expect(response.body).toEqual({
|
|
358
|
+
type: "TITLE"
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
describe("Scenario7: payload with Null", () => {
|
|
363
|
+
it("should return value", async () => {
|
|
364
|
+
const response = await request.post("/rest/body-params/scenario-7").send({
|
|
365
|
+
test: null
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
expect(response.body).toEqual({
|
|
369
|
+
value: null
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
describe("Scenario8: payload with props to null", () => {
|
|
374
|
+
it("should return value with null value", async () => {
|
|
375
|
+
const response = await request.post("/rest/body-params/scenario-8").send({
|
|
376
|
+
prop1: null,
|
|
377
|
+
prop2: null,
|
|
378
|
+
prop3: null,
|
|
379
|
+
prop4: null
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
expect(response.body).toEqual({
|
|
383
|
+
model: {
|
|
384
|
+
prop1: null,
|
|
385
|
+
prop2: null,
|
|
386
|
+
prop3: null,
|
|
387
|
+
prop4: null
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
describe("Scenario9: payload with Generics", () => {
|
|
393
|
+
it("should return value", async () => {
|
|
394
|
+
const response = await request
|
|
395
|
+
.post("/rest/body-params/scenario-9")
|
|
396
|
+
.send({
|
|
397
|
+
offset: 0,
|
|
398
|
+
limit: 10,
|
|
399
|
+
where: {
|
|
400
|
+
a: "ca",
|
|
401
|
+
b: "cb"
|
|
402
|
+
}
|
|
403
|
+
})
|
|
404
|
+
.expect(200);
|
|
405
|
+
|
|
406
|
+
expect(response.body).toEqual({
|
|
407
|
+
q: {
|
|
408
|
+
limit: 10,
|
|
409
|
+
offset: 0,
|
|
410
|
+
where: {
|
|
411
|
+
a: "ca",
|
|
412
|
+
b: "cb"
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
it("should throw a bad request", async () => {
|
|
418
|
+
const response = await request
|
|
419
|
+
.post("/rest/body-params/scenario-9")
|
|
420
|
+
.send({
|
|
421
|
+
offset: 0,
|
|
422
|
+
limit: 0,
|
|
423
|
+
where: {
|
|
424
|
+
a: "ca",
|
|
425
|
+
b: "cb"
|
|
426
|
+
}
|
|
427
|
+
})
|
|
428
|
+
.expect(400);
|
|
429
|
+
|
|
430
|
+
expect(response.body).toEqual({
|
|
431
|
+
errors: [
|
|
432
|
+
{
|
|
433
|
+
data: 0,
|
|
434
|
+
requestPath: "body",
|
|
435
|
+
dataPath: ".limit",
|
|
436
|
+
instancePath: "/limit",
|
|
437
|
+
keyword: "minimum",
|
|
438
|
+
message: "must be >= 1",
|
|
439
|
+
modelName: "PaginationQuery",
|
|
440
|
+
params: {
|
|
441
|
+
comparison: ">=",
|
|
442
|
+
limit: 1
|
|
443
|
+
},
|
|
444
|
+
schemaPath: "#/properties/limit/minimum"
|
|
445
|
+
}
|
|
446
|
+
],
|
|
447
|
+
message: 'Bad request on parameter "request.body".\nPaginationQuery.limit must be >= 1. Given value: 0',
|
|
448
|
+
name: "AJV_VALIDATION_ERROR",
|
|
449
|
+
status: 400
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
describe("Scenario10: validate two payload", () => {
|
|
454
|
+
it("should throw a Bad request if body params is missing (1)", async () => {
|
|
455
|
+
await request
|
|
456
|
+
.post("/rest/body-params/scenario-10")
|
|
457
|
+
.send({param1: {}, param2: {value2: "value"}})
|
|
458
|
+
.expect(400);
|
|
459
|
+
});
|
|
460
|
+
it("should throw a Bad request if body params is missing (2)", async () => {
|
|
461
|
+
await request.post("/rest/body-params/scenario-10").send({param1: {}, param2: {}}).expect(400);
|
|
462
|
+
});
|
|
463
|
+
it("should throw a Bad request if body params is missing (3)", async () => {
|
|
464
|
+
await request
|
|
465
|
+
.post("/rest/body-params/scenario-10")
|
|
466
|
+
.send({param1: {value: "value"}, param2: {}})
|
|
467
|
+
.expect(400);
|
|
468
|
+
});
|
|
469
|
+
it("should throw a Bad request if body params is missing (4)", async () => {
|
|
470
|
+
await request.post("/rest/body-params/scenario-10").send({}).expect(400);
|
|
471
|
+
});
|
|
472
|
+
it("should validate the body params", async () => {
|
|
473
|
+
await request
|
|
474
|
+
.post("/rest/body-params/scenario-10")
|
|
475
|
+
.send({param1: {value1: "value"}, param2: {value2: "value"}})
|
|
476
|
+
.expect(200);
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
describe("Scenario11: validate application/x-www-form-urlencoded body", () => {
|
|
480
|
+
it("should validate the body params", async () => {
|
|
481
|
+
await request
|
|
482
|
+
.post("/rest/body-params/scenario-11")
|
|
483
|
+
.set("Content-Type", "application/x-www-form-urlencoded")
|
|
484
|
+
.send("client_id=id&grant_type=grant")
|
|
485
|
+
.expect(200);
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
}
|