Skip to content

Commit e4cf95c

Browse files
committed
chore: update integration test readme's
1 parent 607df25 commit e4cf95c

File tree

3 files changed

+561
-31
lines changed
  • AmplifyPlugins/Auth/Tests
    • AuthHostApp/AuthIntegrationTests
    • AuthWebAuthnApp/AuthWebAuthnAppUITests

3 files changed

+561
-31
lines changed

AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/MFATests/EmailMFATests/README.md

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,14 @@ The following steps demonstrate how to setup the integration tests for auth plug
1010

1111
At the time this was written, it follows the steps from here https://docs.amplify.aws/gen2/deploy-and-host/fullstack-branching/mono-and-multi-repos/
1212

13-
1. From a new folder, run `npm create amplify@latest`. This uses the following versions of the Amplify CLI, see `package.json` file below.
14-
15-
```json
16-
{
17-
...
18-
"devDependencies": {
19-
"@aws-amplify/backend": "^0.15.0",
20-
"@aws-amplify/backend-cli": "^0.15.0",
21-
"aws-cdk": "^2.139.0",
22-
"aws-cdk-lib": "^2.139.0",
23-
"constructs": "^10.3.0",
24-
"esbuild": "^0.20.2",
25-
"tsx": "^4.7.3",
26-
"typescript": "^5.4.5"
27-
},
28-
"dependencies": {
29-
"aws-amplify": "^6.2.0"
30-
},
31-
}
32-
```
13+
1. From a new folder, run `npm create amplify@latest`. This will create a new amplify project with the latest version of the Amplify CLI.
3314

34-
2. Update `amplify/auth/resource.ts`. The resulting file should look like this
15+
2. Update `amplify/auth/resource.ts`. The resulting file should look like this. Replace `<your_verified_email>` with your verified email address.
3516

3617
```ts
37-
import { defineAuth, defineFunction } from "@aws-amplify/backend";
18+
import { defineAuth } from '@aws-amplify/backend';
19+
20+
const fromEmail = '<your_verified_email>';
3821

3922
/**
4023
* Define and configure your auth resource
@@ -73,6 +56,8 @@ export const auth = defineAuth({
7356
});
7457
```
7558

59+
3. Create a file `amplify/functions/cognito-triggers/pre-sign-up-handler.ts` with the following content
60+
7661
```ts
7762
import type { PreSignUpTriggerHandler } from "aws-lambda";
7863

@@ -92,7 +77,8 @@ export const handler: PreSignUpTriggerHandler = async (event) => {
9277
return event;
9378
};
9479
```
95-
Create a file `amplify/data/mfa/index.graphql` with the following content
80+
81+
4. Create a file `amplify/data/mfa/index.graphql` with the following content
9682

9783
```graphql
9884
# A Graphql Schema for creating Mfa info such as code and username.
@@ -123,7 +109,7 @@ type MfaInfo {
123109
}
124110
```
125111

126-
Update `amplify/data/mfa/index.ts`. The resulting file should look like this
112+
5. Update `amplify/data/mfa/index.ts`. The resulting file should look like this
127113

128114
```ts
129115
import { Duration, Expiration, RemovalPolicy, Stack } from "aws-cdk-lib";
@@ -311,9 +297,7 @@ cfnUserPool.addPropertyOverride("DeviceConfiguration", {
311297
});
312298
```
313299

314-
The triggers should look as follows:
315-
316-
Common
300+
6. Create a file `amplify/functions/cognito-triggers/common.ts` with the following content
317301

318302
```ts
319303
// Code adapted from:
@@ -390,7 +374,7 @@ export const decryptAndBroadcastCode = async (
390374
};
391375
```
392376

393-
custom-email-sender
377+
7. Create a file `amplify/functions/cognito-triggers/custom-email-sender.ts` with the following content
394378

395379
```ts
396380
import { CustomEmailSenderTriggerHandler } from "aws-lambda";
@@ -416,7 +400,8 @@ export const handler: CustomEmailSenderTriggerHandler = async (event) => {
416400
};
417401
```
418402

419-
custom-sms-sender
403+
8. Create a file `amplify/functions/cognito-triggers/custom-sms-sender.ts` with the following content
404+
420405

421406
```ts
422407
import { CustomSMSSenderTriggerHandler } from "aws-lambda";
@@ -439,15 +424,15 @@ export const handler: CustomSMSSenderTriggerHandler = async (event) => {
439424
};
440425
```
441426

442-
4. Deploy the backend with npx amplify sandbox
427+
9. Deploy the backend with npx amplify sandbox
443428

444429
For example, this deploys to a sandbox env and generates the amplify_outputs.json file.
445430

446431
```
447432
npx ampx sandbox --identifier mfa-req-email --outputs-out-dir amplify_outputs/mfa-req-email
448433
```
449434

450-
5. Copy the `amplify_outputs.json` file over to the test directory as `XYZ-amplify_outputs.json` (replace xyz with the name of the file your test is expecting). The tests will automatically pick this file up. Create the directories in this path first if it currently doesn't exist.
435+
10. Copy the `amplify_outputs.json` file over to the test directory as `XYZ-amplify_outputs.json` (replace xyz with the name of the file your test is expecting). The tests will automatically pick this file up. Create the directories in this path first if it currently doesn't exist.
451436

452437
```
453438
cp amplify_outputs.json ~/.aws-amplify/amplify-ios/testconfiguration/XYZ-amplify_outputs.json

0 commit comments

Comments
 (0)