2 Documentation Test Suite for Neutron Security Group
5 Library OperatingSystem
6 Library RequestsLibrary
8 Resource ../../../libraries/DevstackUtils.robot
9 Resource ../../../libraries/OpenStackOperations.robot
10 Resource ../../../libraries/SetupUtils.robot
11 Resource ../../../variables/Variables.robot
13 Suite Setup OpenStackOperations.OpenStack Suite Setup
14 Suite Teardown OpenStackOperations.OpenStack Suite Teardown
15 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
16 Test Teardown OpenStackOperations.Get Test Teardown Debugs
21 ${DESCRIPTION} --description "new security group 1"
22 ${VERIFY_DESCRIPTION} new security group 1
23 ${VERIFY_NAME} SSH_UPDATED
24 ${NAME_UPDATE} --name SSH_UPDATED
25 ${SECURITY_FALSE} --port-security-enabled false
26 ${SECURITY_TRUE} --port-security-enabled true
27 ${SEC_GROUP_API} /restconf/config/neutron:neutron/security-groups/
28 ${SEC_RULE_API} /restconf/config/neutron:neutron/security-rules/
29 ${ADD_ARG_SSH} --direction ingress --ethertype IPv4 --port_range_max 22 --port_range_min 22 --protocol tcp
32 @{IP_SUBNETS} 61.2.1.0/24
33 @{PORTS} sgs_port_1 sgs_port_2
34 ${SECURITY_GROUPS} --security-group
35 @{SGS} sgs_sg_1 sgs_sg_2 sgs_sg_3 sgs_sg_4
36 ${SG_UPDATED} SSH_UPDATED
37 ${ADD_ARG_SSH5} --ingress --ethertype IPv4 --dst-port 25:20 --protocol tcp
38 @{ADD_PARAMS} ingression IPv4 20 25 tcp
39 ${ADD_ARG_SSH6} --ingress --ethertype IPv4 --dst-port -1:25 --protocol tcp
40 ${ADD_ARG_SSH7} --ingress --ethertype IPv4 --dst-port 20:-1 --protocol tcp
41 ${PORT_RANGE_ERROR} argument --dst-port: Invalid range, 25 is not less than 20
42 ${INVALID_MIN_PORT} argument --dst-port: expected one argument
43 ${INVALID_MAX_PORT} argument --dst-port: Invalid range, 20 is not less than -1
47 TC01_Update Security Group description and Name
48 [Documentation] This test case validates the security group creation with optional parameter description, Update Security Group description and name
50 ${sg_id} = BuiltIn.Run Keyword Create Security Group and Validate ${SGS[0]}
51 Create Security Rule and Validate
53 ... direction=${ADD_PARAMS[0]}
54 ... ethertype=${ADD_PARAMS[1]}
55 ... port_range_max=${ADD_PARAMS[3]}
56 ... port_range_min=${ADD_PARAMS[2]}
57 ... protocol=${ADD_PARAMS[4]}
58 Neutron Setup Creation
65 Security group verification on Neutron port ${PORTS[0]} ${sg_id}
66 Security group verification on Neutron port ${PORTS[1]} ${sg_id}
67 Update Security Group Description and Verification ${sg_id} ${DESCRIPTION} ${VERIFY_DESCRIPTION}
68 Update Security Group Name and Verification ${sg_id} ${NAME_UPDATE} ${VERIFY_NAME}
70 TC02_Create Security Rule with port_range_min > port_range_max
71 [Documentation] Create Security Rule with port_range_min greater than port_range_max
73 Create Security Group and Validate ${SGS[1]}
74 Neutron Rule Creation With Invalid Parameters ${SGS[1]} ${ADD_ARG_SSH5} ${PORT_RANGE_ERROR}
76 TC03_Create Security Rule with port_range_min = -1
77 [Documentation] Create Security Rule with port_range_min = -1
79 Create Security Group and Validate ${SGS[2]}
80 Neutron Rule Creation With Invalid Parameters ${SGS[2]} ${ADD_ARG_SSH6} ${INVALID_MIN_PORT}
82 TC04_Create Security Rule with port_range_max = -1
83 [Documentation] Create Security Rule with port_range_max = -1
85 Create Security Group and Validate ${SGS[3]}
86 Neutron Rule Creation With Invalid Parameters ${SGS[3]} ${ADD_ARG_SSH7} ${INVALID_MAX_PORT}
90 Create Security Group and Validate
92 ${output} ${sg_id} = OpenStackOperations.Neutron Security Group Create ${sg_ssh}
93 ${sec_groups} = BuiltIn.Create List ${sg_ssh}
94 BuiltIn.Wait Until Keyword Succeeds
97 ... Utils.Check For Elements At URI
102 Create Security Rule and Validate
103 [Arguments] ${sg_ssh} &{Kwargs}
104 ${output} ${rule_id} = OpenStackOperations.Neutron Security Group Rule Create ${sg_ssh}
105 ${rule_ids} = BuiltIn.Create List ${rule_id}
106 BuiltIn.Wait Until Keyword Succeeds
109 ... Utils.Check For Elements At URI
113 Neutron Setup Creation
114 [Arguments] ${network} ${subnet} ${ip_subnet} ${port1} ${port2} ${sg_id}
115 ${net_id} = OpenStackOperations.Create Network ${network}
116 ${subnet_id} = OpenStackOperations.Create SubNet ${network} ${subnet} ${ip_subnet}
117 ${port_id} = OpenStackOperations.Create Port ${network} ${port1} ${sg_id}
118 ${port_id} = OpenStackOperations.Create Port ${network} ${port2} ${sg_id}
120 Security group verification on Neutron port
121 [Arguments] ${port} ${sg_id}
122 ${port_show} = OpenStackOperations.Neutron Port Show ${port}
123 BuiltIn.Should Contain ${port_show} ${sg_id}
125 Update Security Group Description and Verification
126 [Arguments] ${sg_id} ${description} ${verify_description}
127 OpenStackOperations.Neutron Security Group Update ${sg_id} ${description}
128 ${output} = OpenStackOperations.Neutron Security Group Show ${sg_id}
129 BuiltIn.Should Contain ${output} ${verify_description}
131 Update Security Group Name and Verification
132 [Arguments] ${sg_id} ${name_update} ${verify_name}
133 OpenStackOperations.Neutron Security Group Update ${sg_id} ${name_update}
134 ${output} = OpenStackOperations.Neutron Security Group Show ${sg_id}
135 Should Contain ${output} ${verify_name}
136 ${resp} = RequestsLibrary.Get Request session ${SEC_GROUP_API}
137 BuiltIn.Log ${resp.text}
138 BuiltIn.Should Be Equal As Strings ${resp.status_code} ${RESP_CODE_200}
139 BuiltIn.Should Contain ${resp.text} ${verify_name}
141 Neutron Rule Creation With Invalid Parameters
142 [Arguments] ${sg_name} ${additional_args} ${expected_error}
143 ${rc} ${output} = Run And Return Rc And Output
144 ... openstack security group rule create ${additional_args} ${sg_name}
145 BuiltIn.Log ${output}
146 BuiltIn.Should Contain ${output} ${expected_error}