diff --git a/.circleci/config.yml b/.circleci/config.yml index bdcb1419f44..311dcfe306a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -769,6 +769,14 @@ jobs: when: always - store_artifacts: path: ../uitest_android_results + amplify-configure-amplify_e2e_tests: + working_directory: ~/repo + docker: *ref_0 + resource_class: large + steps: *ref_1 + environment: + TEST_SUITE: src/__tests__/amplify-configure.test.ts + CLI_REGION: us-east-2 api_1-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -776,7 +784,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/api_1.test.ts - CLI_REGION: us-east-2 + CLI_REGION: us-west-2 api_2-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -784,7 +792,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/api_2.test.ts - CLI_REGION: us-west-2 + CLI_REGION: eu-west-2 auth_1-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -792,7 +800,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/auth_1.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: eu-central-1 auth_2-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -800,7 +808,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/auth_2.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: ap-northeast-1 env-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -808,7 +816,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/env.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: ap-southeast-1 function_1-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -816,7 +824,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/function_1.test.ts - CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-2 function_2-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -824,7 +832,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/function_2.test.ts - CLI_REGION: ap-southeast-2 + CLI_REGION: us-east-2 init-special-case-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -832,7 +840,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/init-special-case.test.ts - CLI_REGION: us-east-2 + CLI_REGION: us-west-2 layer-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -840,7 +848,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/layer.test.ts - CLI_REGION: us-west-2 + CLI_REGION: eu-west-2 schema-auth-1-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -848,7 +856,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-1.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: eu-central-1 schema-auth-2-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -856,7 +864,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-2.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: ap-northeast-1 schema-auth-3-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -864,7 +872,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-3.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: ap-southeast-1 schema-auth-4-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -872,7 +880,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-4.test.ts - CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-2 schema-auth-5-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -880,7 +888,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-5.test.ts - CLI_REGION: ap-southeast-2 + CLI_REGION: us-east-2 schema-auth-6-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -888,7 +896,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-6.test.ts - CLI_REGION: us-east-2 + CLI_REGION: us-west-2 schema-auth-7-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -896,7 +904,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-7.test.ts - CLI_REGION: us-west-2 + CLI_REGION: eu-west-2 schema-auth-8-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -904,7 +912,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-8.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: eu-central-1 schema-connection-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -912,7 +920,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-connection.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: ap-northeast-1 schema-data-access-patterns-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -920,7 +928,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-data-access-patterns.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: ap-southeast-1 schema-function-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -928,7 +936,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-function.test.ts - CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-2 schema-key-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -936,7 +944,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-key.test.ts - CLI_REGION: ap-southeast-2 + CLI_REGION: us-east-2 schema-model-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -944,7 +952,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-model.test.ts - CLI_REGION: us-east-2 + CLI_REGION: us-west-2 schema-predictions-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -952,7 +960,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-predictions.test.ts - CLI_REGION: us-west-2 + CLI_REGION: eu-west-2 schema-searchable-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -960,7 +968,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-searchable.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: eu-central-1 schema-versioned-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -968,7 +976,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-versioned.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: ap-northeast-1 tags-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -976,7 +984,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/tags.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: ap-southeast-1 plugin-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -984,7 +992,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/plugin.test.ts - CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-2 datastore-modegen-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -992,7 +1000,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/datastore-modegen.test.ts - CLI_REGION: ap-southeast-2 + CLI_REGION: us-east-2 interactions-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -1000,7 +1008,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/interactions.test.ts - CLI_REGION: us-east-2 + CLI_REGION: us-west-2 hosting-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -1008,7 +1016,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/hosting.test.ts - CLI_REGION: us-west-2 + CLI_REGION: eu-west-2 init-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -1016,7 +1024,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/init.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: eu-central-1 amplify-app-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -1024,7 +1032,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/amplify-app.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: ap-northeast-1 analytics-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -1032,7 +1040,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/analytics.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: ap-southeast-1 hostingPROD-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -1040,7 +1048,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/hostingPROD.test.ts - CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-2 predictions-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -1048,7 +1056,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/predictions.test.ts - CLI_REGION: ap-southeast-2 + CLI_REGION: us-east-2 delete-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -1056,7 +1064,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/delete.test.ts - CLI_REGION: us-east-2 + CLI_REGION: us-west-2 storage-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -1064,7 +1072,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/storage.test.ts - CLI_REGION: us-west-2 + CLI_REGION: eu-west-2 migration-api-key-migration-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -1072,7 +1080,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/migration/api.key.migration.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: eu-central-1 migration-api-connection-migration-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -1080,7 +1088,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/migration/api.connection.migration.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: ap-northeast-1 workflows: version: 2 nightly_console_integration_tests: @@ -1173,6 +1181,9 @@ workflows: - amplify_console_integration_tests - amplify_migration_tests_latest - amplify_migration_tests_v4 + - schema-key-amplify_e2e_tests + - datastore-modegen-amplify_e2e_tests + - predictions-amplify_e2e_tests - schema-model-amplify_e2e_tests - interactions-amplify_e2e_tests - delete-amplify_e2e_tests @@ -1191,16 +1202,13 @@ workflows: - schema-function-amplify_e2e_tests - plugin-amplify_e2e_tests - hostingPROD-amplify_e2e_tests - - schema-key-amplify_e2e_tests - - datastore-modegen-amplify_e2e_tests - - predictions-amplify_e2e_tests filters: branches: only: - release - master - beta - - api_1-amplify_e2e_tests: + - amplify-configure-amplify_e2e_tests: filters: &ref_2 branches: only: @@ -1208,6 +1216,33 @@ workflows: - graphqlschemae2e requires: - publish_to_local_registry + - function_2-amplify_e2e_tests: + filters: *ref_2 + requires: + - publish_to_local_registry + - schema-auth-5-amplify_e2e_tests: + filters: *ref_2 + requires: + - publish_to_local_registry + - schema-key-amplify_e2e_tests: + filters: *ref_2 + requires: + - publish_to_local_registry + - amplify-configure-amplify_e2e_tests + - datastore-modegen-amplify_e2e_tests: + filters: *ref_2 + requires: + - publish_to_local_registry + - function_2-amplify_e2e_tests + - predictions-amplify_e2e_tests: + filters: *ref_2 + requires: + - publish_to_local_registry + - schema-auth-5-amplify_e2e_tests + - api_1-amplify_e2e_tests: + filters: *ref_2 + requires: + - publish_to_local_registry - init-special-case-amplify_e2e_tests: filters: *ref_2 requires: @@ -1356,25 +1391,3 @@ workflows: requires: - publish_to_local_registry - schema-auth-4-amplify_e2e_tests - - function_2-amplify_e2e_tests: - filters: *ref_2 - requires: - - publish_to_local_registry - - schema-auth-5-amplify_e2e_tests: - filters: *ref_2 - requires: - - publish_to_local_registry - - schema-key-amplify_e2e_tests: - filters: *ref_2 - requires: - - publish_to_local_registry - - datastore-modegen-amplify_e2e_tests: - filters: *ref_2 - requires: - - publish_to_local_registry - - function_2-amplify_e2e_tests - - predictions-amplify_e2e_tests: - filters: *ref_2 - requires: - - publish_to_local_registry - - schema-auth-5-amplify_e2e_tests diff --git a/packages/amplify-e2e-tests/src/__tests__/amplify-configure.test.ts b/packages/amplify-e2e-tests/src/__tests__/amplify-configure.test.ts new file mode 100644 index 00000000000..dc0a522659a --- /dev/null +++ b/packages/amplify-e2e-tests/src/__tests__/amplify-configure.test.ts @@ -0,0 +1,68 @@ +import { nspawn as spawn, getCLIPath, singleSelect, createNewProjectDir, deleteProjectDir } from 'amplify-e2e-core'; + +describe('amplify configure', () => { + let projRoot: string; + + beforeEach(async () => { + projRoot = await createNewProjectDir('amplify-configure'); + }); + + afterEach(async () => { + deleteProjectDir(projRoot); + }); + + it('validates key inputs', async () => { + await testAmplifyConfigureValidation(); + }); +}); + +function testAmplifyConfigureValidation() { + const validMockAWSAccessKeyId = 'MOCK_KLNS6VBMOLVRGX'; + const defaultAWSAccessKeyId = ''; + const accessKeyIdWithSpace = 'MOCK_JKLN 6VBMOLVRGX'; + const accessKeyIdTooShort = 'MOCK_JKLN'; //less than 16 + let accessKeyIdTooLong = 'MOCK'; //more than 128 + for (let i = 0; i < 6; i++) { + accessKeyIdTooLong += accessKeyIdTooLong; + } + + const validMockAWSSecretAccessKey = 'Mock_T0ERcxUpZhtQ1iom0v3O8fr0WYTkscsjrXDE'; + const defaultAWSSecretAccessKey = ''; + + return new Promise((resolve, reject) => { + spawn(getCLIPath(), ['configure'], { stripColors: true }) + .wait('Sign in to your AWS administrator account:') + .wait('Press Enter to continue') + .sendCarriageReturn() + .wait('Specify the AWS Region') + .sendCarriageReturn() + .wait('user name:') + .sendCarriageReturn() + .wait('Press Enter to continue') + .sendCarriageReturn() + .wait('accessKeyId') + .sendLine(accessKeyIdWithSpace) + .wait('You must enter a valid accessKeyId') + .sendLine(accessKeyIdTooShort) + .wait('You must enter a valid accessKeyId') + .sendLine(accessKeyIdTooLong) + .wait('You must enter a valid accessKeyId') + .sendLine(defaultAWSAccessKeyId) + .wait('You must enter a valid accessKeyId') + .sendLine(validMockAWSAccessKeyId) + .wait('secretAccessKey') + .sendLine(defaultAWSSecretAccessKey) + .wait('You must enter a valid secretAccessKey') + .sendLine(validMockAWSSecretAccessKey) + .wait('Profile Name:') + .sendCarriageReturn() + .wait('Successfully set up the new user.') + .run((err: Error) => { + if (!err) { + resolve(); + } else { + reject(err); + } + }); + }); +} diff --git a/packages/amplify-provider-awscloudformation/lib/setup-new-user.js b/packages/amplify-provider-awscloudformation/lib/setup-new-user.js index 7bd50ee8bf7..0e03a6eb829 100644 --- a/packages/amplify-provider-awscloudformation/lib/setup-new-user.js +++ b/packages/amplify-provider-awscloudformation/lib/setup-new-user.js @@ -58,6 +58,20 @@ async function run(context) { message: 'accessKeyId: ', default: awsConfig.accessKeyId, transformer: obfuscationUtil.transform, + validate: input => { + if (input === constants.DefaultAWSAccessKeyId || input.length < 16 || input.length > 128 || !/^[\w]+$/.test(input)) { + let message = 'You must enter a valid accessKeyId'; + if (input.length < 16) { + message += ': Minimum length is 16'; + } else if (input.length > 128) { + message += ': Maximun length is 128'; + } else if (!/^[\w]+$/.test(input)) { + message += ': It can only contain letter, number or underscore characters'; + } + return message; + } + return true; + }, }, { type: 'password', @@ -66,6 +80,12 @@ async function run(context) { message: 'secretAccessKey: ', default: awsConfig.secretAccessKey, transformer: obfuscationUtil.transform, + validate: input => { + if (input === constants.DefaultAWSSecretAccessKey || input.trim().length === 0) { + return 'You must enter a valid secretAccessKey'; + } + return true; + }, }, ]);