1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
require "test_helper"
describe "Fog::Identity[:openstack] | users" do
before do
@identity = Fog::OpenStack::Identity.new(:openstack_identity_api_version => 'v2.0')
tenant_id = @identity.list_tenants.body['tenants'].first['id']
@instance = @identity.users.create(
:name => 'foobar',
:email => 'foo@bar.com',
:tenant_id => tenant_id,
:password => 'spoof',
:enabled => true
)
end
describe "success" do
it "#find_by_id" do
user = @identity.users.find_by_id(@instance.id)
user.id.must_equal @instance.id
end
it "#find_by_name" do
user = @identity.users.find_by_name(@instance.name)
user.name.must_equal @instance.name
end
it "#destroy" do
@identity.users.destroy(@instance.id).must_equal true
end
end
describe "fails" do
it "#find_by_id" do
unless Fog.mocking?
proc do
Fog::Identity[:openstack].users.find_by_id('fake')
end.must_raise(Fog::OpenStack::Identity::NotFound)
end
end
it "#find_by_name" do
unless Fog.mocking?
proc do
Fog::Identity[:openstack].users.find_by_name('fake')
end.must_raise(Fog::OpenStack::Identity::NotFound)
end
end
it "#destroy" do
unless Fog.mocking?
proc do
Fog::Identity[:openstack].users.destroy('fake')
end.must_raise(Fog::OpenStack::Identity::NotFound)
end
end
end
end
|