@friggframework/schemas 2.0.0-next.78 → 2.0.0-next.80
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/index.js +232 -5
- package/middleware/__tests__/schema-validation.test.js +508 -0
- package/middleware/schema-validation.js +388 -0
- package/mocks/README.md +280 -0
- package/mocks/__tests__/authorization-mocks.test.js +311 -0
- package/mocks/authorization-mocks.js +339 -0
- package/package.json +4 -2
- package/schemas/api-authorization.schema.json +302 -0
- package/schemas/api-credentials.schema.json +176 -0
- package/schemas/api-entities.schema.json +292 -0
- package/schemas/api-proxy.schema.json +251 -0
- package/schemas/app-definition.schema.json +19 -0
- package/schemas/core-models.schema.json +16 -16
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for schema validation middleware
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
validateBody,
|
|
7
|
+
validateQuery,
|
|
8
|
+
validateParams,
|
|
9
|
+
validateResponse,
|
|
10
|
+
validate,
|
|
11
|
+
validateData,
|
|
12
|
+
SchemaRefs,
|
|
13
|
+
SchemaValidationError,
|
|
14
|
+
formatValidationErrors
|
|
15
|
+
} = require('../schema-validation');
|
|
16
|
+
|
|
17
|
+
// Mock Express request/response/next
|
|
18
|
+
function createMockReq(overrides = {}) {
|
|
19
|
+
return {
|
|
20
|
+
body: {},
|
|
21
|
+
query: {},
|
|
22
|
+
params: {},
|
|
23
|
+
method: 'GET',
|
|
24
|
+
path: '/test',
|
|
25
|
+
...overrides
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function createMockRes() {
|
|
30
|
+
const res = {
|
|
31
|
+
statusCode: 200,
|
|
32
|
+
_data: null,
|
|
33
|
+
status(code) {
|
|
34
|
+
this.statusCode = code;
|
|
35
|
+
return this;
|
|
36
|
+
},
|
|
37
|
+
json(data) {
|
|
38
|
+
this._data = data;
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function createMockNext() {
|
|
46
|
+
const next = jest.fn();
|
|
47
|
+
return next;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
describe('Schema Validation Middleware', () => {
|
|
51
|
+
describe('SchemaValidationError', () => {
|
|
52
|
+
it('should create error with correct properties', () => {
|
|
53
|
+
const errors = [{ instancePath: '/name', message: 'must be string' }];
|
|
54
|
+
const error = new SchemaValidationError('Test error', errors, 'body');
|
|
55
|
+
|
|
56
|
+
expect(error.name).toBe('SchemaValidationError');
|
|
57
|
+
expect(error.message).toBe('Test error');
|
|
58
|
+
expect(error.errors).toBe(errors);
|
|
59
|
+
expect(error.location).toBe('body');
|
|
60
|
+
expect(error.statusCode).toBe(400);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should have 500 status for response validation', () => {
|
|
64
|
+
const error = new SchemaValidationError('Response error', [], 'response');
|
|
65
|
+
expect(error.statusCode).toBe(500);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should serialize to JSON correctly', () => {
|
|
69
|
+
const errors = [{ instancePath: '/id', message: 'must be string', params: { type: 'string' } }];
|
|
70
|
+
const error = new SchemaValidationError('Validation failed', errors, 'body');
|
|
71
|
+
const json = error.toJSON();
|
|
72
|
+
|
|
73
|
+
expect(json.error).toBe('ValidationError');
|
|
74
|
+
expect(json.location).toBe('body');
|
|
75
|
+
expect(json.details).toHaveLength(1);
|
|
76
|
+
expect(json.details[0].path).toBe('/id');
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('formatValidationErrors', () => {
|
|
81
|
+
it('should format errors into readable string', () => {
|
|
82
|
+
const errors = [
|
|
83
|
+
{ instancePath: '/name', message: 'must be string' },
|
|
84
|
+
{ instancePath: '/age', message: 'must be integer' }
|
|
85
|
+
];
|
|
86
|
+
const formatted = formatValidationErrors(errors);
|
|
87
|
+
|
|
88
|
+
expect(formatted).toContain('/name: must be string');
|
|
89
|
+
expect(formatted).toContain('/age: must be integer');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should include allowed values when present', () => {
|
|
93
|
+
const errors = [{
|
|
94
|
+
instancePath: '/status',
|
|
95
|
+
message: 'must be equal to one of the allowed values',
|
|
96
|
+
params: { allowedValues: ['active', 'inactive'] }
|
|
97
|
+
}];
|
|
98
|
+
const formatted = formatValidationErrors(errors);
|
|
99
|
+
|
|
100
|
+
expect(formatted).toContain('allowed: active, inactive');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should handle empty errors array', () => {
|
|
104
|
+
expect(formatValidationErrors([])).toBe('Unknown validation error');
|
|
105
|
+
expect(formatValidationErrors(null)).toBe('Unknown validation error');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('validateBody', () => {
|
|
110
|
+
it('should pass valid entity body', () => {
|
|
111
|
+
const middleware = validateBody(SchemaRefs.entity);
|
|
112
|
+
const req = createMockReq({
|
|
113
|
+
body: {
|
|
114
|
+
id: '507f1f77bcf86cd799439011',
|
|
115
|
+
type: 'hubspot',
|
|
116
|
+
credentialId: '507f1f77bcf86cd799439012',
|
|
117
|
+
userId: '507f1f77bcf86cd799439013',
|
|
118
|
+
externalId: 'contact_123'
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const res = createMockRes();
|
|
122
|
+
const next = createMockNext();
|
|
123
|
+
|
|
124
|
+
middleware(req, res, next);
|
|
125
|
+
|
|
126
|
+
expect(next).toHaveBeenCalled();
|
|
127
|
+
expect(res.statusCode).toBe(200);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should reject invalid entity body in strict mode', () => {
|
|
131
|
+
const middleware = validateBody(SchemaRefs.entity);
|
|
132
|
+
const req = createMockReq({
|
|
133
|
+
body: {
|
|
134
|
+
id: 123, // Should be string
|
|
135
|
+
type: 'hubspot'
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const res = createMockRes();
|
|
139
|
+
const next = createMockNext();
|
|
140
|
+
|
|
141
|
+
middleware(req, res, next);
|
|
142
|
+
|
|
143
|
+
expect(next).not.toHaveBeenCalled();
|
|
144
|
+
expect(res.statusCode).toBe(400);
|
|
145
|
+
expect(res._data.error).toBe('ValidationError');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('should allow invalid body in non-strict mode', () => {
|
|
149
|
+
const middleware = validateBody(SchemaRefs.entity, { strict: false });
|
|
150
|
+
const req = createMockReq({
|
|
151
|
+
body: {
|
|
152
|
+
id: 123 // Invalid
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
const res = createMockRes();
|
|
156
|
+
const next = createMockNext();
|
|
157
|
+
|
|
158
|
+
middleware(req, res, next);
|
|
159
|
+
|
|
160
|
+
expect(next).toHaveBeenCalled();
|
|
161
|
+
expect(req.validationErrors).toBeDefined();
|
|
162
|
+
expect(req.validationErrors.body).toBeDefined();
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe('validateQuery', () => {
|
|
167
|
+
it('should pass valid query parameters', () => {
|
|
168
|
+
const middleware = validateQuery(SchemaRefs.createEntityRequest);
|
|
169
|
+
const req = createMockReq({
|
|
170
|
+
query: {
|
|
171
|
+
entityType: 'hubspot',
|
|
172
|
+
data: { credential_id: 'cred123' }
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
const res = createMockRes();
|
|
176
|
+
const next = createMockNext();
|
|
177
|
+
|
|
178
|
+
middleware(req, res, next);
|
|
179
|
+
|
|
180
|
+
expect(next).toHaveBeenCalled();
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe('validateResponse', () => {
|
|
185
|
+
it('should allow valid response', () => {
|
|
186
|
+
const middleware = validateResponse(SchemaRefs.listEntitiesResponse, { strict: false });
|
|
187
|
+
const req = createMockReq();
|
|
188
|
+
const res = createMockRes();
|
|
189
|
+
const next = createMockNext();
|
|
190
|
+
|
|
191
|
+
middleware(req, res, next);
|
|
192
|
+
|
|
193
|
+
// Call json with valid data
|
|
194
|
+
res.json({
|
|
195
|
+
entities: [{
|
|
196
|
+
id: '507f1f77bcf86cd799439011',
|
|
197
|
+
type: 'hubspot',
|
|
198
|
+
credentialId: '507f1f77bcf86cd799439012',
|
|
199
|
+
userId: '507f1f77bcf86cd799439013',
|
|
200
|
+
externalId: 'contact_123'
|
|
201
|
+
}]
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
expect(res._data.entities).toHaveLength(1);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('should log errors for invalid response in non-strict mode', () => {
|
|
208
|
+
const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
209
|
+
const middleware = validateResponse(SchemaRefs.listEntitiesResponse, {
|
|
210
|
+
strict: false,
|
|
211
|
+
logErrors: true
|
|
212
|
+
});
|
|
213
|
+
const req = createMockReq();
|
|
214
|
+
const res = createMockRes();
|
|
215
|
+
const next = createMockNext();
|
|
216
|
+
|
|
217
|
+
middleware(req, res, next);
|
|
218
|
+
|
|
219
|
+
// Call json with invalid data
|
|
220
|
+
res.json({
|
|
221
|
+
entities: 'not an array' // Invalid
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
expect(consoleSpy).toHaveBeenCalled();
|
|
225
|
+
consoleSpy.mockRestore();
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
describe('validate (combined)', () => {
|
|
230
|
+
it('should create multiple middlewares from config', () => {
|
|
231
|
+
const middlewares = validate({
|
|
232
|
+
body: SchemaRefs.createEntityRequest,
|
|
233
|
+
response: SchemaRefs.createEntityResponse
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
expect(middlewares).toHaveLength(2);
|
|
237
|
+
expect(typeof middlewares[0]).toBe('function');
|
|
238
|
+
expect(typeof middlewares[1]).toBe('function');
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('should create empty array for empty config', () => {
|
|
242
|
+
const middlewares = validate({});
|
|
243
|
+
expect(middlewares).toHaveLength(0);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
describe('validateData (direct validation)', () => {
|
|
248
|
+
it('should validate entity data', () => {
|
|
249
|
+
const result = validateData('entity', {
|
|
250
|
+
id: '507f1f77bcf86cd799439011',
|
|
251
|
+
type: 'hubspot',
|
|
252
|
+
credentialId: '507f1f77bcf86cd799439012',
|
|
253
|
+
userId: '507f1f77bcf86cd799439013',
|
|
254
|
+
externalId: 'contact_123'
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
expect(result.valid).toBe(true);
|
|
258
|
+
expect(result.errors).toBeNull();
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('should return errors for invalid data', () => {
|
|
262
|
+
const result = validateData('entity', {
|
|
263
|
+
id: 123 // Should be string
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
expect(result.valid).toBe(false);
|
|
267
|
+
expect(result.errors).toBeDefined();
|
|
268
|
+
expect(result.formatted).toBeDefined();
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it('should throw for unknown schema name', () => {
|
|
272
|
+
expect(() => validateData('unknown_schema', {})).toThrow('Unknown schema name');
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
describe('SchemaRefs', () => {
|
|
277
|
+
it('should have all expected entity refs', () => {
|
|
278
|
+
expect(SchemaRefs.entity).toBe('api-entities#/definitions/entity');
|
|
279
|
+
expect(SchemaRefs.listEntitiesResponse).toBe('api-entities#/definitions/listEntitiesResponse');
|
|
280
|
+
expect(SchemaRefs.createEntityRequest).toBe('api-entities#/definitions/createEntityRequest');
|
|
281
|
+
expect(SchemaRefs.createEntityResponse).toBe('api-entities#/definitions/createEntityResponse');
|
|
282
|
+
expect(SchemaRefs.entityType).toBe('api-entities#/definitions/entityType');
|
|
283
|
+
expect(SchemaRefs.reauthorizeEntityRequest).toBe('api-entities#/definitions/reauthorizeEntityRequest');
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('should have all expected credential refs', () => {
|
|
287
|
+
expect(SchemaRefs.credential).toBe('api-credentials#/definitions/credential');
|
|
288
|
+
expect(SchemaRefs.listCredentialsResponse).toBe('api-credentials#/definitions/listCredentialsResponse');
|
|
289
|
+
expect(SchemaRefs.reauthorizeCredentialRequest).toBe('api-credentials#/definitions/reauthorizeCredentialRequest');
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('should have all expected proxy refs', () => {
|
|
293
|
+
expect(SchemaRefs.proxyRequest).toBe('api-proxy#/definitions/proxyRequest');
|
|
294
|
+
expect(SchemaRefs.proxyResponse).toBe('api-proxy#/definitions/proxyResponse');
|
|
295
|
+
expect(SchemaRefs.proxyResponseUnion).toBe('api-proxy#/definitions/proxyResponseUnion');
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('should have all expected authorization refs', () => {
|
|
299
|
+
expect(SchemaRefs.authorizationRequirements).toBe('api-authorization#/definitions/authorizationRequirements');
|
|
300
|
+
expect(SchemaRefs.authorizationRequest).toBe('api-authorization#/definitions/authorizationRequest');
|
|
301
|
+
expect(SchemaRefs.authorizationResponse).toBe('api-authorization#/definitions/authorizationResponse');
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
describe('API Response Validation', () => {
|
|
307
|
+
describe('Entities API', () => {
|
|
308
|
+
it('should validate listEntitiesResponse', () => {
|
|
309
|
+
const result = validateData('listEntitiesResponse', {
|
|
310
|
+
entities: [{
|
|
311
|
+
id: '507f1f77bcf86cd799439011',
|
|
312
|
+
type: 'hubspot',
|
|
313
|
+
credentialId: '507f1f77bcf86cd799439012',
|
|
314
|
+
userId: '507f1f77bcf86cd799439013',
|
|
315
|
+
externalId: 'contact_123',
|
|
316
|
+
name: 'Test Entity',
|
|
317
|
+
authIsValid: true,
|
|
318
|
+
createdAt: '2024-01-01T00:00:00Z',
|
|
319
|
+
updatedAt: '2024-01-01T00:00:00Z'
|
|
320
|
+
}]
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
expect(result.valid).toBe(true);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it('should validate createEntityRequest', () => {
|
|
327
|
+
const result = validateData('createEntityRequest', {
|
|
328
|
+
entityType: 'hubspot',
|
|
329
|
+
data: {
|
|
330
|
+
credential_id: '507f1f77bcf86cd799439012'
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
expect(result.valid).toBe(true);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('should validate reauthorizeEntityResponse with success', () => {
|
|
338
|
+
const result = validateData('reauthorizeEntityResponse', {
|
|
339
|
+
success: true,
|
|
340
|
+
credential_id: '507f1f77bcf86cd799439012',
|
|
341
|
+
entity_id: '507f1f77bcf86cd799439011',
|
|
342
|
+
authIsValid: true
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
expect(result.valid).toBe(true);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it('should validate reauthorizeEntityResponse with next step', () => {
|
|
349
|
+
const result = validateData('reauthorizeEntityResponse', {
|
|
350
|
+
step: 2,
|
|
351
|
+
totalSteps: 3,
|
|
352
|
+
sessionId: 'session_123',
|
|
353
|
+
requirements: {
|
|
354
|
+
type: 'form',
|
|
355
|
+
fields: ['workspace_id']
|
|
356
|
+
},
|
|
357
|
+
message: 'Please select your workspace'
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
expect(result.valid).toBe(true);
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
describe('Credentials API', () => {
|
|
365
|
+
it('should validate credential', () => {
|
|
366
|
+
const result = validateData('credential', {
|
|
367
|
+
id: '507f1f77bcf86cd799439012',
|
|
368
|
+
type: 'hubspot',
|
|
369
|
+
userId: '507f1f77bcf86cd799439013',
|
|
370
|
+
externalId: 'hub_123',
|
|
371
|
+
authIsValid: true,
|
|
372
|
+
entityCount: 2,
|
|
373
|
+
createdAt: '2024-01-01T00:00:00Z',
|
|
374
|
+
updatedAt: '2024-01-01T00:00:00Z'
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
expect(result.valid).toBe(true);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it('should validate listCredentialsResponse', () => {
|
|
381
|
+
const result = validateData('listCredentialsResponse', {
|
|
382
|
+
credentials: [{
|
|
383
|
+
id: '507f1f77bcf86cd799439012',
|
|
384
|
+
type: 'hubspot',
|
|
385
|
+
userId: '507f1f77bcf86cd799439013',
|
|
386
|
+
externalId: 'hub_123',
|
|
387
|
+
authIsValid: true
|
|
388
|
+
}]
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
expect(result.valid).toBe(true);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it('should validate reauthorizeCredentialRequest', () => {
|
|
395
|
+
const result = validateData('reauthorizeCredentialRequest', {
|
|
396
|
+
data: {
|
|
397
|
+
code: 'auth_code_123',
|
|
398
|
+
state: 'state_123'
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
expect(result.valid).toBe(true);
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
describe('Proxy API', () => {
|
|
407
|
+
it('should validate proxyRequest', () => {
|
|
408
|
+
const result = validateData('proxyRequest', {
|
|
409
|
+
method: 'GET',
|
|
410
|
+
path: '/api/v1/contacts'
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
expect(result.valid).toBe(true);
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
it('should validate proxyRequest with body', () => {
|
|
417
|
+
const result = validateData('proxyRequest', {
|
|
418
|
+
method: 'POST',
|
|
419
|
+
path: '/api/v1/contacts',
|
|
420
|
+
body: {
|
|
421
|
+
name: 'Test Contact',
|
|
422
|
+
email: 'test@example.com'
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
expect(result.valid).toBe(true);
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
it('should validate proxyRequest with headers and query', () => {
|
|
430
|
+
const result = validateData('proxyRequest', {
|
|
431
|
+
method: 'GET',
|
|
432
|
+
path: '/api/v1/contacts',
|
|
433
|
+
headers: {
|
|
434
|
+
'Accept': 'application/json'
|
|
435
|
+
},
|
|
436
|
+
query: {
|
|
437
|
+
limit: '10'
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
expect(result.valid).toBe(true);
|
|
442
|
+
});
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
describe('Authorization API', () => {
|
|
446
|
+
it('should validate authorizationRequirements', () => {
|
|
447
|
+
const result = validateData('authorizationRequirements', {
|
|
448
|
+
type: 'oauth2',
|
|
449
|
+
step: 1,
|
|
450
|
+
totalSteps: 1,
|
|
451
|
+
isMultiStep: false,
|
|
452
|
+
data: {
|
|
453
|
+
url: 'https://auth.example.com/oauth/authorize',
|
|
454
|
+
scopes: ['read', 'write']
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
expect(result.valid).toBe(true);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it('should validate authorizationRequest', () => {
|
|
462
|
+
const result = validateData('authorizationRequest', {
|
|
463
|
+
entityType: 'hubspot',
|
|
464
|
+
data: {
|
|
465
|
+
code: 'auth_code_123',
|
|
466
|
+
state: 'state_123'
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
expect(result.valid).toBe(true);
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
it('should validate authorizationResponse with success', () => {
|
|
474
|
+
const result = validateData('authorizationResponse', {
|
|
475
|
+
entity_id: '507f1f77bcf86cd799439011',
|
|
476
|
+
credential_id: '507f1f77bcf86cd799439012',
|
|
477
|
+
type: 'hubspot',
|
|
478
|
+
display: 'HubSpot Account'
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
expect(result.valid).toBe(true);
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it('should validate authorizationResponse with next step', () => {
|
|
485
|
+
const result = validateData('authorizationResponse', {
|
|
486
|
+
nextStep: 2,
|
|
487
|
+
sessionId: 'session_123',
|
|
488
|
+
requirements: {
|
|
489
|
+
type: 'form',
|
|
490
|
+
step: 2,
|
|
491
|
+
totalSteps: 2,
|
|
492
|
+
isMultiStep: true,
|
|
493
|
+
data: {
|
|
494
|
+
jsonSchema: {
|
|
495
|
+
type: 'object',
|
|
496
|
+
properties: {
|
|
497
|
+
workspace_id: { type: 'string' }
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
message: 'Please select your workspace'
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
expect(result.valid).toBe(true);
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
});
|