1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/openstack/requests/compute/create_security_group.rb
Alfonso Juan Dillera b7370d640e [openstack|compute] Add requests and tests for security groups
- Added tests to already existing security group requests.
2012-04-30 10:34:58 +08:00

47 lines
1.2 KiB
Ruby

module Fog
module Compute
class OpenStack
class Real
def create_security_group(name, description)
data = {
'security_group' => {
'name' => name,
'description' => description
}
}
request(
:body => MultiJson.encode(data),
:expects => 200,
:method => 'POST',
:path => 'os-security-groups.json'
)
end
end
class Mock
def create_security_group(name, description)
response = Excon::Response.new
response.status = 200
response.headers = {
"X-Compute-Request-Id" => "req-c373a42c-2825-4e60-8d34-99416ea850be",
"Content-Type" => "application/json",
"Content-Length" => "139",
"Date" => Date.new}
response.body = {
"security_groups" => [{
"rules" => [],
"tenant_id" => "d5183375ab0343f3a0b4b05f547aefc2",
"id" => 999,
"name" => name,
"description" => description
}]
}
response
end
end # mock
end # openstack
end # compute
end # fog