|
8 | 8 | GenerateEnchantedLinkForTestResponse, |
9 | 9 | ProviderTokenResponse, |
10 | 10 | GenerateEmbeddedLinkResponse, |
11 | | - InviteBatchResponse, |
| 11 | + CreateOrInviteBatchResponse, |
12 | 12 | UserPasswordHashed, |
13 | 13 | } from './types'; |
14 | 14 |
|
@@ -385,7 +385,7 @@ describe('Management User', () => { |
385 | 385 | }, |
386 | 386 | }; |
387 | 387 |
|
388 | | - const resp: SdkResponse<InviteBatchResponse> = await management.user.inviteBatch( |
| 388 | + const resp: SdkResponse<CreateOrInviteBatchResponse> = await management.user.inviteBatch( |
389 | 389 | [ |
390 | 390 | { loginId: 'one', roles: ['r1'], email: 'one@one', password: 'clear', seed: 'aaa' }, |
391 | 391 | { loginId: 'two', roles: ['r1'], email: 'two@two', hashedPassword: hashed }, |
@@ -437,6 +437,74 @@ describe('Management User', () => { |
437 | 437 | }); |
438 | 438 | }); |
439 | 439 |
|
| 440 | + describe('create batch', () => { |
| 441 | + it('should send the correct request and receive correct response', async () => { |
| 442 | + const httpResponse = { |
| 443 | + ok: true, |
| 444 | + json: () => mockMgmtInviteBatchResponse, |
| 445 | + clone: () => ({ |
| 446 | + json: () => Promise.resolve(mockMgmtInviteBatchResponse), |
| 447 | + }), |
| 448 | + status: 200, |
| 449 | + }; |
| 450 | + mockHttpClient.post.mockResolvedValue(httpResponse); |
| 451 | + |
| 452 | + const hashed: UserPasswordHashed = { |
| 453 | + firebase: { |
| 454 | + hash: 'h', |
| 455 | + salt: 's', |
| 456 | + saltSeparator: 'ss', |
| 457 | + signerKey: 'sk', |
| 458 | + memory: 14, |
| 459 | + rounds: 8, |
| 460 | + }, |
| 461 | + }; |
| 462 | + |
| 463 | + const resp: SdkResponse<CreateOrInviteBatchResponse> = await management.user.createBatch([ |
| 464 | + { loginId: 'one', roles: ['r1'], email: 'one@one', password: 'clear', seed: 'aaa' }, |
| 465 | + { loginId: 'two', roles: ['r1'], email: 'two@two', hashedPassword: hashed }, |
| 466 | + ]); |
| 467 | + |
| 468 | + expect(mockHttpClient.post).toHaveBeenCalledWith( |
| 469 | + apiPaths.user.createBatch, |
| 470 | + { |
| 471 | + users: [ |
| 472 | + { |
| 473 | + loginId: 'one', |
| 474 | + roleNames: ['r1'], |
| 475 | + email: 'one@one', |
| 476 | + password: 'clear', |
| 477 | + seed: 'aaa', |
| 478 | + }, |
| 479 | + { |
| 480 | + loginId: 'two', |
| 481 | + roleNames: ['r1'], |
| 482 | + email: 'two@two', |
| 483 | + hashedPassword: { |
| 484 | + firebase: { |
| 485 | + hash: 'h', |
| 486 | + salt: 's', |
| 487 | + saltSeparator: 'ss', |
| 488 | + signerKey: 'sk', |
| 489 | + memory: 14, |
| 490 | + rounds: 8, |
| 491 | + }, |
| 492 | + }, |
| 493 | + }, |
| 494 | + ], |
| 495 | + }, |
| 496 | + { token: 'key' }, |
| 497 | + ); |
| 498 | + |
| 499 | + expect(resp).toEqual({ |
| 500 | + code: 200, |
| 501 | + data: mockMgmtInviteBatchResponse, |
| 502 | + ok: true, |
| 503 | + response: httpResponse, |
| 504 | + }); |
| 505 | + }); |
| 506 | + }); |
| 507 | + |
440 | 508 | describe('update', () => { |
441 | 509 | it('should send the correct request and receive correct response with multiple arguments', async () => { |
442 | 510 | const httpResponse = { |
|
0 commit comments