@@ -1421,7 +1421,6 @@ def test_must_add_custom_statements(self):
14211421
14221422 self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
14231423
1424- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
14251424 def test_must_add_iam_allow (self ):
14261425## fails
14271426 resourcePolicy = {
@@ -1438,14 +1437,14 @@ def test_must_add_iam_allow(self):
14381437 'Action' : 'execute-api:Invoke' ,
14391438 'Resource' : [{
14401439 'Fn::Sub' : [
1441- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/PUT/foo' ,
1442- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1440+ 'execute-api:/${__Stage__}/PUT/foo' ,
1441+ {'__Stage__' : 'prod' }
14431442 ]
14441443 },
14451444 {
14461445 'Fn::Sub' : [
1447- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/GET/foo' ,
1448- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1446+ 'execute-api:/${__Stage__}/GET/foo' ,
1447+ {'__Stage__' : 'prod' }
14491448 ]
14501449 }],
14511450 'Effect' : 'Allow' ,
@@ -1457,7 +1456,6 @@ def test_must_add_iam_allow(self):
14571456
14581457 self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
14591458
1460- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
14611459 def test_must_add_iam_deny (self ):
14621460
14631461 resourcePolicy = {
@@ -1474,14 +1472,14 @@ def test_must_add_iam_deny(self):
14741472 'Action' : 'execute-api:Invoke' ,
14751473 'Resource' : [{
14761474 'Fn::Sub' : [
1477- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/PUT/foo' ,
1478- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1475+ 'execute-api:/${__Stage__}/PUT/foo' ,
1476+ {'__Stage__' : 'prod' }
14791477 ]
14801478 },
14811479 {
14821480 'Fn::Sub' : [
1483- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/GET/foo' ,
1484- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1481+ 'execute-api:/${__Stage__}/GET/foo' ,
1482+ {'__Stage__' : 'prod' }
14851483 ]
14861484 }],
14871485 'Effect' : 'Deny' ,
@@ -1493,7 +1491,6 @@ def test_must_add_iam_deny(self):
14931491
14941492 self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
14951493
1496- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
14971494 def test_must_add_ip_allow (self ):
14981495
14991496 resourcePolicy = {
@@ -1510,14 +1507,14 @@ def test_must_add_ip_allow(self):
15101507 'Action' : 'execute-api:Invoke' ,
15111508 'Resource' : [{
15121509 'Fn::Sub' : [
1513- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/PUT/foo' ,
1514- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1510+ 'execute-api:/${__Stage__}/PUT/foo' ,
1511+ {'__Stage__' : 'prod' }
15151512 ]
15161513 },
15171514 {
15181515 'Fn::Sub' : [
1519- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/GET/foo' ,
1520- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1516+ 'execute-api:/${__Stage__}/GET/foo' ,
1517+ {'__Stage__' : 'prod' }
15211518 ]
15221519 }],
15231520 'Effect' : 'Allow' ,
@@ -1527,14 +1524,14 @@ def test_must_add_ip_allow(self):
15271524 'Action' : 'execute-api:Invoke' ,
15281525 'Resource' : [{
15291526 'Fn::Sub' : [
1530- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/PUT/foo' ,
1531- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1527+ 'execute-api:/${__Stage__}/PUT/foo' ,
1528+ {'__Stage__' : 'prod' }
15321529 ]
15331530 },
15341531 {
15351532 'Fn::Sub' : [
1536- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/GET/foo' ,
1537- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1533+ 'execute-api:/${__Stage__}/GET/foo' ,
1534+ {'__Stage__' : 'prod' }
15381535 ]
15391536 }],
15401537 'Effect' : 'Deny' ,
@@ -1549,7 +1546,6 @@ def test_must_add_ip_allow(self):
15491546
15501547 self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
15511548
1552- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
15531549 def test_must_add_ip_deny (self ):
15541550
15551551 resourcePolicy = {
@@ -1566,14 +1562,14 @@ def test_must_add_ip_deny(self):
15661562 'Action' : 'execute-api:Invoke' ,
15671563 'Resource' : [{
15681564 'Fn::Sub' : [
1569- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/PUT/foo' ,
1570- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1565+ 'execute-api:/${__Stage__}/PUT/foo' ,
1566+ {'__Stage__' : 'prod' }
15711567 ]
15721568 },
15731569 {
15741570 'Fn::Sub' : [
1575- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/GET/foo' ,
1576- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1571+ 'execute-api:/${__Stage__}/GET/foo' ,
1572+ {'__Stage__' : 'prod' }
15771573 ]
15781574 }],
15791575 'Effect' : 'Allow' ,
@@ -1583,14 +1579,14 @@ def test_must_add_ip_deny(self):
15831579 'Action' : 'execute-api:Invoke' ,
15841580 'Resource' : [{
15851581 'Fn::Sub' : [
1586- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/PUT/foo' ,
1587- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1582+ 'execute-api:/${__Stage__}/PUT/foo' ,
1583+ {'__Stage__' : 'prod' }
15881584 ]
15891585 },
15901586 {
15911587 'Fn::Sub' : [
1592- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/GET/foo' ,
1593- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1588+ 'execute-api:/${__Stage__}/GET/foo' ,
1589+ {'__Stage__' : 'prod' }
15941590 ]
15951591 }],
15961592 'Effect' : 'Deny' ,
@@ -1605,7 +1601,6 @@ def test_must_add_ip_deny(self):
16051601
16061602 self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
16071603
1608- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
16091604 def test_must_add_vpc_allow (self ):
16101605
16111606 resourcePolicy = {
@@ -1624,14 +1619,14 @@ def test_must_add_vpc_allow(self):
16241619 'Action' : 'execute-api:Invoke' ,
16251620 'Resource' : [{
16261621 'Fn::Sub' : [
1627- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/PUT/foo' ,
1628- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1622+ 'execute-api:/${__Stage__}/PUT/foo' ,
1623+ {'__Stage__' : 'prod' }
16291624 ]
16301625 },
16311626 {
16321627 'Fn::Sub' : [
1633- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/GET/foo' ,
1634- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1628+ 'execute-api:/${__Stage__}/GET/foo' ,
1629+ {'__Stage__' : 'prod' }
16351630 ]
16361631 }],
16371632 'Effect' : 'Allow' ,
@@ -1641,14 +1636,14 @@ def test_must_add_vpc_allow(self):
16411636 'Action' : 'execute-api:Invoke' ,
16421637 'Resource' : [{
16431638 'Fn::Sub' : [
1644- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/PUT/foo' ,
1645- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1639+ 'execute-api:/${__Stage__}/PUT/foo' ,
1640+ {'__Stage__' : 'prod' }
16461641 ]
16471642 },
16481643 {
16491644 'Fn::Sub' : [
1650- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/GET/foo' ,
1651- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1645+ 'execute-api:/${__Stage__}/GET/foo' ,
1646+ {'__Stage__' : 'prod' }
16521647 ]
16531648 }],
16541649 'Effect' : 'Deny' ,
@@ -1663,14 +1658,14 @@ def test_must_add_vpc_allow(self):
16631658 'Action' : 'execute-api:Invoke' ,
16641659 'Resource' : [{
16651660 'Fn::Sub' : [
1666- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/PUT/foo' ,
1667- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1661+ 'execute-api:/${__Stage__}/PUT/foo' ,
1662+ {'__Stage__' : 'prod' }
16681663 ]
16691664 },
16701665 {
16711666 'Fn::Sub' : [
1672- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/GET/foo' ,
1673- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1667+ 'execute-api:/${__Stage__}/GET/foo' ,
1668+ {'__Stage__' : 'prod' }
16741669 ]
16751670 }],
16761671 'Effect' : 'Deny' ,
@@ -1686,7 +1681,6 @@ def test_must_add_vpc_allow(self):
16861681
16871682 self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
16881683
1689- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
16901684 def test_must_add_vpc_deny (self ):
16911685
16921686 resourcePolicy = {
@@ -1704,14 +1698,14 @@ def test_must_add_vpc_deny(self):
17041698 'Action' : 'execute-api:Invoke' ,
17051699 'Resource' : [{
17061700 'Fn::Sub' : [
1707- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/PUT/foo' ,
1708- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1701+ 'execute-api:/${__Stage__}/PUT/foo' ,
1702+ {'__Stage__' : 'prod' }
17091703 ]
17101704 },
17111705 {
17121706 'Fn::Sub' : [
1713- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/GET/foo' ,
1714- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1707+ 'execute-api:/${__Stage__}/GET/foo' ,
1708+ {'__Stage__' : 'prod' }
17151709 ]
17161710 }],
17171711 'Effect' : 'Allow' ,
@@ -1721,14 +1715,14 @@ def test_must_add_vpc_deny(self):
17211715 'Action' : 'execute-api:Invoke' ,
17221716 'Resource' : [ {
17231717 'Fn::Sub' : [
1724- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/PUT/foo' ,
1725- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1718+ 'execute-api:/${__Stage__}/PUT/foo' ,
1719+ {'__Stage__' : 'prod' }
17261720 ]
17271721 },
17281722 {
17291723 'Fn::Sub' : [
1730- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/GET/foo' ,
1731- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1724+ 'execute-api:/${__Stage__}/GET/foo' ,
1725+ {'__Stage__' : 'prod' }
17321726 ]
17331727 }],
17341728 'Effect' : 'Deny' ,
@@ -1744,9 +1738,7 @@ def test_must_add_vpc_deny(self):
17441738
17451739 self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
17461740
1747- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
17481741 def test_must_add_iam_allow_and_custom (self ):
1749- ## fails
17501742 resourcePolicy = {
17511743 'AwsAccountWhitelist' : [
17521744 '123456'
@@ -1769,14 +1761,14 @@ def test_must_add_iam_allow_and_custom(self):
17691761 'Action' : 'execute-api:Invoke' ,
17701762 'Resource' : [{
17711763 'Fn::Sub' : [
1772- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/PUT/foo' ,
1773- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1764+ 'execute-api:/${__Stage__}/PUT/foo' ,
1765+ {'__Stage__' : 'prod' }
17741766 ]
17751767 },
17761768 {
17771769 'Fn::Sub' : [
1778- 'arn:aws: execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__} /${__Stage__}/GET/foo' ,
1779- {'__Stage__' : 'prod' , '__ApiId__' : '123' }
1770+ 'execute-api:/${__Stage__}/GET/foo' ,
1771+ {'__Stage__' : 'prod' }
17801772 ]
17811773 }],
17821774 'Effect' : 'Allow' ,
0 commit comments