Skip to content

Commit

Permalink
fix: fixed import_auth test (aws-amplify#8755)
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarkarachi authored and akshbhu committed Nov 10, 2021
1 parent f31c48f commit 039a80e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 49 deletions.
79 changes: 33 additions & 46 deletions packages/amplify-e2e-core/src/categories/storage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { singleSelect } from '../utils/selectors';
import { getCLIPath, nspawn as spawn } from '..';
import { getCLIPath, nspawn as spawn, RETURN } from '..';

export type AddStorageSettings = {
resourceName: string;
bucketName: string;
resourceName?: string;
bucketName?: string;
};

export type AddDynamoDBSettings = {
Expand Down Expand Up @@ -602,31 +602,32 @@ export function addS3StorageWithIdpAuth(projectDir: string): Promise<void> {
export function addS3Storage(projectDir: string): Promise<void> {
return new Promise((resolve, reject) => {
let chain = spawn(getCLIPath(), ['add', 'storage'], { cwd: projectDir, stripColors: true });
chain.wait('Select from one of the below mentioned services:') //'Content (Images, audio, video, etc.)'
.sendCarriageReturn()
.wait('Provide a friendly name for your resource that will be used to label this category in the project:')
.sendCarriageReturn()
.wait('Provide bucket name:')
.sendCarriageReturn()
.wait('Who should have access:')
.sendKeyDown()
.send(' ') //Auth and guest
.sendCarriageReturn()
.wait('What kind of access do you want for Authenticated users?')//Auth
.sendCtrlA()
.sendCarriageReturn()
.wait('What kind of access do you want for Guest users?')//Guest
.sendCtrlA()
.sendCarriageReturn()
.wait('Do you want to add a Lambda Trigger for your S3 Bucket?')
.sendConfirmNo()
.run((err: Error) => {
if (!err) {
resolve();
} else {
reject(err);
}
});
chain
.wait('Select from one of the below mentioned services:') //'Content (Images, audio, video, etc.)'
.sendCarriageReturn()
.wait('Provide a friendly name for your resource that will be used to label this category in the project:')
.sendCarriageReturn()
.wait('Provide bucket name:')
.sendCarriageReturn()
.wait('Who should have access:')
.sendKeyDown()
.send(' ') //Auth and guest
.sendCarriageReturn()
.wait('What kind of access do you want for Authenticated users?') //Auth
.sendCtrlA()
.sendCarriageReturn()
.wait('What kind of access do you want for Guest users?') //Guest
.sendCtrlA()
.sendCarriageReturn()
.wait('Do you want to add a Lambda Trigger for your S3 Bucket?')
.sendConfirmNo()
.run((err: Error) => {
if (!err) {
resolve();
} else {
reject(err);
}
});
});
}

Expand Down Expand Up @@ -658,29 +659,15 @@ export function addS3StorageWithSettings(projectDir: string, settings: AddStorag

chain
.wait('Provide a friendly name for your resource that will be used to label this category in the project:')
.sendLine(settings.resourceName)
.sendLine(settings.resourceName || RETURN)
.wait('Provide bucket name:')
.sendLine(settings.bucketName);
.sendLine(settings.bucketName || RETURN);

chain.wait('Who should have access:').sendKeyDown().send(' ').sendCarriageReturn();

chain
.wait('What kind of access do you want for Authenticated users?')
.send(' ') //'create/update'
.sendKeyDown()
.send(' ') //'read'
.sendKeyDown()
.send(' ') //'delete'
.sendCarriageReturn();
chain.wait('What kind of access do you want for Authenticated users?').sendCtrlA().sendCarriageReturn();

chain
.wait('What kind of access do you want for Guest users?')
.send(' ') //'create/update'
.sendKeyDown()
.send(' ') //'read'
.sendKeyDown()
.send(' ') //'delete'
.sendCarriageReturn();
chain.wait('What kind of access do you want for Guest users?').sendCtrlA().sendCarriageReturn();

chain.wait('Do you want to add a Lambda Trigger for your S3 Bucket?').sendConfirmNo();

Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-e2e-core/src/utils/nexpect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { join, parse } from 'path';
import * as fs from 'fs-extra';
import * as os from 'os';
import { getScriptRunnerPath, isTestingWithLatestCodebase } from '..';
const RETURN = process.platform === 'win32' ? '\r' : EOL;
export const RETURN = process.platform === 'win32' ? '\r' : EOL;
const DEFAULT_NO_OUTPUT_TIMEOUT = process.env.AMPLIFY_TEST_TIMEOUT_SEC
? Number.parseInt(process.env.AMPLIFY_TEST_TIMEOUT_SEC, 10) * 1000
: 5 * 60 * 1000; // 5 Minutes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
deleteProjectDir,
getAppId,
initJSProjectWithProfile,
addS3StorageWithSettings,
} from 'amplify-e2e-core';
import {
AuthProjectDetails,
Expand Down Expand Up @@ -241,7 +242,7 @@ describe('auth import identity pool and userpool', () => {
it('auth import, storage auth/guest access, push successful', async () => {
await initJSProjectWithProfile(projectRoot, projectSettings);
await importIdentityPoolAndUserPool(projectRoot, ogSettings.userPoolName, { native: '_app_client ', web: '_app_clientWeb' });
await addS3Storage(projectRoot);
await addS3StorageWithSettings(projectRoot, {});
await amplifyPushAuth(projectRoot);

await amplifyStatus(projectRoot, 'No Change');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ describe('nodejs version migration tests', () => {
'amplify',
'backend',
'auth',
'build',
authResourceName,
'build',
`${authResourceName}-cloudformation-template.json`,
);
let authStackContent = fs.readFileSync(authStackFileName).toString();
Expand Down

0 comments on commit 039a80e

Please sign in to comment.