-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
591 additions
and
521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Identity[:openstack] | ec2_credential" do | ||
before do | ||
identity = Fog::Identity[:openstack] | ||
tenant_id = identity.list_tenants.body['tenants'].first['id'] | ||
|
||
@user = identity.users.find { |user| user.name == 'foobar' } | ||
@user ||= identity.users.create( | ||
:name => 'foobar', | ||
:email => 'foo@bar.com', | ||
:tenant_id => tenant_id, | ||
:password => 'spoof', | ||
:enabled => true | ||
) | ||
|
||
@ec2_credential = identity.ec2_credentials.create( | ||
:user_id => @user.id, | ||
:tenant_id => tenant_id | ||
) | ||
end | ||
|
||
after do | ||
@user.ec2_credentials.each do |ec2_credential| | ||
ec2_credential.destroy | ||
end | ||
|
||
@user.destroy | ||
end | ||
|
||
describe "success" do | ||
it "#destroy" do | ||
@ec2_credential.destroy.must_equal(true) | ||
end | ||
end | ||
|
||
describe "failure" do | ||
it "#save" do | ||
proc do | ||
@ec2_credential.save | ||
end.must_raise(Fog::Errors::Error) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Identity[:openstack] | ec2_credentials" do | ||
before do | ||
identity = Fog::Identity[:openstack] | ||
tenant_id = identity.list_tenants.body['tenants'].first['id'] | ||
|
||
@user = identity.users.find { |user| user.name == 'foobar' } | ||
@user ||= identity.users.create( | ||
:name => 'foobar', | ||
:email => 'foo@bar.com', | ||
:tenant_id => tenant_id, | ||
:password => 'spoof', | ||
:enabled => true | ||
) | ||
|
||
@ec2_credential = identity.ec2_credentials.create( | ||
:user_id => @user.id, | ||
:tenant_id => tenant_id | ||
) | ||
end | ||
|
||
after do | ||
@user.ec2_credentials.each(&:destroy) | ||
@user.destroy | ||
end | ||
|
||
describe "success" do | ||
it "#find_by_access_key" do | ||
ec2_credential = | ||
@user.ec2_credentials.find_by_access_key(@ec2_credential.access) | ||
|
||
ec2_credential.access.must_equal @ec2_credential.access | ||
end | ||
|
||
it "#create" do | ||
@user.ec2_credentials.create.tenant_id.wont_be_empty | ||
end | ||
|
||
it "#destroy" do | ||
@user.ec2_credentials.destroy(@ec2_credential.access).must_equal true | ||
end | ||
end | ||
|
||
describe "fails" do | ||
it "#find_by_access_key" do | ||
skip if Fog.mocking? | ||
proc do | ||
@user.ec2_credentials.find_by_access_key('fake') | ||
end.must_raise(Fog::Identity::OpenStack::NotFound) | ||
end | ||
|
||
it "#destroy" do | ||
skip if Fog.mocking? | ||
proc do | ||
@user.ec2_credentials.destroy('fake') | ||
end.must_raise(Fog::Identity::OpenStack::NotFound) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Identity[:openstack] | role" do | ||
before do | ||
@identity = Fog::Identity[:openstack] | ||
@instance = @identity.roles.new( | ||
:name => 'Role Name', | ||
:user_id => 1, | ||
:role_id => 1 | ||
) | ||
@tenant = @identity.tenants.create(:name => 'test_user') | ||
@user = @identity.users.create( | ||
:name => 'test_user', | ||
:tenant_id => @tenant.id, | ||
:password => 'spoof' | ||
) | ||
@instance_saved = @instance.save | ||
end | ||
|
||
describe "success" do | ||
it "#save" do | ||
@instance_saved.must_equal true | ||
end | ||
|
||
it "#add_to_user(@user.id, @tenant.id)" do | ||
@instance.add_to_user(@user.id, @tenant.id).must_equal true | ||
end | ||
|
||
it "#remove_to_user(@user.id, @tenant.id)" do | ||
@instance.remove_to_user(@user.id, @tenant.id).must_equal true | ||
end | ||
|
||
it "#destroy" do | ||
@instance.destroy.must_equal(true) | ||
end | ||
end | ||
|
||
after do | ||
@user.destroy | ||
@tenant.destroy | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Identity[:openstack] | roles" do | ||
before do | ||
@identity = Fog::Identity[:openstack] | ||
|
||
@tenant = @identity.tenants.create(:name => 'test_user') | ||
@user = @identity.users.create(:name => 'test_user', :tenant_id => @tenant.id, :password => 'spoof') | ||
@role = @identity.roles(:user => @user, :tenant => @tenant).create(:name => 'test_role') | ||
@roles = @identity.roles(:user => @user, :tenant => @tenant) | ||
end | ||
|
||
describe "success" do | ||
it "#all" do | ||
@roles.all.must_be_kind_of Fog::Identity::OpenStack::V2::Roles | ||
end | ||
|
||
it "#get" do | ||
@roles.get(@roles.first.id).body.wont_be_nil | ||
end | ||
|
||
after do | ||
@role.destroy | ||
@user.destroy | ||
@tenant.destroy | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Identity[:openstack] | tenant" do | ||
before do | ||
@identity = Fog::Identity[:openstack] | ||
end | ||
|
||
describe "success" do | ||
before do | ||
@instance = @identity.tenants.first | ||
end | ||
|
||
it "#roles_for(0)" do | ||
@instance.roles_for(0) | ||
end | ||
|
||
it "#users" do | ||
instance = @identity.tenants.first | ||
instance.users.count.wont_equal @identity.users.count | ||
end | ||
end | ||
|
||
describe "CRUD" do | ||
before do | ||
@instance = @identity.tenants.create(:name => 'test') | ||
end | ||
|
||
it "#create" do | ||
@instance.id.nil?.wont_be_nil | ||
end | ||
|
||
it "#update" do | ||
@instance.update(:name => 'test2') | ||
@instance.name.must_equal 'test2' | ||
end | ||
|
||
it "#destroy" do | ||
@instance.destroy.must_equal true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Compute[:openstack] | tenants" do | ||
before do | ||
@identity = Fog::Identity[:openstack] | ||
@instance = @identity.tenants.create(:name => 'test') | ||
end | ||
|
||
describe "success" do | ||
it "#find_by_id" do | ||
tenant = @identity.tenants.find_by_id(@instance.id) | ||
tenant.id.must_equal @instance.id | ||
end | ||
|
||
it "#destroy" do | ||
@identity.tenants.destroy(@instance.id).must_equal true | ||
end | ||
end | ||
|
||
describe "failure" do | ||
it "#find_by_id" do | ||
skip if Fog.mocking? | ||
|
||
proc do | ||
@identity.tenants.find_by_id('fake') | ||
end.must_raise(Fog::Identity::OpenStack::NotFound) | ||
end | ||
|
||
it "#destroy" do | ||
skip if Fog.mocking? | ||
|
||
proc do | ||
@identity.tenants.destroy('fake') | ||
end.must_raise(Fog::Identity::OpenStack::NotFound) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Identity[:openstack] | user" do | ||
before do | ||
@identity = Fog::Identity[:openstack] | ||
@tenant_id = @identity.list_tenants.body['tenants'].first['id'] | ||
@instance = @identity.users.new( | ||
:name => 'User Name', | ||
:email => 'test@fog.com', | ||
:tenant_id => @tenant_id, | ||
:password => 'spoof', | ||
:enabled => true | ||
) | ||
end | ||
|
||
describe "success" do | ||
before do | ||
@instance_saved = @instance.save | ||
end | ||
|
||
it "#save" do | ||
@instance_saved.must_equal true | ||
end | ||
|
||
it "#roles" do | ||
@instance.roles.must_be_empty | ||
end | ||
|
||
it "#update" do | ||
@instance.update(:name => 'updatename', :email => 'new@email.com'). | ||
must_equal true | ||
end | ||
|
||
it "#update_password" do | ||
@instance.update_password('swordfish').must_equal true | ||
end | ||
|
||
it "#update_tenant" do | ||
@instance.update_tenant(@tenant_id).must_equal true | ||
end | ||
|
||
it "#update_enabled" do | ||
@instance.update_enabled(true).must_equal true | ||
end | ||
|
||
it "#destroy" do | ||
@instance.destroy.must_equal true | ||
end | ||
end | ||
|
||
describe "failure" do | ||
it "#save" do | ||
skip | ||
proc do | ||
@instance.save | ||
end.must_raise(Fog::Errors::Error) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Identity[:openstack] | users" do | ||
before do | ||
@identity = Fog::Identity[:openstack] | ||
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 | ||
skip if Fog.mocking? | ||
proc do | ||
Fog::Identity[:openstack].users.find_by_id('fake') | ||
end.must_raise(Fog::Identity::OpenStack::NotFound) | ||
end | ||
|
||
it "#find_by_name" do | ||
skip if Fog.mocking? | ||
proc do | ||
Fog::Identity[:openstack].users.find_by_name('fake') | ||
end.must_raise(Fog::Identity::OpenStack::NotFound) | ||
end | ||
|
||
it "#destroy" do | ||
skip if Fog.mocking? | ||
proc do | ||
Fog::Identity[:openstack].users.destroy('fake') | ||
end.must_raise(Fog::Identity::OpenStack::NotFound) | ||
end | ||
end | ||
end |
Oops, something went wrong.