Skip to content

Commit bfea93a

Browse files
author
Vieltojarvi
committed
updated some tests
1 parent 9949198 commit bfea93a

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

packages/seed/src/auth-seed/auth_client.test.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
UsernameExistsException,
1414
} from '@aws-sdk/client-cognito-identity-provider';
1515
import * as auth from 'aws-amplify/auth';
16-
import { AuthSignUp, AuthUser } from '../types.js';
16+
import { AuthOutputs, AuthSignUp, AuthUser } from '../types.js';
1717
import { MfaFlow } from './mfa_flow.js';
1818
import { PersistentPasswordFlow } from './persistent_password_flow.js';
1919

@@ -194,7 +194,7 @@ void describe('seeding auth APIs', () => {
194194
});
195195

196196
void it('creates and signs up user', async () => {
197-
await authClient.createAndSignUpUser({
197+
const output = await authClient.createAndSignUpUser({
198198
username: testUsername,
199199
password: testPassword,
200200
signInAfterCreation: true,
@@ -206,6 +206,10 @@ void describe('seeding auth APIs', () => {
206206
1,
207207
);
208208
assert.strictEqual(mockCognitoIdProviderClient.send.mock.callCount(), 1);
209+
assert.deepStrictEqual(output, {
210+
signInFlow: 'Password',
211+
username: testUsername,
212+
} as AuthOutputs);
209213
});
210214

211215
void it('throws error if attempting to create user that already exists', async () => {
@@ -242,7 +246,7 @@ void describe('seeding auth APIs', () => {
242246
const expectedErr = new AmplifyUserError('NotAuthorizedError', {
243247
message: 'You are not authorized to create a user',
244248
resolution:
245-
'Run npx ampx sandbox seed generate-policy and attach the outputted policy to yourself',
249+
'Run npx ampx sandbox seed generate-policy, attach the outputted policy template to a role with AmplifyBackendDeployFullAccess, assume that role to run seed',
246250
});
247251

248252
mockCognitoIdProviderClient.send.mock.mockImplementationOnce(() => {
@@ -362,7 +366,7 @@ void describe('seeding auth APIs', () => {
362366
});
363367

364368
void it('creates a user with MFA', async () => {
365-
await authClient.createAndSignUpUser({
369+
const output = await authClient.createAndSignUpUser({
366370
username: testUsername,
367371
password: testPassword,
368372
signInAfterCreation: true,
@@ -374,16 +378,21 @@ void describe('seeding auth APIs', () => {
374378

375379
assert.strictEqual(mockMfaFlow.mfaSignUp.mock.callCount(), 1);
376380
assert.strictEqual(mockCognitoIdProviderClient.send.mock.callCount(), 1);
381+
assert.deepStrictEqual(output, {
382+
signInFlow: 'MFA',
383+
username: testUsername,
384+
} as AuthOutputs);
377385
});
378386

379387
void it('signs in a user with MFA', async () => {
380-
await authClient.signInUser({
388+
const output = await authClient.signInUser({
381389
username: testUsername,
382390
password: testPassword,
383391
signInFlow: 'MFA',
384392
});
385393

386394
assert.strictEqual(mockMfaFlow.mfaSignIn.mock.callCount(), 1);
395+
assert.strictEqual(output, true);
387396
});
388397
});
389398
});

packages/seed/src/auth-seed/auth_client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class AuthClient {
6868
{
6969
message: 'You are not authorized to create a user',
7070
resolution:
71-
'Run npx ampx sandbox seed generate-policy and attach the outputted policy to yourself',
71+
'Run npx ampx sandbox seed generate-policy, attach the outputted policy template to a role with AmplifyBackendDeployFullAccess, assume that role to run seed',
7272
},
7373
error,
7474
);

0 commit comments

Comments
 (0)