Skip to content

Commit

Permalink
mid work
Browse files Browse the repository at this point in the history
  • Loading branch information
iliapolo committed Sep 15, 2024
1 parent bcdf94f commit 0b47cd7
Showing 1 changed file with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('new style synthesis', () => {

});

test('can set session tags on default stack synthesizer', () => {
test('can set role additional options tags on default stack synthesizer', () => {
// GIVEN
stack = new Stack(app, 'SessionTagsStack', {
synthesizer: new DefaultStackSynthesizer({
Expand All @@ -122,6 +122,9 @@ describe('new style synthesis', () => {
Tags: [{ Key: 'Department', Value: 'Engineering-LookupRoleTag' }],
},
}),
env: {
account: '111111111111', region: 'us-east-1',
},
});

stack.synthesizer.addFileAsset({
Expand All @@ -135,9 +138,15 @@ describe('new style synthesis', () => {
sourceHash: 'dockerHash',
});

ContextProvider.getValue(stack, {
provider: cxschema.ContextProvider.VPC_PROVIDER,
props: {},
dummyValue: undefined,
}).value;

// THEN
const asm = app.synth();
const manifest = app.synth().getStackByName('SessionTagsStack').manifest;
const manifest = asm.getStackByName('SessionTagsStack').manifest;
// Validates that the deploy and lookup role session tags were set in the Manifest:
expect((manifest.properties as cxschema.AwsCloudFormationStackProperties).assumeRoleAdditionalOptions?.Tags).toEqual([{ Key: 'Department', Value: 'Engineering-DeployRoleTag' }]);
expect((manifest.properties as cxschema.AwsCloudFormationStackProperties).lookupRole?.assumeRoleAdditionalOptions?.Tags).toEqual([{ Key: 'Department', Value: 'Engineering-LookupRoleTag' }]);
Expand All @@ -148,6 +157,10 @@ describe('new style synthesis', () => {
// Validates that the image and file asset session tags were set in the asset manifest:
expect(assetManifestJSON.dockerImages?.dockerHash.destinations['current_account-current_region'].assumeRoleAdditionalOptions?.Tags).toEqual([{ Key: 'Department', Value: 'Engineering-ImageAssetTag' }]);
expect(assetManifestJSON.files?.fileHash.destinations['current_account-current_region'].assumeRoleAdditionalOptions?.Tags).toEqual([{ Key: 'Department', Value: 'Engineering-FileAssetTag' }]);

// assert that lookup role options are added to the missing lookup context
expect(asm.manifest.missing![0].props.assumeRoleAdditionalOptions).toEqual({});

});

test('customize version parameter', () => {
Expand Down Expand Up @@ -233,6 +246,29 @@ describe('new style synthesis', () => {

});

test('generates missing context with the lookup role external id as one of the missing context properties', () => {
// GIVEN
stack = new Stack(app, 'Stack2', {
synthesizer: new DefaultStackSynthesizer({
generateBootstrapVersionRule: false,
lookupRoleExternalId: 'External',
}),
env: {
account: '111111111111', region: 'us-east-1',
},
});
ContextProvider.getValue(stack, {
provider: cxschema.ContextProvider.VPC_PROVIDER,
props: {},
dummyValue: undefined,
}).value;

// THEN
const assembly = app.synth();
expect(assembly.manifest.missing![0].props.lookupRoleExternalId).toEqual('External');

});

test('nested Stack uses the lookup role ARN of the parent stack', () => {
// GIVEN
const myapp = new App();
Expand Down

0 comments on commit 0b47cd7

Please sign in to comment.