2 Documentation Test Suite for Neutron Security Group
3 Suite Setup OpenStackOperations.OpenStack Suite Setup
4 Suite Teardown OpenStackOperations.OpenStack Suite Teardown
5 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Test Teardown OpenStackOperations.Get Test Teardown Debugs
8 Library OperatingSystem
9 Library RequestsLibrary
11 Resource ../../../libraries/DevstackUtils.robot
12 Resource ../../../libraries/OpenStackOperations.robot
13 Resource ../../../libraries/SetupUtils.robot
14 Resource ../../../variables/Variables.robot
18 ${DESCRIPTION} --description "new security group 1"
19 ${VERIFY_DESCRIPTION} new security group 1
20 ${VERIFY_NAME} SSH_UPDATED
21 ${NAME_UPDATE} --name SSH_UPDATED
22 ${SECURITY_FALSE} --port-security-enabled false
23 ${SECURITY_TRUE} --port-security-enabled true
24 ${SEC_GROUP_API} /restconf/config/neutron:neutron/security-groups/
25 ${SEC_RULE_API} /restconf/config/neutron:neutron/security-rules/
26 ${ADD_ARG_SSH} --direction ingress --ethertype IPv4 --port_range_max 22 --port_range_min 22 --protocol tcp
29 @{IP_SUBNETS} 61.2.1.0/24
30 @{PORTS} sgs_port_1 sgs_port_2
31 ${SECURITY_GROUPS} --security-group
32 @{SGS} sgs_sg_1 sgs_sg_2 sgs_sg_3 sgs_sg_4
33 ${SG_UPDATED} SSH_UPDATED
34 ${ADD_ARG_SSH5} --ingress --ethertype IPv4 --dst-port 25:20 --protocol tcp
35 @{ADD_PARAMS} ingression IPv4 20 25 tcp
36 ${ADD_ARG_SSH6} --ingress --ethertype IPv4 --dst-port -1:25 --protocol tcp
37 ${ADD_ARG_SSH7} --ingress --ethertype IPv4 --dst-port 20:-1 --protocol tcp
38 ${PORT_RANGE_ERROR} argument --dst-port: Invalid range, 25 is not less than 20
39 ${INVALID_MIN_PORT} argument --dst-port: expected one argument
40 ${INVALID_MAX_PORT} argument --dst-port: Invalid range, 20 is not less than -1
43 TC01_Update Security Group description and Name
44 [Documentation] This test case validates the security group creation with optional parameter description, Update Security Group description and name
46 ${sg_id} = BuiltIn.Run Keyword Create Security Group and Validate ${SGS[0]}
47 Create Security Rule and Validate ${SGS[0]} direction=${ADD_PARAMS[0]} ethertype=${ADD_PARAMS[1]} port_range_max=${ADD_PARAMS[3]} port_range_min=${ADD_PARAMS[2]} protocol=${ADD_PARAMS[4]}
48 Neutron Setup Creation ${NETWORKS[0]} ${SUBNETS[0]} ${IP_SUBNETS[0]} ${PORTS[0]} ${PORTS[1]} ${sg_id}
49 Security group verification on Neutron port ${PORTS[0]} ${sg_id}
50 Security group verification on Neutron port ${PORTS[1]} ${sg_id}
51 Update Security Group Description and Verification ${sg_id} ${DESCRIPTION} ${VERIFY_DESCRIPTION}
52 Update Security Group Name and Verification ${sg_id} ${NAME_UPDATE} ${VERIFY_NAME}
54 TC02_Create Security Rule with port_range_min > port_range_max
55 [Documentation] Create Security Rule with port_range_min greater than port_range_max
57 Create Security Group and Validate ${SGS[1]}
58 Neutron Rule Creation With Invalid Parameters ${SGS[1]} ${ADD_ARG_SSH5} ${PORT_RANGE_ERROR}
60 TC03_Create Security Rule with port_range_min = -1
61 [Documentation] Create Security Rule with port_range_min = -1
63 Create Security Group and Validate ${SGS[2]}
64 Neutron Rule Creation With Invalid Parameters ${SGS[2]} ${ADD_ARG_SSH6} ${INVALID_MIN_PORT}
66 TC04_Create Security Rule with port_range_max = -1
67 [Documentation] Create Security Rule with port_range_max = -1
69 Create Security Group and Validate ${SGS[3]}
70 Neutron Rule Creation With Invalid Parameters ${SGS[3]} ${ADD_ARG_SSH7} ${INVALID_MAX_PORT}
73 Create Security Group and Validate
75 ${output} ${sg_id} = OpenStackOperations.Neutron Security Group Create ${sg_ssh}
76 ${sec_groups} = BuiltIn.Create List ${sg_ssh}
77 BuiltIn.Wait Until Keyword Succeeds 10s 2s Utils.Check For Elements At URI ${SEC_GROUP_API} ${sec_groups}
80 Create Security Rule and Validate
81 [Arguments] ${sg_ssh} &{Kwargs}
82 ${output} ${rule_id} = OpenStackOperations.Neutron Security Group Rule Create ${sg_ssh}
83 ${rule_ids} = BuiltIn.Create List ${rule_id}
84 BuiltIn.Wait Until Keyword Succeeds 10s 2s Utils.Check For Elements At URI ${SEC_RULE_API} ${rule_ids}
86 Neutron Setup Creation
87 [Arguments] ${network} ${subnet} ${ip_subnet} ${port1} ${port2} ${sg_id}
88 ${net_id} = OpenStackOperations.Create Network ${network}
89 ${subnet_id} = OpenStackOperations.Create SubNet ${network} ${subnet} ${ip_subnet}
90 ${port_id} = OpenStackOperations.Create Port ${network} ${port1} ${sg_id}
91 ${port_id} = OpenStackOperations.Create Port ${network} ${port2} ${sg_id}
93 Security group verification on Neutron port
94 [Arguments] ${port} ${sg_id}
95 ${port_show} = OpenStackOperations.Neutron Port Show ${port}
96 BuiltIn.Should Contain ${port_show} ${sg_id}
98 Update Security Group Description and Verification
99 [Arguments] ${sg_id} ${description} ${verify_description}
100 OpenStackOperations.Neutron Security Group Update ${sg_id} ${description}
101 ${output} = OpenStackOperations.Neutron Security Group Show ${sg_id}
102 BuiltIn.Should Contain ${output} ${verify_description}
104 Update Security Group Name and Verification
105 [Arguments] ${sg_id} ${name_update} ${verify_name}
106 OpenStackOperations.Neutron Security Group Update ${sg_id} ${name_update}
107 ${output} = OpenStackOperations.Neutron Security Group Show ${sg_id}
108 Should Contain ${output} ${verify_name}
109 ${resp} RequestsLibrary.Get Request session ${SEC_GROUP_API}
110 BuiltIn.Log ${resp.content}
111 BuiltIn.Should Be Equal As Strings ${resp.status_code} ${RESP_CODE_200}
112 BuiltIn.Should Contain ${resp.content} ${verify_name}
114 Neutron Rule Creation With Invalid Parameters
115 [Arguments] ${sg_name} ${additional_args} ${expected_error}
116 ${rc} ${output} = Run And Return Rc And Output openstack security group rule create ${additional_args} ${sg_name}
117 BuiltIn.Log ${output}
118 BuiltIn.Should Contain ${output} ${expected_error}