Skip to content

Commit 556d982

Browse files
authored
test: Updated datastore Readme for integration test (#1755)
1 parent e9bedee commit 556d982

File tree

5 files changed

+173
-52
lines changed

5 files changed

+173
-52
lines changed

AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginAuthIntegrationTests/DefaultAuthCognito/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ m now)
2020
? Select the default resolution strategy Auto Merge
2121
? Here is the GraphQL API that we will create. Select a setting to edit or continue Continue
2222
? Choose a schema template: Blank Schema
23-
? Do you want to edit the schema now? `No`
23+
? Do you want to edit the schema now? `Yes`
2424
```
2525

2626
Copy the content of the schema from `AWSDataStoreCategoryPluginAuthIntegrationTests/DefaultAuthCognito/singleauth-cognito-schema.graphql` into the newly created `schema.graphql` file
@@ -36,6 +36,10 @@ Copy the content of the schema from `AWSDataStoreCategoryPluginAuthIntegrationTe
3636
```
3737

3838
5. Copy `amplifyconfiguration.json` to a new file named `AWSDataStoreCategoryPluginAuthIntegrationTests-amplifyconfiguration.json` inside `~/.aws-amplify/amplify-ios/testconfiguration/`
39+
```
40+
cp amplifyconfiguration.json ~/.aws-amplify/amplify-ios/testconfiguration/AWSDataStoreCategoryPluginAuthIntegrationTests-amplifyconfiguration.json
41+
```
42+
3943
6. Create `AWSDataStoreCategoryPluginAuthIntegrationTests-credentials.json` inside the same folder with a json object containing `user1`, and `password`, used to create the cognito user in the userpool. In step 2, the cognito userpool is configured to allow users to sign up with their email as the username.
4044

4145
```json

AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginAuthIntegrationTests/DefaultAuthIAM/README.md

