forked from flosell/iamspec
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathintegration_spec.rb
38 lines (30 loc) · 1.38 KB
/
integration_spec.rb
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
require 'spec_helper'
describe 'AWS IAM Integration' do
account_id = Iamspec::Helpers::AccountHelper.current_account_id
describe('Using a generic resource') do
describe generic_policy_source("arn:aws:iam::#{account_id}:user/some_user_with_admin_permissions") do
it { should be_allowed_to perform_action('sts:AssumeRole').with_resource("arn:aws:iam::#{account_id}:role/Administrator") }
end
describe generic_policy_source("arn:aws:iam::#{account_id}:user/some_user_without_admin_permissions") do
it { should_not be_allowed_to perform_action('sts:AssumeRole').with_resource("arn:aws:iam::#{account_id}:role/Administrator") }
end
describe generic_policy_source("arn:aws:iam::#{account_id}:role/SomeRole") do
it { should be_allowed_to perform_actions(['ec2:DescribeInstances','ec2:DescribeAddresses','ec2:DescribeVolumes']) }
end
end
describe('Using syntactic sugar') do
describe('for users') do
describe iam_user('some_user_with_admin_permissions') do
it { should be_allowed_to assume_role('Administrator') }
end
describe iam_user('some_user_without_admin_permissions') do
it { should_not be_allowed_to assume_role('Administrator') }
end
end
describe('for roles') do
describe iam_role('SomeRole') do
it { should be_allowed_to perform_action('ec2:DescribeInstances') }
end
end
end
end