2012-02-23 03:43:00 -05:00
|
|
|
Shindo.tests('Fog::Compute[:openstack] | security group requests', ['openstack']) do
|
2012-02-27 06:59:53 -05:00
|
|
|
@security_group = Hash.new
|
|
|
|
@security_group_rule = Hash.new
|
2012-02-23 03:43:00 -05:00
|
|
|
@security_group_format = {
|
2012-10-02 01:52:45 -04:00
|
|
|
"id" => Integer,
|
|
|
|
"rules" => Array,
|
|
|
|
"tenant_id" => String,
|
|
|
|
"name" => String,
|
2012-02-23 03:43:00 -05:00
|
|
|
"description" => String
|
|
|
|
}
|
|
|
|
|
|
|
|
@security_group_rule_format = {
|
2012-10-02 01:52:45 -04:00
|
|
|
"id" => Integer,
|
|
|
|
"from_port" => Integer,
|
|
|
|
"to_port" => Integer,
|
2012-02-23 03:43:00 -05:00
|
|
|
"ip_protocol" => String,
|
2012-10-02 01:52:45 -04:00
|
|
|
"group" => Hash,
|
|
|
|
"ip_range" => Hash,
|
|
|
|
"parent_group_id" => Integer
|
2012-02-23 03:43:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
tests('success') do
|
2012-11-29 21:30:58 -05:00
|
|
|
tests('#create_security_group(name, description)').formats({"security_group" => @security_group_format}) do
|
2012-02-27 06:59:53 -05:00
|
|
|
Fog::Compute[:openstack].create_security_group('from_shindo_test', 'this is from the shindo test').body
|
2012-02-23 03:43:00 -05:00
|
|
|
end
|
|
|
|
|
2012-02-27 06:59:53 -05:00
|
|
|
tests('#create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id=nil)').formats({"security_group_rule" => @security_group_rule_format}) do
|
|
|
|
parent_group_id = Fog::Compute[:openstack].list_security_groups.body['security_groups'].last['id']
|
|
|
|
Fog::Compute[:openstack].create_security_group_rule(parent_group_id, "tcp", 2222, 3333, "20.20.20.20/24").body
|
2012-02-23 03:43:00 -05:00
|
|
|
end
|
|
|
|
|
2012-02-27 06:59:53 -05:00
|
|
|
tests('#list_security_groups').formats({"security_groups" => [@security_group_format]}) do
|
|
|
|
Fog::Compute[:openstack].list_security_groups.body
|
2012-02-23 03:43:00 -05:00
|
|
|
end
|
|
|
|
|
2012-02-27 06:59:53 -05:00
|
|
|
tests('#get_security_group(security_group_id)').formats({"security_group" => @security_group_format}) do
|
|
|
|
group_id = Fog::Compute[:openstack].list_security_groups.body['security_groups'].last['id']
|
|
|
|
Fog::Compute[:openstack].get_security_group(group_id).body
|
2012-02-23 03:43:00 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
tests('#delete_security_group_rule(security_group_rule_id)').succeeds do
|
2012-02-27 06:59:53 -05:00
|
|
|
security_group_rule_id = Fog::Compute[:openstack].list_security_groups.body['security_groups'].last['rules'].last['id']
|
|
|
|
Fog::Compute[:openstack].delete_security_group_rule(security_group_rule_id)
|
2012-02-23 03:43:00 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
tests('#delete_security_group(security_group_id)').succeeds do
|
2012-12-05 22:29:19 -05:00
|
|
|
compute = Fog::Compute[:openstack]
|
|
|
|
|
|
|
|
group_id = compute.list_security_groups.body['security_groups'].last['id']
|
|
|
|
|
|
|
|
compute.delete_security_group(group_id)
|
|
|
|
|
|
|
|
returns(false) {
|
|
|
|
groups = compute.list_security_groups.body['security_groups']
|
|
|
|
groups.any? { |group| group['id'] == group_id }
|
|
|
|
}
|
2012-02-23 03:43:00 -05:00
|
|
|
end
|
|
|
|
end # tests('success')
|
|
|
|
end
|