@@ -1421,7 +1421,6 @@ def test_must_add_custom_statements(self):
1421
1421
1422
1422
self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
1423
1423
1424
- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
1425
1424
def test_must_add_iam_allow (self ):
1426
1425
## fails
1427
1426
resourcePolicy = {
@@ -1438,14 +1437,14 @@ def test_must_add_iam_allow(self):
1438
1437
'Action' : 'execute-api:Invoke' ,
1439
1438
'Resource' : [{
1440
1439
'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' }
1443
1442
]
1444
1443
},
1445
1444
{
1446
1445
'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' }
1449
1448
]
1450
1449
}],
1451
1450
'Effect' : 'Allow' ,
@@ -1457,7 +1456,6 @@ def test_must_add_iam_allow(self):
1457
1456
1458
1457
self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
1459
1458
1460
- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
1461
1459
def test_must_add_iam_deny (self ):
1462
1460
1463
1461
resourcePolicy = {
@@ -1474,14 +1472,14 @@ def test_must_add_iam_deny(self):
1474
1472
'Action' : 'execute-api:Invoke' ,
1475
1473
'Resource' : [{
1476
1474
'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' }
1479
1477
]
1480
1478
},
1481
1479
{
1482
1480
'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' }
1485
1483
]
1486
1484
}],
1487
1485
'Effect' : 'Deny' ,
@@ -1493,7 +1491,6 @@ def test_must_add_iam_deny(self):
1493
1491
1494
1492
self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
1495
1493
1496
- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
1497
1494
def test_must_add_ip_allow (self ):
1498
1495
1499
1496
resourcePolicy = {
@@ -1510,14 +1507,14 @@ def test_must_add_ip_allow(self):
1510
1507
'Action' : 'execute-api:Invoke' ,
1511
1508
'Resource' : [{
1512
1509
'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' }
1515
1512
]
1516
1513
},
1517
1514
{
1518
1515
'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' }
1521
1518
]
1522
1519
}],
1523
1520
'Effect' : 'Allow' ,
@@ -1527,14 +1524,14 @@ def test_must_add_ip_allow(self):
1527
1524
'Action' : 'execute-api:Invoke' ,
1528
1525
'Resource' : [{
1529
1526
'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' }
1532
1529
]
1533
1530
},
1534
1531
{
1535
1532
'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' }
1538
1535
]
1539
1536
}],
1540
1537
'Effect' : 'Deny' ,
@@ -1549,7 +1546,6 @@ def test_must_add_ip_allow(self):
1549
1546
1550
1547
self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
1551
1548
1552
- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
1553
1549
def test_must_add_ip_deny (self ):
1554
1550
1555
1551
resourcePolicy = {
@@ -1566,14 +1562,14 @@ def test_must_add_ip_deny(self):
1566
1562
'Action' : 'execute-api:Invoke' ,
1567
1563
'Resource' : [{
1568
1564
'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' }
1571
1567
]
1572
1568
},
1573
1569
{
1574
1570
'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' }
1577
1573
]
1578
1574
}],
1579
1575
'Effect' : 'Allow' ,
@@ -1583,14 +1579,14 @@ def test_must_add_ip_deny(self):
1583
1579
'Action' : 'execute-api:Invoke' ,
1584
1580
'Resource' : [{
1585
1581
'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' }
1588
1584
]
1589
1585
},
1590
1586
{
1591
1587
'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' }
1594
1590
]
1595
1591
}],
1596
1592
'Effect' : 'Deny' ,
@@ -1605,7 +1601,6 @@ def test_must_add_ip_deny(self):
1605
1601
1606
1602
self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
1607
1603
1608
- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
1609
1604
def test_must_add_vpc_allow (self ):
1610
1605
1611
1606
resourcePolicy = {
@@ -1624,14 +1619,14 @@ def test_must_add_vpc_allow(self):
1624
1619
'Action' : 'execute-api:Invoke' ,
1625
1620
'Resource' : [{
1626
1621
'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' }
1629
1624
]
1630
1625
},
1631
1626
{
1632
1627
'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' }
1635
1630
]
1636
1631
}],
1637
1632
'Effect' : 'Allow' ,
@@ -1641,14 +1636,14 @@ def test_must_add_vpc_allow(self):
1641
1636
'Action' : 'execute-api:Invoke' ,
1642
1637
'Resource' : [{
1643
1638
'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' }
1646
1641
]
1647
1642
},
1648
1643
{
1649
1644
'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' }
1652
1647
]
1653
1648
}],
1654
1649
'Effect' : 'Deny' ,
@@ -1663,14 +1658,14 @@ def test_must_add_vpc_allow(self):
1663
1658
'Action' : 'execute-api:Invoke' ,
1664
1659
'Resource' : [{
1665
1660
'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' }
1668
1663
]
1669
1664
},
1670
1665
{
1671
1666
'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' }
1674
1669
]
1675
1670
}],
1676
1671
'Effect' : 'Deny' ,
@@ -1686,7 +1681,6 @@ def test_must_add_vpc_allow(self):
1686
1681
1687
1682
self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
1688
1683
1689
- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
1690
1684
def test_must_add_vpc_deny (self ):
1691
1685
1692
1686
resourcePolicy = {
@@ -1704,14 +1698,14 @@ def test_must_add_vpc_deny(self):
1704
1698
'Action' : 'execute-api:Invoke' ,
1705
1699
'Resource' : [{
1706
1700
'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' }
1709
1703
]
1710
1704
},
1711
1705
{
1712
1706
'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' }
1715
1709
]
1716
1710
}],
1717
1711
'Effect' : 'Allow' ,
@@ -1721,14 +1715,14 @@ def test_must_add_vpc_deny(self):
1721
1715
'Action' : 'execute-api:Invoke' ,
1722
1716
'Resource' : [ {
1723
1717
'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' }
1726
1720
]
1727
1721
},
1728
1722
{
1729
1723
'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' }
1732
1726
]
1733
1727
}],
1734
1728
'Effect' : 'Deny' ,
@@ -1744,9 +1738,7 @@ def test_must_add_vpc_deny(self):
1744
1738
1745
1739
self .assertEqual (deep_sort_lists (expected ), deep_sort_lists (self .editor .swagger [_X_POLICY ]))
1746
1740
1747
- @patch ("boto3.session.Session.region_name" , "eu-west-2" )
1748
1741
def test_must_add_iam_allow_and_custom (self ):
1749
- ## fails
1750
1742
resourcePolicy = {
1751
1743
'AwsAccountWhitelist' : [
1752
1744
'123456'
@@ -1769,14 +1761,14 @@ def test_must_add_iam_allow_and_custom(self):
1769
1761
'Action' : 'execute-api:Invoke' ,
1770
1762
'Resource' : [{
1771
1763
'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' }
1774
1766
]
1775
1767
},
1776
1768
{
1777
1769
'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' }
1780
1772
]
1781
1773
}],
1782
1774
'Effect' : 'Allow' ,
0 commit comments