Path: blob/develop/tests/functional/ec2/test_replace_network_acl_entry.py
1567 views
#!/usr/bin/env python1# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License"). You4# may not use this file except in compliance with the License. A copy of5# the License is located at6#7# http://aws.amazon.com/apache2.0/8#9# or in the "license" file accompanying this file. This file is10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF11# ANY KIND, either express or implied. See the License for the specific12# language governing permissions and limitations under the License.13from awscli.testutils import BaseAWSCommandParamsTest141516class TestReplaceNetworkACLEntry(BaseAWSCommandParamsTest):1718prefix = 'ec2 replace-network-acl-entry'1920def test_tcp(self):21cmdline = self.prefix22cmdline += ' --network-acl-id acl-12345678'23cmdline += ' --rule-number 100'24cmdline += ' --protocol tcp'25cmdline += ' --rule-action allow'26cmdline += ' --ingress'27cmdline += ' --port-range From=22,To=22'28cmdline += ' --cidr-block 0.0.0.0/0'29result = {'NetworkAclId': 'acl-12345678',30'RuleNumber': 100,31'Protocol': '6',32'RuleAction': 'allow',33'Egress': False,34'CidrBlock': '0.0.0.0/0',35'PortRange': {'From': 22, 'To': 22}}36self.assert_params_for_cmd(cmdline, result)3738def test_udp(self):39cmdline = self.prefix40cmdline += ' --network-acl-id acl-12345678'41cmdline += ' --rule-number 100'42cmdline += ' --protocol udp'43cmdline += ' --rule-action allow'44cmdline += ' --ingress'45cmdline += ' --port-range From=22,To=22'46cmdline += ' --cidr-block 0.0.0.0/0'47result = {'NetworkAclId': 'acl-12345678',48'RuleNumber': 100,49'Protocol': '17',50'RuleAction': 'allow',51'Egress': False,52'CidrBlock': '0.0.0.0/0',53'PortRange': {'From': 22, 'To': 22}}54self.assert_params_for_cmd(cmdline, result)5556def test_icmp(self):57cmdline = self.prefix58cmdline += ' --network-acl-id acl-12345678'59cmdline += ' --rule-number 100'60cmdline += ' --protocol icmp'61cmdline += ' --rule-action allow'62cmdline += ' --ingress'63cmdline += ' --port-range From=22,To=22'64cmdline += ' --cidr-block 0.0.0.0/0'65result = {'NetworkAclId': 'acl-12345678',66'RuleNumber': 100,67'Protocol': '1',68'RuleAction': 'allow',69'Egress': False,70'CidrBlock': '0.0.0.0/0',71'PortRange': {'From': 22, 'To': 22}}72self.assert_params_for_cmd(cmdline, result)7374def test_all(self):75cmdline = self.prefix76cmdline += ' --network-acl-id acl-12345678'77cmdline += ' --rule-number 100'78cmdline += ' --protocol all'79cmdline += ' --rule-action allow'80cmdline += ' --ingress'81cmdline += ' --port-range From=22,To=22'82cmdline += ' --cidr-block 0.0.0.0/0'83result = {'NetworkAclId': 'acl-12345678',84'RuleNumber': 100,85'Protocol': '-1',86'RuleAction': 'allow',87'Egress': False,88'CidrBlock': '0.0.0.0/0',89'PortRange': {'From': 22, 'To': 22}}90self.assert_params_for_cmd(cmdline, result)9192def test_number(self):93cmdline = self.prefix94cmdline += ' --network-acl-id acl-12345678'95cmdline += ' --rule-number 100'96cmdline += ' --protocol 99'97cmdline += ' --rule-action allow'98cmdline += ' --ingress'99cmdline += ' --port-range From=22,To=22'100cmdline += ' --cidr-block 0.0.0.0/0'101result = {'NetworkAclId': 'acl-12345678',102'RuleNumber': 100,103'Protocol': '99',104'RuleAction': 'allow',105'Egress': False,106'CidrBlock': '0.0.0.0/0',107'PortRange': {'From': 22, 'To': 22}}108self.assert_params_for_cmd(cmdline, result)109110111112