subiam 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,150 @@
1
+ describe 'specify target' do
2
+ let(:dsl_another_prefix) do
3
+ <<-RUBY
4
+ target /.*/
5
+
6
+ user "another-prefix-bob", :path=>"/devloper/" do
7
+ login_profile :password_reset_required=>true
8
+
9
+ groups(
10
+ "another-prefix-Admin",
11
+ "another-prefix-SES"
12
+ )
13
+
14
+ policy "S3" do
15
+ {"Statement"=>
16
+ [{"Action"=>
17
+ ["s3:Get*",
18
+ "s3:List*"],
19
+ "Effect"=>"Allow",
20
+ "Resource"=>"*"}]}
21
+ end
22
+ end
23
+
24
+ user "another-prefix-mary", :path=>"/staff/" do
25
+ policy "S3" do
26
+ {"Statement"=>
27
+ [{"Action"=>
28
+ ["s3:Get*",
29
+ "s3:List*"],
30
+ "Effect"=>"Allow",
31
+ "Resource"=>"*"}]}
32
+ end
33
+ end
34
+
35
+ group "another-prefix-Admin", :path=>"/admin/" do
36
+ policy "Admin" do
37
+ {"Statement"=>[{"Effect"=>"Allow", "Action"=>"*", "Resource"=>"*"}]}
38
+ end
39
+ end
40
+
41
+ group "another-prefix-SES", :path=>"/ses/" do
42
+ policy "ses-policy" do
43
+ {"Statement"=>
44
+ [{"Effect"=>"Allow", "Action"=>"ses:SendRawEmail", "Resource"=>"*"}]}
45
+ end
46
+ end
47
+
48
+ role "another-prefix-my-role", :path=>"/any/" do
49
+ instance_profiles(
50
+ "another-prefix-my-instance-profile"
51
+ )
52
+
53
+ assume_role_policy_document do
54
+ {"Version"=>"2012-10-17",
55
+ "Statement"=>
56
+ [{"Sid"=>"",
57
+ "Effect"=>"Allow",
58
+ "Principal"=>{"Service"=>"ec2.amazonaws.com"},
59
+ "Action"=>"sts:AssumeRole"}]}
60
+ end
61
+
62
+ policy "role-policy" do
63
+ {"Statement"=>
64
+ [{"Action"=>
65
+ ["s3:Get*",
66
+ "s3:List*"],
67
+ "Effect"=>"Allow",
68
+ "Resource"=>"*"}]}
69
+ end
70
+ end
71
+
72
+ instance_profile "another-prefix-my-instance-profile", :path=>"/profile/"
73
+ RUBY
74
+ end
75
+
76
+ let(:expected) do
77
+ {:users=>
78
+ {"another-prefix-bob"=>
79
+ {:path=>"/devloper/",
80
+ :groups=>["another-prefix-Admin", "another-prefix-SES"],
81
+ :attached_managed_policies=>[],
82
+ :policies=>
83
+ {"S3"=>
84
+ {"Statement"=>
85
+ [{"Action"=>["s3:Get*", "s3:List*"],
86
+ "Effect"=>"Allow",
87
+ "Resource"=>"*"}]}},
88
+ :login_profile=>{:password_reset_required=>true}},
89
+ "another-prefix-mary"=>
90
+ {:path=>"/staff/",
91
+ :groups=>[],
92
+ :attached_managed_policies=>[],
93
+ :policies=>
94
+ {"S3"=>
95
+ {"Statement"=>
96
+ [{"Action"=>["s3:Get*", "s3:List*"],
97
+ "Effect"=>"Allow",
98
+ "Resource"=>"*"}]}}}},
99
+ :groups=>
100
+ {"another-prefix-Admin"=>
101
+ {:path=>"/admin/",
102
+ :attached_managed_policies=>[],
103
+ :policies=>
104
+ {"Admin"=>
105
+ {"Statement"=>[{"Effect"=>"Allow", "Action"=>"*", "Resource"=>"*"}]}}},
106
+ "another-prefix-SES"=>
107
+ {:path=>"/ses/",
108
+ :attached_managed_policies=>[],
109
+ :policies=>
110
+ {"ses-policy"=>
111
+ {"Statement"=>
112
+ [{"Effect"=>"Allow",
113
+ "Action"=>"ses:SendRawEmail",
114
+ "Resource"=>"*"}]}}}},
115
+ :policies=>{},
116
+ :roles=>
117
+ {"another-prefix-my-role"=>
118
+ {:path=>"/any/",
119
+ :assume_role_policy_document=>
120
+ {"Version"=>"2012-10-17",
121
+ "Statement"=>
122
+ [{"Sid"=>"",
123
+ "Effect"=>"Allow",
124
+ "Principal"=>{"Service"=>"ec2.amazonaws.com"},
125
+ "Action"=>"sts:AssumeRole"}]},
126
+ :instance_profiles=>["another-prefix-my-instance-profile"],
127
+ :attached_managed_policies=>[],
128
+ :policies=>
129
+ {"role-policy"=>
130
+ {"Statement"=>
131
+ [{"Action"=>["s3:Get*", "s3:List*"],
132
+ "Effect"=>"Allow",
133
+ "Resource"=>"*"}]}}}},
134
+ :instance_profiles=>{"another-prefix-my-instance-profile"=>{:path=>"/profile/"}}}
135
+ end
136
+
137
+ before(:each) do
138
+ apply { dsl_another_prefix }
139
+ end
140
+
141
+ context 'apply when empty dsl to exists environment' do
142
+ subject { client }
143
+
144
+ it 'should change nothing' do
145
+ updated = apply(subject) { 'target /^iam-test-/' }
146
+ expect(updated).to be_falsey
147
+ expect(export).to eq expected
148
+ end
149
+ end
150
+ end