EC2 describe_network_acls: add support for owner-id filter (#3898)
* add test that fails with FilterNotImplementedError * describe_network_acls: add support for owner-id filter Co-authored-by: Kevin Neal <Kevin_Neal@intuit.com>
This commit is contained in:
parent
94a70e9ad1
commit
e5b3f4181d
@ -5667,10 +5667,13 @@ class NetworkAclAssociation(object):
|
|||||||
|
|
||||||
|
|
||||||
class NetworkAcl(TaggedEC2Resource):
|
class NetworkAcl(TaggedEC2Resource):
|
||||||
def __init__(self, ec2_backend, network_acl_id, vpc_id, default=False):
|
def __init__(
|
||||||
|
self, ec2_backend, network_acl_id, vpc_id, default=False, owner_id=OWNER_ID,
|
||||||
|
):
|
||||||
self.ec2_backend = ec2_backend
|
self.ec2_backend = ec2_backend
|
||||||
self.id = network_acl_id
|
self.id = network_acl_id
|
||||||
self.vpc_id = vpc_id
|
self.vpc_id = vpc_id
|
||||||
|
self.owner_id = owner_id
|
||||||
self.network_acl_entries = []
|
self.network_acl_entries = []
|
||||||
self.associations = {}
|
self.associations = {}
|
||||||
self.default = "true" if default is True else "false"
|
self.default = "true" if default is True else "false"
|
||||||
@ -5684,6 +5687,8 @@ class NetworkAcl(TaggedEC2Resource):
|
|||||||
return self.id
|
return self.id
|
||||||
elif filter_name == "association.subnet-id":
|
elif filter_name == "association.subnet-id":
|
||||||
return [assoc.subnet_id for assoc in self.associations.values()]
|
return [assoc.subnet_id for assoc in self.associations.values()]
|
||||||
|
elif filter_name == "owner-id":
|
||||||
|
return self.owner_id
|
||||||
else:
|
else:
|
||||||
return super(NetworkAcl, self).get_filter_value(
|
return super(NetworkAcl, self).get_filter_value(
|
||||||
filter_name, "DescribeNetworkAcls"
|
filter_name, "DescribeNetworkAcls"
|
||||||
|
@ -132,6 +132,7 @@ DESCRIBE_NETWORK_ACL_RESPONSE = """
|
|||||||
<item>
|
<item>
|
||||||
<networkAclId>{{ network_acl.id }}</networkAclId>
|
<networkAclId>{{ network_acl.id }}</networkAclId>
|
||||||
<vpcId>{{ network_acl.vpc_id }}</vpcId>
|
<vpcId>{{ network_acl.vpc_id }}</vpcId>
|
||||||
|
<ownerId>{{ network_acl.owner_id }}</ownerId>
|
||||||
<default>{{ network_acl.default }}</default>
|
<default>{{ network_acl.default }}</default>
|
||||||
<entrySet>
|
<entrySet>
|
||||||
{% for entry in network_acl.network_acl_entries %}
|
{% for entry in network_acl.network_acl_entries %}
|
||||||
|
@ -6,6 +6,7 @@ import pytest
|
|||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
|
|
||||||
from moto import mock_ec2_deprecated, mock_ec2
|
from moto import mock_ec2_deprecated, mock_ec2
|
||||||
|
from moto.ec2.models import OWNER_ID
|
||||||
|
|
||||||
|
|
||||||
@mock_ec2_deprecated
|
@mock_ec2_deprecated
|
||||||
@ -297,6 +298,11 @@ def test_describe_network_acls():
|
|||||||
resp2 = conn.describe_network_acls()["NetworkAcls"]
|
resp2 = conn.describe_network_acls()["NetworkAcls"]
|
||||||
resp2.should.have.length_of(3)
|
resp2.should.have.length_of(3)
|
||||||
|
|
||||||
|
resp3 = conn.describe_network_acls(
|
||||||
|
Filters=[{"Name": "owner-id", "Values": [OWNER_ID]}]
|
||||||
|
)["NetworkAcls"]
|
||||||
|
resp3.should.have.length_of(3)
|
||||||
|
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
conn.describe_network_acls(NetworkAclIds=["1"])
|
conn.describe_network_acls(NetworkAclIds=["1"])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user