Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/functional/ec2/test_create_network_acl_entry.py
1567 views
1
#!/usr/bin/env python
2
# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License"). You
5
# may not use this file except in compliance with the License. A copy of
6
# the License is located at
7
#
8
# http://aws.amazon.com/apache2.0/
9
#
10
# or in the "license" file accompanying this file. This file is
11
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12
# ANY KIND, either express or implied. See the License for the specific
13
# language governing permissions and limitations under the License.
14
from awscli.testutils import BaseAWSCommandParamsTest
15
16
17
class TestCreateNetworkACLEntry(BaseAWSCommandParamsTest):
18
19
prefix = 'ec2 create-network-acl-entry'
20
21
def test_tcp(self):
22
cmdline = self.prefix
23
cmdline += ' --network-acl-id acl-12345678'
24
cmdline += ' --rule-number 100'
25
cmdline += ' --protocol tcp'
26
cmdline += ' --rule-action allow'
27
cmdline += ' --ingress'
28
cmdline += ' --port-range From=22,To=22'
29
cmdline += ' --cidr-block 0.0.0.0/0'
30
result = {'NetworkAclId': 'acl-12345678',
31
'RuleNumber': 100,
32
'Protocol': '6',
33
'RuleAction': 'allow',
34
'Egress': False,
35
'CidrBlock': '0.0.0.0/0',
36
'PortRange': {'From': 22, 'To': 22}}
37
self.assert_params_for_cmd(cmdline, result)
38
39
def test_udp(self):
40
cmdline = self.prefix
41
cmdline += ' --network-acl-id acl-12345678'
42
cmdline += ' --rule-number 100'
43
cmdline += ' --protocol udp'
44
cmdline += ' --rule-action allow'
45
cmdline += ' --ingress'
46
cmdline += ' --port-range From=22,To=22'
47
cmdline += ' --cidr-block 0.0.0.0/0'
48
result = {'NetworkAclId': 'acl-12345678',
49
'RuleNumber': 100,
50
'Protocol': '17',
51
'RuleAction': 'allow',
52
'Egress': False,
53
'CidrBlock': '0.0.0.0/0',
54
'PortRange': {'From': 22, 'To': 22}}
55
self.assert_params_for_cmd(cmdline, result)
56
57
def test_icmp(self):
58
cmdline = self.prefix
59
cmdline += ' --network-acl-id acl-12345678'
60
cmdline += ' --rule-number 100'
61
cmdline += ' --protocol icmp'
62
cmdline += ' --rule-action allow'
63
cmdline += ' --ingress'
64
cmdline += ' --port-range From=22,To=22'
65
cmdline += ' --cidr-block 0.0.0.0/0'
66
result = {'NetworkAclId': 'acl-12345678',
67
'RuleNumber': 100,
68
'Protocol': '1',
69
'RuleAction': 'allow',
70
'Egress': False,
71
'CidrBlock': '0.0.0.0/0',
72
'PortRange': {'From': 22, 'To': 22}}
73
self.assert_params_for_cmd(cmdline, result)
74
75
def test_all(self):
76
cmdline = self.prefix
77
cmdline += ' --network-acl-id acl-12345678'
78
cmdline += ' --rule-number 100'
79
cmdline += ' --protocol all'
80
cmdline += ' --rule-action allow'
81
cmdline += ' --ingress'
82
cmdline += ' --port-range From=22,To=22'
83
cmdline += ' --cidr-block 0.0.0.0/0'
84
result = {'NetworkAclId': 'acl-12345678',
85
'RuleNumber': 100,
86
'Protocol': '-1',
87
'RuleAction': 'allow',
88
'Egress': False,
89
'CidrBlock': '0.0.0.0/0',
90
'PortRange': {'From': 22, 'To': 22}}
91
self.assert_params_for_cmd(cmdline, result)
92
93
def test_number(self):
94
cmdline = self.prefix
95
cmdline += ' --network-acl-id acl-12345678'
96
cmdline += ' --rule-number 100'
97
cmdline += ' --protocol 99'
98
cmdline += ' --rule-action allow'
99
cmdline += ' --ingress'
100
cmdline += ' --port-range From=22,To=22'
101
cmdline += ' --cidr-block 0.0.0.0/0'
102
result = {'NetworkAclId': 'acl-12345678',
103
'RuleNumber': 100,
104
'Protocol': '99',
105
'RuleAction': 'allow',
106
'Egress': False,
107
'CidrBlock': '0.0.0.0/0',
108
'PortRange': {'From': 22, 'To': 22}}
109
self.assert_params_for_cmd(cmdline, result)
110
111
112