mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add Owner Mocks for vApps
This commit is contained in:
parent
cf45a85039
commit
84306b6fcc
3 changed files with 37 additions and 14 deletions
|
@ -98,7 +98,7 @@ module Fog
|
|||
:NetworkConfigSection => get_vapp_network_config_section_body(id, vapp),
|
||||
:SnapshotSection => get_snapshot_section_body(id),
|
||||
:DateCreated => vapp[:date_created], # eg "2014-03-16T10:52:31.874Z"
|
||||
:Owner => get_owner_section_body(id, vapp),
|
||||
:Owner => get_owner_section_body(id),
|
||||
:InMaintenanceMode => "false",
|
||||
:Children => {
|
||||
:Vm => get_vapp_children_vms_body(id)
|
||||
|
@ -167,17 +167,6 @@ module Fog
|
|||
}
|
||||
end
|
||||
|
||||
def get_owner_section_body(id, vapp)
|
||||
{
|
||||
:type => "application/vnd.vmware.vcloud.owner+xml",
|
||||
:User => {
|
||||
:type => "application/vnd.vmware.admin.user+xml",
|
||||
:name => "mockuser",
|
||||
:href => make_href("user/12345678-1234-1234-1234-12345678df2b"),
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def get_vapp_children_vms_body(id)
|
||||
child_vms = data[:vms].select do |vm_id, vm_details|
|
||||
vm_details[:parent_vapp] == id
|
||||
|
|
|
@ -20,6 +20,39 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_vapp_owner(id)
|
||||
|
||||
type = 'application/vnd.vmware.vcloud.owner+xml'
|
||||
|
||||
unless vapp = data[:vapps][id]
|
||||
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
||||
'This operation is denied.'
|
||||
)
|
||||
end
|
||||
|
||||
Excon::Response.new(
|
||||
:status => 200,
|
||||
:headers => {'Content-Type' => "#{type};version=#{api_version}"},
|
||||
:body => get_owner_section_body(id)
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
def get_owner_section_body(id)
|
||||
{
|
||||
:type => 'application/vnd.vmware.vcloud.owner+xml',
|
||||
:User => {
|
||||
:type => "application/vnd.vmware.admin.user+xml",
|
||||
:name => "mockuser",
|
||||
:href => make_href("user/12345678-1234-1234-1234-12345678df2b"),
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -60,9 +60,11 @@ Shindo.tests('Compute::VcloudDirector | vapp requests', ['vclouddirector']) do
|
|||
end
|
||||
|
||||
tests("#get_vapp_owner(#{@vapp_id})").data_matches_schema(VcloudDirector::Compute::Schema::OWNER_TYPE) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_vapp_owner(@vapp_id).body
|
||||
end
|
||||
tests("#get_vapp(#{@vapp_id}).body[:Owner]").data_matches_schema(VcloudDirector::Compute::Schema::OWNER_TYPE) do
|
||||
@service.get_vapp(@vapp_id).body[:Owner]
|
||||
end
|
||||
|
||||
tests("#get_control_access_params_vapp(#{@vapp_id})").data_matches_schema(VcloudDirector::Compute::Schema::CONTROL_ACCESS_PARAMS_TYPE) do
|
||||
pending if Fog.mocking?
|
||||
|
@ -92,7 +94,6 @@ Shindo.tests('Compute::VcloudDirector | vapp requests', ['vclouddirector']) do
|
|||
end
|
||||
|
||||
tests('Retrieve owner of non-existent vApp').raises(Fog::Compute::VcloudDirector::Forbidden) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_vapp_owner('00000000-0000-0000-0000-000000000000')
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue