@@ -31,12 +31,93 @@ describe('#compileHttpIamRole()', () => {
3131    serverlessStepFunctions  =  new  ServerlessStepFunctions ( serverless ) ; 
3232  } ) ; 
3333
34-   it ( 'should create a IAM Role resource' ,  ( )  =>  serverlessStepFunctions 
35-     . compileHttpIamRole ( ) . then ( ( )  =>  { 
36-       expect ( 
37-         serverlessStepFunctions . serverless . service . provider . compiledCloudFormationTemplate 
38-           . Resources . ApigatewayToStepFunctionsRole . Type 
39-       ) . to . equal ( 'AWS::IAM::Role' ) ; 
40-     } ) 
41-   ) ; 
34+   it ( 'should create an IAM Role resource when there are no iamRole overrides' ,  ( )  =>  { 
35+     serverlessStepFunctions . pluginhttpValidated  =  { 
36+       events : [ 
37+         { 
38+           stateMachineName : 'first' , 
39+           http : { 
40+             path : 'foo/bar1' , 
41+             method : 'post' , 
42+           } , 
43+         } , 
44+         { 
45+           stateMachineName : 'first' , 
46+           http : { 
47+             path : 'foo/bar2' , 
48+             method : 'post' , 
49+             private : true , 
50+           } , 
51+         } , 
52+       ] , 
53+     } ; 
54+ 
55+     serverlessStepFunctions 
56+       . compileHttpIamRole ( ) . then ( ( )  =>  { 
57+         expect ( 
58+           serverlessStepFunctions . serverless . service . provider . compiledCloudFormationTemplate 
59+             . Resources . ApigatewayToStepFunctionsRole . Type 
60+         ) . to . equal ( 'AWS::IAM::Role' ) ; 
61+       } ) ; 
62+   } ) ; 
63+ 
64+   it ( 'should create an IAM Role resource when at least one event has no iamRole override' ,  ( )  =>  { 
65+     serverlessStepFunctions . pluginhttpValidated  =  { 
66+       events : [ 
67+         { 
68+           stateMachineName : 'first' , 
69+           http : { 
70+             path : 'foo/bar1' , 
71+             method : 'post' , 
72+           } , 
73+         } , 
74+         { 
75+           stateMachineName : 'first' , 
76+           http : { 
77+             path : 'foo/bar2' , 
78+             method : 'post' , 
79+             iamRole : 'arn:aws:iam::12345567890:role/test' , 
80+           } , 
81+         } , 
82+       ] , 
83+     } ; 
84+ 
85+     serverlessStepFunctions 
86+       . compileHttpIamRole ( ) . then ( ( )  =>  { 
87+         expect ( 
88+           serverlessStepFunctions . serverless . service . provider . compiledCloudFormationTemplate 
89+             . Resources . ApigatewayToStepFunctionsRole . Type 
90+         ) . to . equal ( 'AWS::IAM::Role' ) ; 
91+       } ) ; 
92+   } ) ; 
93+ 
94+   it ( 'should not create an IAM Role resource when all events have iamRole override' ,  ( )  =>  { 
95+     serverlessStepFunctions . pluginhttpValidated  =  { 
96+       events : [ 
97+         { 
98+           stateMachineName : 'first' , 
99+           http : { 
100+             path : 'foo/bar1' , 
101+             method : 'post' , 
102+             iamRole : 'arn:aws:iam::12345567890:role/test1' , 
103+           } , 
104+         } , 
105+         { 
106+           stateMachineName : 'first' , 
107+           http : { 
108+             path : 'foo/bar2' , 
109+             method : 'post' , 
110+             iamRole : 'arn:aws:iam::12345567890:role/test2' , 
111+           } , 
112+         } , 
113+       ] , 
114+     } ; 
115+ 
116+     serverlessStepFunctions 
117+       . compileHttpIamRole ( ) . then ( ( )  =>  { 
118+         const  resources  =  serverlessStepFunctions . serverless . service . provider 
119+           . compiledCloudFormationTemplate . Resources ; 
120+         expect ( resources ) . to . not . haveOwnProperty ( 'ApigatewayToStepFunctionsRole' ) ; 
121+       } ) ; 
122+   } ) ; 
42123} ) ; 
0 commit comments