Ejemplo n.º 1
0
 def test_from_string_errors_with_no_id(self):
     with self.assertRaisesRegex(
             ValueError,
             "Resource ID must be supplied as the 7th element in a colon separated string"
     ):
         URN.from_string(
             r"urn:aws:111111111111:eu-west-1:cloudwatch:metric")
Ejemplo n.º 2
0
 def test_from_string_with_multiple_ids(self):
     assert URN.from_string(
         "urn:aws:111111111111:us-east-1:iam:role_policy:test-role/test-policy/this/should/be/included"
     ) == URN(
         account_id="111111111111",
         region="us-east-1",
         service="iam",
         resource_type="role_policy",
         resource_id_parts=[
             "test-role", "test-policy", "this", "should", "be", "included"
         ],
     )
Ejemplo n.º 3
0
    def test_resource_id_with_integer(self):
        urn = URN.from_string(
            r"urn:aws:111111111111:eu-west-1:lambda:layer_version:test_layer/1"
        )

        assert urn == URN(
            account_id="111111111111",
            region="eu-west-1",
            service="lambda",
            resource_type="layer_version",
            resource_id_parts=["test_layer", "1"],
        )
        assert urn.resource_id_parts == ["test_layer", "1"]
Ejemplo n.º 4
0
    def test_resource_id_with_slashes_from_string(self):
        urn = URN.from_string(
            r"urn:aws:111111111111:eu-west-1:cloudwatch:metric:AWS\/Logs\/IncomingBytes"
        )

        assert urn == URN(
            account_id="111111111111",
            region="eu-west-1",
            service="cloudwatch",
            resource_type="metric",
            resource_id_parts=["AWS/Logs/IncomingBytes"],
        )
        assert urn.resource_id_parts == ["AWS/Logs/IncomingBytes"]
        assert urn.resource_id == r"AWS\/Logs\/IncomingBytes"
Ejemplo n.º 5
0
    def test_resource_id_with_arn_from_string(self):
        urn = URN.from_string(
            r"urn:aws:111111111111:us-east-1:iam:policy:iam\:\:111111111111\:"
            r"policy\/service-role\/AmazonSageMaker-ExecutionPolicy-20211016T110298"
        )

        assert urn == URN(
            account_id="111111111111",
            region="us-east-1",
            service="iam",
            resource_type="policy",
            resource_id_parts=[
                r"iam::111111111111:policy/service-role/AmazonSageMaker-ExecutionPolicy-20211016T110298"
            ],
        )
        assert urn.resource_id_parts == [
            r"iam::111111111111:policy/service-role/AmazonSageMaker-ExecutionPolicy-20211016T110298"
        ]
Ejemplo n.º 6
0
 def test_from_string(self):
     assert (URN.from_string(
         "urn:aws:111111111111:us-east-1:iam:role_policy:test-role/test-policy"
     ) == self.test_urn_dependent_resource)