Lines changed: 102 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,107 @@ Copy the content of the schema from `AWSDataStoreCategoryPluginAuthIntegrationTe
3232
? Please select from one of the below mentioned services: `GraphQL`
3333
? Select from the options below `Enable DataStore for entire API`
3434

35-
4. `amplify push`
35+
4. Add amplify auth
36+
37+
```
38+
amplify add auth
39+
40+
Do you want to use the default authentication and security configuration?
41+
Manual configuration
42+
Select the authentication/authorization services that you want to use:
43+
User Sign-Up, Sign-In, connected with AWS IAM controls (Enables ...)
44+
Please provide a friendly name for your resource that will be used to label this category in the project:
45+
<amplifyintegtest>
46+
Please enter a name for your identity pool.
47+
<amplifyintegtestCIDP>
48+
Allow unauthenticated logins? (Provides scoped down permissions that you can control via AWS IAM)
49+
Yes
50+
Do you want to enable 3rd party authentication providers in your identity pool?
51+
No
52+
Please provide a name for your user pool:
53+
<amplifyintegCUP>
54+
55+
How do you want users to be able to sign in?
56+
Username
57+
Do you want to add User Pool Groups?
58+
No
59+
Do you want to add an admin queries API?
60+
No
61+
Multifactor authentication (MFA) user login options:
62+
OFF
63+
64+
Email based user registration/forgot password:
65+
Enabled (Requires per-user email entry at registration)
66+
Please specify an email verification subject:
67+
Your verification code
68+
Please specify an email verification message:
69+
Your verification code is {####}
70+
Do you want to override the default password policy for this User Pool?
71+
No
72+
73+
What attributes are required for signing up?
74+
(Press Space to deselect Email, if selected, then press Enter with none selected)
75+
Specify the app's refresh token expiration period (in days):
76+
30
77+
Do you want to specify the user attributes this app can read and write?
78+
No
79+
Do you want to enable any of the following capabilities?
80+
(press Enter with none selected)
81+
Do you want to use an OAuth flow?
82+
No
83+
? Do you want to configure Lambda Triggers for Cognito?
84+
Yes
85+
? Which triggers do you want to enable for Cognito
86+
Custom Message
87+
Pre Sign-up
88+
[Choose as many that you would like to manually verify later]
89+
? What functionality do you want to use for Custom Message
90+
Create your own module
91+
? What functionality do you want to use for Pre Sign-up
92+
Create your own module
93+
Succesfully added the Lambda function locally
94+
? Do you want to edit your custom function now? Yes
95+
Please edit the file in your editor:
96+
```
97+
98+
For Pre Sign-up lambda
99+
100+
```
101+
exports.handler = (event) => {
102+
event.response.autoConfirmUser = true;
103+
};
104+
```
105+
106+
For Custom Message and any other lambdas
107+
108+
```
109+
// you can simply set them to log the input so you can verify valid and correct validationData/clientMetadata
110+
exports.handler = (event) => {
111+
console.log("Reached custom message lambda");
112+
};
113+
```
114+
115+
Continue in the terminal;
116+
117+
```
118+
? Press enter to continue
119+
Successfully added resource amplifyintegtest locally
120+
121+
ampl
122+
123+
5. `amplify push`
36124
```perl
37125
? Are you sure you want to continue? `Yes`
38126
? Do you want to generate code for your newly created GraphQL API `No`
39127
```
40128

41-
5. Copy `amplifyconfiguration.json` to a new file named `AWSDataStoreCategoryPluginAuthIAMIntegrationTests-amplifyconfiguration.json` inside `~/.aws-amplify/amplify-ios/testconfiguration/`
42-
6. Create `AWSDataStoreCategoryPluginAuthIAMIntegrationTests-credentials.json` inside the same folder with a json object containing `user1`, and `password`, used to create the cognito user in the userpool. In step 2, the cognito userpool is configured to allow users to sign up with their email as the username.
129+
6. Copy `amplifyconfiguration.json` to a new file named `AWSDataStoreCategoryPluginAuthIAMIntegrationTests-amplifyconfiguration.json` inside `~/.aws-amplify/amplify-ios/testconfiguration/`
130+
131+
```
132+
cp amplifyconfiguration.json ~/.aws-amplify/amplify-ios/testconfiguration/AWSDataStoreCategoryPluginAuthIAMIntegrationTests-amplifyconfiguration.json
133+
```
134+
135+
7. Create `AWSDataStoreCategoryPluginAuthIAMIntegrationTests-credentials.json` inside the same folder with a json object containing `user1`, and `password`, used to create the cognito user in the userpool. In step 2, the cognito userpool is configured to allow users to sign up with their email as the username.
43136

44137
```json
45138
{
@@ -53,22 +146,22 @@ Copy the content of the schema from `AWSDataStoreCategoryPluginAuthIntegrationTe
53146

54147
### Creating users through AWS Console
55148

56-
7. `amplify console auth`
149+
8. `amplify console auth`
57150
```perl
58151
? Which console `User Pool`
59152
```
60153

61-
8. Click on `Users and groups`, Sign up the two new users with the email and a temporary password.
154+
9. Click on `Users and groups`, Sign up the two new users with the email and a temporary password.
62155

63-
9. Click on App clients, and keep note of the app client web's `App client id`. This can be used the AWS AppSync console Queries.
156+
10. Click on App clients, and keep note of the app client web's `App client id`. This can be used the AWS AppSync console Queries.
64157

65-
10. `amplify console api`
158+
11. `amplify console api`
66159
Click on Queries tab, and click on Log in. This will prompt you to enter the app client id, username, and temporary password. After logging in successfully, it will ask you to enter a new password. Make sure those are the same as the one specified in the credentials json file from step 5. Do this for both users.
67-
11. Some test cases require IAM to allow guest access. To do so run `amplify update auth` and follow the instructions
160+
12. Some test cases require IAM to allow guest access. To do so run `amplify update auth` and follow the instructions
68161

69162
### Creating users through AWS CLI
70163

71-
7. Run the following commands
164+
8. Run the following commands
72165

73166
```
74167
aws cognito-idp admin-create-user --user-pool-id [POOL_ID] --username [USER EMAIL]

AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginAuthIntegrationTests/MultiAuth/README.md

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,74 @@
22

33
### Prerequisites
44
- AWS CLI
5+
- Version used: `amplify -v` => `8.0.1`
56

67
### Set-up
78

8-
1. create a `schema.graphql` file with the content of `MultiAuth/schema.graphql`
9+
1. `amplify init`
910

10-
2. `amplify init`
11+
2. `amplify add api`
1112

12-
3. `amplify add api` (when asked, provide **"datastoreintegtestmu"** as API name)
1313
```
14-
? Please select from one of the below mentioned services: `GraphQL`
15-
? Provide API name: `datastoreintegtestmu`
14+
? Select from one of the below mentioned services: `GraphQL`
15+
? Provide API name: <provide any name>
1616
? Choose the default authorization type for the API: `API key`
1717
? Enter a description for the API key:
1818
? After how many days from now the API key should expire (1-365): `365`
19-
? Do you want to configure advanced settings for the GraphQL API `Yes, I want to make some additional changes.`
19+
2020
? Configure additional auth types? `Yes`
2121
? Choose the additional authorization types you want to configure for the API: `Amazon Cognito User Pool`, `IAM`
22+
? Do you want to use the default authentication and security configuration? `Manual configuration`
23+
? Select the authentication/authorization services that you want to use: `User Sign-Up, Sign-In, connected with AWS IAM controls (Enables per-user Storage features for images or ot
24+
her content, Analytics, and more)`
25+
? Provide a friendly name for your resource that will be used to label this category in the project: <provide name>
26+
? Enter a name for your identity pool. <provide name>
27+
? Allow unauthenticated logins? (Provides scoped down permissions that you can control via AWS IAM) `Yes`
28+
? Do you want to enable 3rd party authentication providers in your identity pool? `No`
29+
? Provide a name for your user pool: <provide name>
30+
31+
? How do you want users to be able to sign in? `Username`
32+
? Do you want to add User Pool Groups? `No`
33+
? Do you want to add an admin queries API? `No`
34+
? Multifactor authentication (MFA) user login options: `OFF`
35+
? Email based user registration/forgot password: `Enabled (Requires per-user email entry at registration)`
36+
? Specify an email verification subject: `Your verification code`
37+
? Specify an email verification message: `Your verification code is {####}`
38+
? Do you want to override the default password policy for this User Pool? `No`
39+
40+
? What attributes are required for signing up? `Email`
41+
? Specify the app's refresh token expiration period (in days): `30`
42+
? Do you want to specify the user attributes this app can read and write? `No`
43+
? Do you want to enable any of the following capabilities? None
44+
? Do you want to use an OAuth flow? `No`
45+
? Do you want to configure Lambda Triggers for Cognito? `No`
46+
47+
48+
2249
? Enable conflict detection? `Yes`
2350
? Select the default resolution strategy Auto Merge
24-
? Do you have an annotated GraphQL schema? `Yes`
25-
? Provide your schema file path: `schema.graphql`
51+
? Choose a schema template: Blank Schema
52+
? Do you want to edit the schema now? (Y/n) 'Y'
53+
54+
Copy the contents from `MultiAuth/schema.graphql`
55+
2656
```
27-
4. `amplify push`
57+
58+
3. `amplify push`
59+
2860
```perl
2961
? Are you sure you want to continue? `Yes`
3062
? Do you want to generate code for your newly created GraphQL API `No`
3163
```
3264

33-
5. Copy `amplifyconfiguration.json` to a new file named `AWSDataStoreCategoryPluginMultiAuthIntegrationTests-amplifyconfiguration.json` inside `~/.aws-amplify/amplify-ios/testconfiguration/`
34-
6. Create `AWSDataStoreCategoryPluginMultiAuthIntegrationTests-credentials.json` inside the same folder with the following value
65+
4. Copy `amplifyconfiguration.json` to a new file named `AWSDataStoreCategoryPluginMultiAuthIntegrationTests-amplifyconfiguration.json` inside `~/.aws-amplify/amplify-ios/testconfiguration/`
66+
67+
```perl
68+
cp amplifyconfiguration.json ~/.aws-amplify/amplify-ios/testconfiguration/AWSDataStoreCategoryPluginMultiAuthIntegrationTests-amplifyconfiguration.json
69+
```
70+
71+
5. Create `AWSDataStoreCategoryPluginMultiAuthIntegrationTests-credentials.json` inside the same folder with the following value
72+
3573
```json
3674
{
3775
"user1": "<USER1_EMAIL>",
@@ -41,36 +79,16 @@
4179
}
4280
4381
```
44-
7. Replace `USER1_EMAIL`, `PASSWORD_1`, `USER2_EMAIL`, `PASSWORD_2` with values for test users
45-
8. Run the following commands to create the above users and set their passwords
82+
6. Replace `USER1_EMAIL`, `PASSWORD_1`, `USER2_EMAIL`, `PASSWORD_2` with values for test users
83+
84+
7. Run the following commands to create the above users and set their passwords
4685
4786
`aws cognito-idp admin-create-user --user-pool-id <USER_POOL_ID> --username USER1_EMAIL`
4887
`aws cognito-idp admin-set-user-password --user-pool-id <USER_POOL_ID> --username USER1_EMAIL --password PASSWORD_1 --permanent`
4988
5089
`aws cognito-idp admin-create-user --user-pool-id <USER_POOL_ID> --username USER2_EMAIL`
5190
`aws cognito-idp admin-set-user-password --user-pool-id <USER_POOL_ID> --username USER2_EMAIL --password PASSWORD_2 --permanent`
5291
53-
9. Create a `Admins` group in the `<USER_POOL_ID>` user pool
54-
10. Add `user1` to `Admins` group
55-
11. Some test cases require IAM to allow guest access. To do so run `amplify update auth` and follow the instructions
56-
```
57-
What do you want to do? `Walkthrough all the auth configurations`
58-
Select the authentication/authorization services that you want to use: `User Sign-Up, Sign-In, connected with AWS IAM controls (Enables per-user Storage features for images or other content, Analytics, a
59-
nd more)`
60-
Allow unauthenticated logins? (Provides scoped down permissions that you can control via AWS IAM) `Yes`
61-
Do you want to enable 3rd party authentication providers in your identity pool? `No`
62-
Do you want to add User Pool Groups? `No`
63-
Do you want to add an admin queries API? `No`
64-
Multifactor authentication (MFA) user login options: `OFF`
65-
Email based user registration/forgot password: `Enabled (Requires per-user email entry at registration)`
66-
Please specify an email verification subject: `Your verification code`
67-
Please specify an email verification message: `Your verification code is {####}`
68-
Do you want to override the default password policy for this User Pool? `No`
69-
Specify the app's refresh token expiration period (in days): `30`
70-
Do you want to specify the user attributes this app can read and write? `No`
71-
Do you want to enable any of the following capabilities?
72-
Do you want to use an OAuth flow? `No`
73-
? Do you want to configure Lambda Triggers for Cognito? `No`
74-
```
75-
Then `amplify push`
92+
8. Create a `Admins` group in the `<USER_POOL_ID>` user pool
7693
94+
9. Add `user1` to `Admins` group

AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginIntegrationTests/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ The following steps demonstrate how to set up DataStore with a conflict resoluti
1919
? Configure additional auth types? `No`
2020
? Configure conflict detection? `Yes`
2121
? Select the default resolution strategy `Auto Merge`
22-
? Do you have an annotated GraphQL schema? `Yes`
23-
? Provide your schema file path: `schema.graphql`
22+
? Choose a schema template: `Blank Schema`
23+
? Do you want to edit the schema now? Y
2424
```
2525
When asked to provide the schema, create the `schema.graphql` file
2626
```
@@ -236,9 +236,15 @@ type CustomerOrder @model
236236
}
237237
238238
```
239-
3. `amplify push`
239+
3. If you are using the latest CLI, update cli.json to include `"useExperimentalPipelinedTransformer": false` to ensure that it will use the v1 transformer.
240240

241-
4. Copy `amplifyconfiguration.json` to a new file named `AWSDataStoreCategoryPluginIntegrationTests-amplifyconfiguration.json` inside `~/.aws-amplify/amplify-ios/testconfiguration/`
241+
4. `amplify push`
242+
243+
5. Copy `amplifyconfiguration.json` to a new file named `AWSDataStoreCategoryPluginIntegrationTests-amplifyconfiguration.json` inside `~/.aws-amplify/amplify-ios/testconfiguration/`
244+
245+
```
246+
cp amplifyconfiguration.json ~/.aws-amplify/amplify-ios/testconfiguration/AWSDataStoreCategoryPluginIntegrationTests-amplifyconfiguration.json
247+
```
242248

243249

244250
You should now be able to run all of the tests

AmplifyPlugins/DataStore/DataStoreCategoryPlugin.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,9 +891,9 @@
891891
2149E5E42388692E00873955 /* AWSDataStoreCategoryPluginTests */,
892892
2149E61E23886CEE00873955 /* AWSDataStoreCategoryPluginIntegrationTests */,
893893
21233DDE2475935600039337 /* AWSDataStoreCategoryPluginAuthIntegrationTests */,
894+
9C0CA4EF2748705F001C70CD /* AWSDataStoreCategoryPluginFlutterIntegrationTests */,
894895
2149E60623886C7B00873955 /* HostApp */,
895896
9B5889A231ECAD33B03B5DF6 /* Pods */,
896-
9C0CA4EF2748705F001C70CD /* AWSDataStoreCategoryPluginFlutterIntegrationTests */,
897897
2149E59C238867E100873955 /* Products */,
898898
FA9C743C238CB493009DAFCF /* Recovered References */,
899899
B158D86B8144CD1BD9589BA7 /* Frameworks */,
@@ -1893,8 +1893,8 @@
18931893
2149E5E22388692E00873955 /* AWSDataStoreCategoryPluginTests */,
18941894
2149E61C23886CEE00873955 /* AWSDataStoreCategoryPluginIntegrationTests */,
18951895
21233DDC2475935600039337 /* AWSDataStoreCategoryPluginAuthIntegrationTests */,
1896-
2149E60423886C7B00873955 /* HostApp */,
18971896
9C0CA4ED2748705F001C70CD /* AWSDataStoreCategoryPluginFlutterIntegrationTests */,
1897+
2149E60423886C7B00873955 /* HostApp */,
18981898
);
18991899
};
19001900
/* End PBXProject section */

0 commit comments

Comments
 (0)