@@ -24,6 +24,8 @@ describe('AWS advanced template', () => {
2424 provider : 'aws' ,
2525 infrastructureType : 'advanced' ,
2626 awsRegion : 'ap-southeast-1' ,
27+ addonModules : [ ] ,
28+ enabledSecurityFeatures : false ,
2729 } ;
2830
2931 beforeAll ( async ( ) => {
@@ -74,28 +76,53 @@ describe('AWS advanced template', () => {
7476 } ) ;
7577
7678 describe ( 'given enabledSecurityFeatures is true' , ( ) => {
77- const optionsEnabledSecurityFeatures : AwsOptions = {
78- projectName : projectDir ,
79- provider : 'aws' ,
80- infrastructureType : 'advanced' ,
81- awsRegion : 'ap-southeast-1' ,
82- enabledSecurityFeatures : true ,
83- } ;
84-
85- beforeAll ( async ( ) => {
86- jest . clearAllMocks ( ) ;
87- await applyAdvancedTemplate ( optionsEnabledSecurityFeatures ) ;
79+ describe ( 'given addonModules includes vpcFlowLog' , ( ) => {
80+ const optionsEnabledSecurityFeatures : AwsOptions = {
81+ projectName : projectDir ,
82+ provider : 'aws' ,
83+ infrastructureType : 'advanced' ,
84+ awsRegion : 'ap-southeast-1' ,
85+ enabledSecurityFeatures : true ,
86+ addonModules : [ 'vpcFlowLog' ] ,
87+ } ;
88+
89+ beforeAll ( async ( ) => {
90+ jest . clearAllMocks ( ) ;
91+ await applyAdvancedTemplate ( optionsEnabledSecurityFeatures ) ;
92+ } ) ;
93+
94+ afterAll ( ( ) => {
95+ jest . clearAllMocks ( ) ;
96+ remove ( '/' , projectDir ) ;
97+ } ) ;
98+
99+ it ( 'applies VPC Flow Log add-on when flag is set' , ( ) => {
100+ expect ( applyAwsVpcFlowLog ) . toHaveBeenCalledWith (
101+ optionsEnabledSecurityFeatures
102+ ) ;
103+ } ) ;
88104 } ) ;
89-
90- afterAll ( ( ) => {
91- jest . clearAllMocks ( ) ;
92- remove ( '/' , projectDir ) ;
93- } ) ;
94-
95- it ( 'applies VPC Flow Log add-on when flag is set' , ( ) => {
96- expect ( applyAwsVpcFlowLog ) . toHaveBeenCalledWith (
97- optionsEnabledSecurityFeatures
98- ) ;
105+ describe ( 'given addonModules does NOT include vpcFlowLog' , ( ) => {
106+ const optionsEnabledSecurityFeaturesWithoutVpcFlowLog : AwsOptions = {
107+ projectName : projectDir ,
108+ provider : 'aws' ,
109+ infrastructureType : 'advanced' ,
110+ awsRegion : 'ap-southeast-1' ,
111+ enabledSecurityFeatures : true ,
112+ addonModules : [ ] , // No vpcFlowLog
113+ } ;
114+
115+ afterAll ( ( ) => {
116+ jest . clearAllMocks ( ) ;
117+ remove ( '/' , projectDir ) ;
118+ } ) ;
119+
120+ it ( 'does NOT apply VPC Flow Log add-on when flag is set but module is not included' , async ( ) => {
121+ await applyAdvancedTemplate (
122+ optionsEnabledSecurityFeaturesWithoutVpcFlowLog
123+ ) ;
124+ expect ( applyAwsVpcFlowLog ) . not . toHaveBeenCalled ( ) ;
125+ } ) ;
99126 } ) ;
100127 } ) ;
101128 } ) ;
0 commit comments