Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: externalId requirement for add account form #713

Merged
merged 5 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ const addUpdateBaseAwsAccountFormFields = {
placeholder: 'Type description for this AWS account',
rules: 'required|string',
},
externalId: {
label: 'External ID',
placeholder: 'Type external ID for this AWS account',
rules: 'required|string|between:1,300',
},
};

const addUpdateAwsAccountAppStreamFormFields = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('AddAwsAccount', () => {
name: 'MyResearchProjectAccount',
accountId: '012345678910',
description: 'This is my research project account',
externalId: 'sampleExternalId',
};
awsAccountsStore.addAwsAccount.mockImplementationOnce(() => {
return { ...component.awsAccount, id: 'mockID' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,53 @@ describe('AwsAccountService', () => {
}
});

it('should not share appstream image if member account is same as main account', async () => {
// BUILD
const requestContext = {};
service.updateEnvironmentInstanceFilesBucketPolicy = jest.fn();
uuidMock.mockReturnValueOnce('abc-123-456');
settingsService.get = jest.fn(() => {
return awsAccount.accountId;
});
service.shareAppStreamImageWithMemberAccount = jest.fn();

// OPERATE
await service.create(requestContext, awsAccount);

// CHECK
expect(service.shareAppStreamImageWithMemberAccount).not.toHaveBeenCalled();
});

it('should share appstream image if member account is different than main account', async () => {
// BUILD
const requestContext = {};
service.updateEnvironmentInstanceFilesBucketPolicy = jest.fn();
uuidMock.mockReturnValueOnce('abc-123-456');
const mainAccountId = '0987654321';
settingsService.get = jest.fn(() => {
return mainAccountId;
});
settingsService.getBoolean = jest.fn(() => {
return true;
});
service.shareAppStreamImageWithMemberAccount = jest.fn();
const appstreamAwsAccount = {
name: 'my-aws-account',
accountId: '012345678998',
appStreamImageName: 'sampleAppStreamImageName',
};

// OPERATE
await service.create(requestContext, appstreamAwsAccount);

// CHECK
expect(service.shareAppStreamImageWithMemberAccount).toHaveBeenCalledWith(
requestContext,
appstreamAwsAccount.accountId,
appstreamAwsAccount.appStreamImageName,
);
});

it('should save awsAccount in the database with a new uuid', async () => {
// BUILD
const requestContext = {};
Expand Down