mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Update mocking support for security groups.
This commit is contained in:
parent
26e2fa51ec
commit
4f14fe3806
1 changed files with 17 additions and 11 deletions
|
@ -51,18 +51,24 @@ module Fog
|
|||
|
||||
def create_security_group(name, description)
|
||||
response = Excon::Response.new
|
||||
if self.data[:security_groups].detect {|_,v| v['name'] == name}
|
||||
response.status = 400
|
||||
response.body = { "badRequest" => {"message" => "Security group #{name} already exists", "code" => 400}}
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
else
|
||||
response.status = 200
|
||||
|
||||
data = {
|
||||
'id' => Fog::Mock.random_numbers(3).to_s,
|
||||
'rules' => [],
|
||||
'id' => Fog::Mock.random_numbers(3).to_i,
|
||||
'tenant_id' => Fog::HP::Mock.user_id.to_s,
|
||||
'name' => name,
|
||||
'description' => description,
|
||||
'tenant_id' => Fog::HP::Mock.user_id.to_s
|
||||
'description' => description
|
||||
}
|
||||
self.data[:last_modified][:security_groups][data['id']] = Time.now
|
||||
self.data[:security_groups][data['id']] = data
|
||||
|
||||
response.body = { 'security_group' => data }
|
||||
end
|
||||
response
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue