2012-06-05 09:03:14 -04:00
|
|
|
Shindo.tests("Fog::Compute[:iam] | users", ['aws','iam']) do
|
2012-06-04 14:34:58 -04:00
|
|
|
|
|
|
|
Fog.mock!
|
|
|
|
@iam = Fog::AWS[:iam]
|
|
|
|
@user_one_name = 'fake_user_one'
|
|
|
|
@user_two_name = 'fake_user_two'
|
2012-11-29 02:54:47 -05:00
|
|
|
|
|
|
|
@user_three_name = 'fake_user_three'
|
|
|
|
@user_three_path = '/path/to/fake_user_three/'
|
2012-11-29 11:42:35 -05:00
|
|
|
@user_four_name = 'fake_user_four'
|
|
|
|
|
2012-06-04 14:34:58 -04:00
|
|
|
tests('#create').succeeds do
|
|
|
|
@user_one = @iam.users.create(:id => @user_one_name)
|
|
|
|
@user_one.id == @user_one_name
|
|
|
|
end
|
2012-11-29 02:54:47 -05:00
|
|
|
|
2012-06-05 09:03:14 -04:00
|
|
|
tests('#all','there is only one user').succeeds do
|
2012-06-04 14:34:58 -04:00
|
|
|
@iam.users.size == 1
|
|
|
|
end
|
|
|
|
|
2012-06-05 09:03:14 -04:00
|
|
|
tests('#all','the only user should match').succeeds do
|
2012-06-04 14:34:58 -04:00
|
|
|
@iam.users.first.id == @user_one_name
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#create','a second user').succeeds do
|
|
|
|
@user_two = @iam.users.create(:id => @user_two_name)
|
|
|
|
@user_two.id == @user_two_name
|
|
|
|
end
|
|
|
|
|
2012-06-05 09:03:14 -04:00
|
|
|
tests('#all','there are two users').succeeds do
|
2012-06-04 14:34:58 -04:00
|
|
|
@iam.users.size == 2
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#get','an existing user').succeeds do
|
|
|
|
@iam.users.get(@user_one_name).id == @user_one_name
|
|
|
|
end
|
|
|
|
|
2012-06-05 09:03:14 -04:00
|
|
|
tests('#get',"returns nil if the user doesn't exists").succeeds do
|
2012-06-04 14:34:58 -04:00
|
|
|
@iam.users.get('non-exists') == nil
|
|
|
|
end
|
|
|
|
|
2012-06-05 09:03:14 -04:00
|
|
|
tests('#policies','it has no policies').succeeds do
|
|
|
|
@iam.users.get(@user_one_name).policies.empty?
|
2012-06-04 14:34:58 -04:00
|
|
|
end
|
|
|
|
|
2012-06-05 09:03:14 -04:00
|
|
|
tests('#access_keys','it has no keys').succeeds do
|
|
|
|
@iam.users.get(@user_one_name).access_keys.empty?
|
2012-06-04 14:34:58 -04:00
|
|
|
end
|
|
|
|
|
2012-11-29 13:51:16 -05:00
|
|
|
tests('#create', 'assigns path').succeeds do
|
|
|
|
@user_three = @iam.users.create(:id => @user_three_name, :path => @user_three_path)
|
|
|
|
@user_three.path == @user_three_path
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#create', 'defaults path to /').succeeds do
|
|
|
|
@user_four = @iam.users.create(:id => @user_four_name)
|
|
|
|
@user_four.path == '/'
|
|
|
|
end
|
|
|
|
|
2012-06-04 14:34:58 -04:00
|
|
|
tests('#destroy','an existing user').succeeds do
|
|
|
|
@iam.users.get(@user_one_name).destroy
|
|
|
|
end
|
|
|
|
|
2012-06-05 09:03:14 -04:00
|
|
|
tests('#destroy','clean up remaining user').succeeds do
|
|
|
|
@iam.users.get(@user_two_name).destroy
|
|
|
|
end
|
|
|
|
|
2012-06-04 14:34:58 -04:00
|
|
|
end
|