cheffish 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +201 -201
- data/README.md +120 -120
- data/Rakefile +23 -23
- data/lib/chef/provider/chef_acl.rb +439 -439
- data/lib/chef/provider/chef_client.rb +53 -53
- data/lib/chef/provider/chef_container.rb +55 -55
- data/lib/chef/provider/chef_data_bag.rb +55 -55
- data/lib/chef/provider/chef_data_bag_item.rb +278 -278
- data/lib/chef/provider/chef_environment.rb +83 -83
- data/lib/chef/provider/chef_group.rb +83 -83
- data/lib/chef/provider/chef_mirror.rb +169 -169
- data/lib/chef/provider/chef_node.rb +87 -87
- data/lib/chef/provider/chef_organization.rb +155 -155
- data/lib/chef/provider/chef_resolved_cookbooks.rb +46 -46
- data/lib/chef/provider/chef_role.rb +84 -84
- data/lib/chef/provider/chef_user.rb +59 -59
- data/lib/chef/provider/private_key.rb +225 -225
- data/lib/chef/provider/public_key.rb +88 -88
- data/lib/chef/resource/chef_acl.rb +69 -69
- data/lib/chef/resource/chef_client.rb +48 -48
- data/lib/chef/resource/chef_container.rb +22 -22
- data/lib/chef/resource/chef_data_bag.rb +22 -22
- data/lib/chef/resource/chef_data_bag_item.rb +121 -121
- data/lib/chef/resource/chef_environment.rb +77 -77
- data/lib/chef/resource/chef_group.rb +53 -53
- data/lib/chef/resource/chef_mirror.rb +52 -52
- data/lib/chef/resource/chef_node.rb +22 -22
- data/lib/chef/resource/chef_organization.rb +69 -69
- data/lib/chef/resource/chef_resolved_cookbooks.rb +35 -35
- data/lib/chef/resource/chef_role.rb +110 -110
- data/lib/chef/resource/chef_user.rb +56 -56
- data/lib/chef/resource/private_key.rb +48 -48
- data/lib/chef/resource/public_key.rb +25 -25
- data/lib/cheffish/actor_provider_base.rb +131 -131
- data/lib/cheffish/basic_chef_client.rb +184 -184
- data/lib/cheffish/chef_provider_base.rb +246 -246
- data/lib/cheffish/chef_run.rb +162 -162
- data/lib/cheffish/chef_run_data.rb +19 -19
- data/lib/cheffish/chef_run_listener.rb +30 -30
- data/lib/cheffish/key_formatter.rb +113 -113
- data/lib/cheffish/merged_config.rb +94 -94
- data/lib/cheffish/recipe_dsl.rb +157 -157
- data/lib/cheffish/rspec/chef_run_support.rb +83 -83
- data/lib/cheffish/rspec/matchers/be_idempotent.rb +16 -16
- data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +15 -15
- data/lib/cheffish/rspec/matchers/have_updated.rb +37 -37
- data/lib/cheffish/rspec/matchers/partially_match.rb +63 -63
- data/lib/cheffish/rspec/matchers.rb +4 -4
- data/lib/cheffish/rspec/recipe_run_wrapper.rb +78 -59
- data/lib/cheffish/rspec/repository_support.rb +108 -108
- data/lib/cheffish/rspec.rb +8 -8
- data/lib/cheffish/server_api.rb +52 -52
- data/lib/cheffish/version.rb +3 -3
- data/lib/cheffish/with_pattern.rb +21 -21
- data/lib/cheffish.rb +235 -235
- data/spec/functional/fingerprint_spec.rb +64 -64
- data/spec/functional/merged_config_spec.rb +19 -19
- data/spec/functional/server_api_spec.rb +13 -13
- data/spec/integration/chef_acl_spec.rb +879 -879
- data/spec/integration/chef_client_spec.rb +105 -105
- data/spec/integration/chef_container_spec.rb +33 -33
- data/spec/integration/chef_group_spec.rb +309 -309
- data/spec/integration/chef_mirror_spec.rb +491 -491
- data/spec/integration/chef_node_spec.rb +786 -786
- data/spec/integration/chef_organization_spec.rb +226 -226
- data/spec/integration/chef_role_spec.rb +78 -78
- data/spec/integration/chef_user_spec.rb +85 -85
- data/spec/integration/private_key_spec.rb +399 -399
- data/spec/integration/recipe_dsl_spec.rb +28 -28
- data/spec/integration/rspec/converge_spec.rb +183 -183
- data/spec/support/key_support.rb +29 -29
- data/spec/support/spec_support.rb +15 -15
- data/spec/unit/get_private_key_spec.rb +131 -131
- data/spec/unit/recipe_run_wrapper_spec.rb +37 -37
- metadata +3 -2
@@ -1,226 +1,226 @@
|
|
1
|
-
require 'support/spec_support'
|
2
|
-
require 'cheffish/rspec/chef_run_support'
|
3
|
-
require 'chef/resource/chef_organization'
|
4
|
-
require 'chef/provider/chef_organization'
|
5
|
-
|
6
|
-
describe Chef::Resource::ChefOrganization do
|
7
|
-
extend Cheffish::RSpec::ChefRunSupport
|
8
|
-
|
9
|
-
when_the_chef_12_server 'is in multi-org mode' do
|
10
|
-
context 'and chef_server_url is pointed at the top level' do
|
11
|
-
user 'u', {}
|
12
|
-
user 'u2', {}
|
13
|
-
|
14
|
-
it 'chef_organization "x" creates the organization' do
|
15
|
-
expect_recipe {
|
16
|
-
chef_organization 'x'
|
17
|
-
}.to have_updated('chef_organization[x]', :create)
|
18
|
-
expect(get('/organizations/x')['full_name']).to eq('x')
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'and chef_server_url is pointed at /organizations/foo' do
|
23
|
-
organization 'foo'
|
24
|
-
|
25
|
-
before :each do
|
26
|
-
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'and is empty' do
|
30
|
-
user 'u', {}
|
31
|
-
user 'u2', {}
|
32
|
-
|
33
|
-
it 'chef_organization "x" creates the organization' do
|
34
|
-
expect_recipe {
|
35
|
-
chef_organization 'x'
|
36
|
-
}.to have_updated('chef_organization[x]', :create)
|
37
|
-
expect(get('/organizations/x')['full_name']).to eq('x')
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'chef_organization "x" with full_name creates the organization' do
|
41
|
-
expect_recipe {
|
42
|
-
chef_organization 'x' do
|
43
|
-
full_name 'Hi'
|
44
|
-
end
|
45
|
-
}.to have_updated('chef_organization[x]', :create)
|
46
|
-
expect(get('/organizations/x')['full_name']).to eq('Hi')
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'chef_organization "x" and inviting users creates the invites' do
|
50
|
-
expect_recipe {
|
51
|
-
chef_organization 'x' do
|
52
|
-
invites 'u', 'u2'
|
53
|
-
end
|
54
|
-
}.to have_updated('chef_organization[x]', :create)
|
55
|
-
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(u u2))
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'chef_organization "x" adds members' do
|
59
|
-
expect_recipe {
|
60
|
-
chef_organization 'x' do
|
61
|
-
members 'u', 'u2'
|
62
|
-
end
|
63
|
-
}.to have_updated('chef_organization[x]', :create)
|
64
|
-
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(u u2))
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'and already has an organization named x' do
|
69
|
-
user 'u', {}
|
70
|
-
user 'u2', {}
|
71
|
-
user 'u3', {}
|
72
|
-
user 'member', {}
|
73
|
-
user 'member2', {}
|
74
|
-
user 'invited', {}
|
75
|
-
user 'invited2', {}
|
76
|
-
organization 'x', { 'full_name' => 'Lo' } do
|
77
|
-
org_member 'member', 'member2'
|
78
|
-
org_invite 'invited', 'invited2'
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'chef_organization "x" changes nothing' do
|
82
|
-
expect_recipe {
|
83
|
-
chef_organization 'x'
|
84
|
-
}.not_to have_updated('chef_organization[x]', :create)
|
85
|
-
expect(get('/organizations/x')['full_name']).to eq('Lo')
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'chef_organization "x" with "complete true" reverts the full_name' do
|
89
|
-
expect_recipe {
|
90
|
-
chef_organization 'x' do
|
91
|
-
complete true
|
92
|
-
end
|
93
|
-
}.to have_updated('chef_organization[x]', :create)
|
94
|
-
expect(get('/organizations/x')['full_name']).to eq('x')
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'chef_organization "x" with new full_name updates the organization' do
|
98
|
-
expect_recipe {
|
99
|
-
chef_organization 'x' do
|
100
|
-
full_name 'Hi'
|
101
|
-
end
|
102
|
-
}.to have_updated('chef_organization[x]', :create)
|
103
|
-
expect(get('/organizations/x')['full_name']).to eq('Hi')
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'invites and membership tests' do
|
107
|
-
it 'chef_organization "x" and inviting users creates the invites' do
|
108
|
-
expect_recipe {
|
109
|
-
chef_organization 'x' do
|
110
|
-
invites 'u', 'u2'
|
111
|
-
end
|
112
|
-
}.to have_updated('chef_organization[x]', :create)
|
113
|
-
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2 u u2))
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'chef_organization "x" adds members' do
|
117
|
-
expect_recipe {
|
118
|
-
chef_organization 'x' do
|
119
|
-
members 'u', 'u2'
|
120
|
-
end
|
121
|
-
}.to have_updated('chef_organization[x]', :create)
|
122
|
-
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2 u u2))
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'chef_organization "x" does nothing when inviting already-invited users and members' do
|
126
|
-
expect_recipe {
|
127
|
-
chef_organization 'x' do
|
128
|
-
invites 'invited', 'member'
|
129
|
-
end
|
130
|
-
}.not_to have_updated('chef_organization[x]', :create)
|
131
|
-
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2))
|
132
|
-
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'chef_organization "x" does nothing when adding members who are already members' do
|
136
|
-
expect_recipe {
|
137
|
-
chef_organization 'x' do
|
138
|
-
members 'member'
|
139
|
-
end
|
140
|
-
}.not_to have_updated('chef_organization[x]', :create)
|
141
|
-
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2))
|
142
|
-
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'chef_organization "x" upgrades invites to members when asked' do
|
146
|
-
expect_recipe {
|
147
|
-
chef_organization 'x' do
|
148
|
-
members 'invited'
|
149
|
-
end
|
150
|
-
}.to have_updated('chef_organization[x]', :create)
|
151
|
-
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(invited member member2))
|
152
|
-
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited2))
|
153
|
-
end
|
154
|
-
|
155
|
-
it 'chef_organization "x" removes members and invites when asked' do
|
156
|
-
expect_recipe {
|
157
|
-
chef_organization 'x' do
|
158
|
-
remove_members 'invited', 'member'
|
159
|
-
end
|
160
|
-
}.to have_updated('chef_organization[x]', :create)
|
161
|
-
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited2))
|
162
|
-
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member2))
|
163
|
-
end
|
164
|
-
|
165
|
-
it 'chef_organization "x" does nothing when asked to remove non-members' do
|
166
|
-
expect_recipe {
|
167
|
-
chef_organization 'x' do
|
168
|
-
remove_members 'u', 'u2'
|
169
|
-
end
|
170
|
-
}.not_to have_updated('chef_organization[x]', :create)
|
171
|
-
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2))
|
172
|
-
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'chef_organization "x" with "complete true" reverts the full_name but does not remove invites or members' do
|
176
|
-
expect_recipe {
|
177
|
-
chef_organization 'x' do
|
178
|
-
complete true
|
179
|
-
end
|
180
|
-
}.to have_updated('chef_organization[x]', :create)
|
181
|
-
expect(get('/organizations/x')['full_name']).to eq('x')
|
182
|
-
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2))
|
183
|
-
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
|
184
|
-
end
|
185
|
-
|
186
|
-
it 'chef_organization "x" with members [] and "complete true" removes invites and members' do
|
187
|
-
expect_recipe {
|
188
|
-
chef_organization 'x' do
|
189
|
-
members []
|
190
|
-
complete true
|
191
|
-
end
|
192
|
-
}.to have_updated('chef_organization[x]', :create)
|
193
|
-
expect(get('/organizations/x')['full_name']).to eq('x')
|
194
|
-
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq([])
|
195
|
-
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq([])
|
196
|
-
end
|
197
|
-
|
198
|
-
it 'chef_organization "x" with members [] and "complete true" removes invites but not members' do
|
199
|
-
expect_recipe {
|
200
|
-
chef_organization 'x' do
|
201
|
-
invites []
|
202
|
-
complete true
|
203
|
-
end
|
204
|
-
}.to have_updated('chef_organization[x]', :create)
|
205
|
-
expect(get('/organizations/x')['full_name']).to eq('x')
|
206
|
-
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq([])
|
207
|
-
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
|
208
|
-
end
|
209
|
-
|
210
|
-
it 'chef_organization "x" with invites, members and "complete true" removes all non-specified invites and members' do
|
211
|
-
expect_recipe {
|
212
|
-
chef_organization 'x' do
|
213
|
-
invites 'invited', 'u'
|
214
|
-
members 'member', 'u2'
|
215
|
-
complete true
|
216
|
-
end
|
217
|
-
}.to have_updated('chef_organization[x]', :create)
|
218
|
-
expect(get('/organizations/x')['full_name']).to eq('x')
|
219
|
-
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited u))
|
220
|
-
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member u2))
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
1
|
+
require 'support/spec_support'
|
2
|
+
require 'cheffish/rspec/chef_run_support'
|
3
|
+
require 'chef/resource/chef_organization'
|
4
|
+
require 'chef/provider/chef_organization'
|
5
|
+
|
6
|
+
describe Chef::Resource::ChefOrganization do
|
7
|
+
extend Cheffish::RSpec::ChefRunSupport
|
8
|
+
|
9
|
+
when_the_chef_12_server 'is in multi-org mode' do
|
10
|
+
context 'and chef_server_url is pointed at the top level' do
|
11
|
+
user 'u', {}
|
12
|
+
user 'u2', {}
|
13
|
+
|
14
|
+
it 'chef_organization "x" creates the organization' do
|
15
|
+
expect_recipe {
|
16
|
+
chef_organization 'x'
|
17
|
+
}.to have_updated('chef_organization[x]', :create)
|
18
|
+
expect(get('/organizations/x')['full_name']).to eq('x')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'and chef_server_url is pointed at /organizations/foo' do
|
23
|
+
organization 'foo'
|
24
|
+
|
25
|
+
before :each do
|
26
|
+
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'and is empty' do
|
30
|
+
user 'u', {}
|
31
|
+
user 'u2', {}
|
32
|
+
|
33
|
+
it 'chef_organization "x" creates the organization' do
|
34
|
+
expect_recipe {
|
35
|
+
chef_organization 'x'
|
36
|
+
}.to have_updated('chef_organization[x]', :create)
|
37
|
+
expect(get('/organizations/x')['full_name']).to eq('x')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'chef_organization "x" with full_name creates the organization' do
|
41
|
+
expect_recipe {
|
42
|
+
chef_organization 'x' do
|
43
|
+
full_name 'Hi'
|
44
|
+
end
|
45
|
+
}.to have_updated('chef_organization[x]', :create)
|
46
|
+
expect(get('/organizations/x')['full_name']).to eq('Hi')
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'chef_organization "x" and inviting users creates the invites' do
|
50
|
+
expect_recipe {
|
51
|
+
chef_organization 'x' do
|
52
|
+
invites 'u', 'u2'
|
53
|
+
end
|
54
|
+
}.to have_updated('chef_organization[x]', :create)
|
55
|
+
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(u u2))
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'chef_organization "x" adds members' do
|
59
|
+
expect_recipe {
|
60
|
+
chef_organization 'x' do
|
61
|
+
members 'u', 'u2'
|
62
|
+
end
|
63
|
+
}.to have_updated('chef_organization[x]', :create)
|
64
|
+
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(u u2))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'and already has an organization named x' do
|
69
|
+
user 'u', {}
|
70
|
+
user 'u2', {}
|
71
|
+
user 'u3', {}
|
72
|
+
user 'member', {}
|
73
|
+
user 'member2', {}
|
74
|
+
user 'invited', {}
|
75
|
+
user 'invited2', {}
|
76
|
+
organization 'x', { 'full_name' => 'Lo' } do
|
77
|
+
org_member 'member', 'member2'
|
78
|
+
org_invite 'invited', 'invited2'
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'chef_organization "x" changes nothing' do
|
82
|
+
expect_recipe {
|
83
|
+
chef_organization 'x'
|
84
|
+
}.not_to have_updated('chef_organization[x]', :create)
|
85
|
+
expect(get('/organizations/x')['full_name']).to eq('Lo')
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'chef_organization "x" with "complete true" reverts the full_name' do
|
89
|
+
expect_recipe {
|
90
|
+
chef_organization 'x' do
|
91
|
+
complete true
|
92
|
+
end
|
93
|
+
}.to have_updated('chef_organization[x]', :create)
|
94
|
+
expect(get('/organizations/x')['full_name']).to eq('x')
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'chef_organization "x" with new full_name updates the organization' do
|
98
|
+
expect_recipe {
|
99
|
+
chef_organization 'x' do
|
100
|
+
full_name 'Hi'
|
101
|
+
end
|
102
|
+
}.to have_updated('chef_organization[x]', :create)
|
103
|
+
expect(get('/organizations/x')['full_name']).to eq('Hi')
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'invites and membership tests' do
|
107
|
+
it 'chef_organization "x" and inviting users creates the invites' do
|
108
|
+
expect_recipe {
|
109
|
+
chef_organization 'x' do
|
110
|
+
invites 'u', 'u2'
|
111
|
+
end
|
112
|
+
}.to have_updated('chef_organization[x]', :create)
|
113
|
+
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2 u u2))
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'chef_organization "x" adds members' do
|
117
|
+
expect_recipe {
|
118
|
+
chef_organization 'x' do
|
119
|
+
members 'u', 'u2'
|
120
|
+
end
|
121
|
+
}.to have_updated('chef_organization[x]', :create)
|
122
|
+
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2 u u2))
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'chef_organization "x" does nothing when inviting already-invited users and members' do
|
126
|
+
expect_recipe {
|
127
|
+
chef_organization 'x' do
|
128
|
+
invites 'invited', 'member'
|
129
|
+
end
|
130
|
+
}.not_to have_updated('chef_organization[x]', :create)
|
131
|
+
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2))
|
132
|
+
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'chef_organization "x" does nothing when adding members who are already members' do
|
136
|
+
expect_recipe {
|
137
|
+
chef_organization 'x' do
|
138
|
+
members 'member'
|
139
|
+
end
|
140
|
+
}.not_to have_updated('chef_organization[x]', :create)
|
141
|
+
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2))
|
142
|
+
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'chef_organization "x" upgrades invites to members when asked' do
|
146
|
+
expect_recipe {
|
147
|
+
chef_organization 'x' do
|
148
|
+
members 'invited'
|
149
|
+
end
|
150
|
+
}.to have_updated('chef_organization[x]', :create)
|
151
|
+
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(invited member member2))
|
152
|
+
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited2))
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'chef_organization "x" removes members and invites when asked' do
|
156
|
+
expect_recipe {
|
157
|
+
chef_organization 'x' do
|
158
|
+
remove_members 'invited', 'member'
|
159
|
+
end
|
160
|
+
}.to have_updated('chef_organization[x]', :create)
|
161
|
+
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited2))
|
162
|
+
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member2))
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'chef_organization "x" does nothing when asked to remove non-members' do
|
166
|
+
expect_recipe {
|
167
|
+
chef_organization 'x' do
|
168
|
+
remove_members 'u', 'u2'
|
169
|
+
end
|
170
|
+
}.not_to have_updated('chef_organization[x]', :create)
|
171
|
+
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2))
|
172
|
+
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'chef_organization "x" with "complete true" reverts the full_name but does not remove invites or members' do
|
176
|
+
expect_recipe {
|
177
|
+
chef_organization 'x' do
|
178
|
+
complete true
|
179
|
+
end
|
180
|
+
}.to have_updated('chef_organization[x]', :create)
|
181
|
+
expect(get('/organizations/x')['full_name']).to eq('x')
|
182
|
+
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2))
|
183
|
+
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'chef_organization "x" with members [] and "complete true" removes invites and members' do
|
187
|
+
expect_recipe {
|
188
|
+
chef_organization 'x' do
|
189
|
+
members []
|
190
|
+
complete true
|
191
|
+
end
|
192
|
+
}.to have_updated('chef_organization[x]', :create)
|
193
|
+
expect(get('/organizations/x')['full_name']).to eq('x')
|
194
|
+
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq([])
|
195
|
+
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq([])
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'chef_organization "x" with members [] and "complete true" removes invites but not members' do
|
199
|
+
expect_recipe {
|
200
|
+
chef_organization 'x' do
|
201
|
+
invites []
|
202
|
+
complete true
|
203
|
+
end
|
204
|
+
}.to have_updated('chef_organization[x]', :create)
|
205
|
+
expect(get('/organizations/x')['full_name']).to eq('x')
|
206
|
+
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq([])
|
207
|
+
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'chef_organization "x" with invites, members and "complete true" removes all non-specified invites and members' do
|
211
|
+
expect_recipe {
|
212
|
+
chef_organization 'x' do
|
213
|
+
invites 'invited', 'u'
|
214
|
+
members 'member', 'u2'
|
215
|
+
complete true
|
216
|
+
end
|
217
|
+
}.to have_updated('chef_organization[x]', :create)
|
218
|
+
expect(get('/organizations/x')['full_name']).to eq('x')
|
219
|
+
expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited u))
|
220
|
+
expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member u2))
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
@@ -1,78 +1,78 @@
|
|
1
|
-
require 'support/spec_support'
|
2
|
-
require 'cheffish/rspec/chef_run_support'
|
3
|
-
require 'chef/resource/chef_role'
|
4
|
-
require 'chef/provider/chef_role'
|
5
|
-
|
6
|
-
describe Chef::Resource::ChefRole do
|
7
|
-
extend Cheffish::RSpec::ChefRunSupport
|
8
|
-
|
9
|
-
when_the_chef_12_server 'is in multi-org mode' do
|
10
|
-
organization 'foo'
|
11
|
-
|
12
|
-
before :each do
|
13
|
-
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'and is empty' do
|
17
|
-
context 'and we run a recipe that creates role "blah"' do
|
18
|
-
it 'the role gets created' do
|
19
|
-
expect_recipe {
|
20
|
-
chef_role 'blah'
|
21
|
-
}.to have_updated 'chef_role[blah]', :create
|
22
|
-
expect(get('roles/blah')['name']).to eq('blah')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# TODO why-run mode
|
27
|
-
|
28
|
-
context 'and another chef server is running on port 8899' do
|
29
|
-
before :each do
|
30
|
-
@server = ChefZero::Server.new(:port => 8899)
|
31
|
-
@server.start_background
|
32
|
-
end
|
33
|
-
|
34
|
-
after :each do
|
35
|
-
@server.stop
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'and a recipe is run that creates role "blah" on the second chef server using with_chef_server' do
|
39
|
-
|
40
|
-
it 'the role is created on the second chef server but not the first' do
|
41
|
-
expect_recipe {
|
42
|
-
with_chef_server 'http://127.0.0.1:8899'
|
43
|
-
chef_role 'blah'
|
44
|
-
}.to have_updated 'chef_role[blah]', :create
|
45
|
-
expect { get('roles/blah') }.to raise_error(Net::HTTPServerException)
|
46
|
-
expect(get('http://127.0.0.1:8899/roles/blah')['name']).to eq('blah')
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'and a recipe is run that creates role "blah" on the second chef server using chef_server' do
|
51
|
-
|
52
|
-
it 'the role is created on the second chef server but not the first' do
|
53
|
-
expect_recipe {
|
54
|
-
chef_role 'blah' do
|
55
|
-
chef_server({ :chef_server_url => 'http://127.0.0.1:8899' })
|
56
|
-
end
|
57
|
-
}.to have_updated 'chef_role[blah]', :create
|
58
|
-
expect { get('roles/blah') }.to raise_error(Net::HTTPServerException)
|
59
|
-
expect(get('http://127.0.0.1:8899/roles/blah')['name']).to eq('blah')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
when_the_chef_server 'is in OSC mode' do
|
67
|
-
context 'and is empty' do
|
68
|
-
context 'and we run a recipe that creates role "blah"' do
|
69
|
-
it 'the role gets created' do
|
70
|
-
expect_recipe {
|
71
|
-
chef_role 'blah'
|
72
|
-
}.to have_updated 'chef_role[blah]', :create
|
73
|
-
expect(get('roles/blah')['name']).to eq('blah')
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
1
|
+
require 'support/spec_support'
|
2
|
+
require 'cheffish/rspec/chef_run_support'
|
3
|
+
require 'chef/resource/chef_role'
|
4
|
+
require 'chef/provider/chef_role'
|
5
|
+
|
6
|
+
describe Chef::Resource::ChefRole do
|
7
|
+
extend Cheffish::RSpec::ChefRunSupport
|
8
|
+
|
9
|
+
when_the_chef_12_server 'is in multi-org mode' do
|
10
|
+
organization 'foo'
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'and is empty' do
|
17
|
+
context 'and we run a recipe that creates role "blah"' do
|
18
|
+
it 'the role gets created' do
|
19
|
+
expect_recipe {
|
20
|
+
chef_role 'blah'
|
21
|
+
}.to have_updated 'chef_role[blah]', :create
|
22
|
+
expect(get('roles/blah')['name']).to eq('blah')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# TODO why-run mode
|
27
|
+
|
28
|
+
context 'and another chef server is running on port 8899' do
|
29
|
+
before :each do
|
30
|
+
@server = ChefZero::Server.new(:port => 8899)
|
31
|
+
@server.start_background
|
32
|
+
end
|
33
|
+
|
34
|
+
after :each do
|
35
|
+
@server.stop
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'and a recipe is run that creates role "blah" on the second chef server using with_chef_server' do
|
39
|
+
|
40
|
+
it 'the role is created on the second chef server but not the first' do
|
41
|
+
expect_recipe {
|
42
|
+
with_chef_server 'http://127.0.0.1:8899'
|
43
|
+
chef_role 'blah'
|
44
|
+
}.to have_updated 'chef_role[blah]', :create
|
45
|
+
expect { get('roles/blah') }.to raise_error(Net::HTTPServerException)
|
46
|
+
expect(get('http://127.0.0.1:8899/roles/blah')['name']).to eq('blah')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'and a recipe is run that creates role "blah" on the second chef server using chef_server' do
|
51
|
+
|
52
|
+
it 'the role is created on the second chef server but not the first' do
|
53
|
+
expect_recipe {
|
54
|
+
chef_role 'blah' do
|
55
|
+
chef_server({ :chef_server_url => 'http://127.0.0.1:8899' })
|
56
|
+
end
|
57
|
+
}.to have_updated 'chef_role[blah]', :create
|
58
|
+
expect { get('roles/blah') }.to raise_error(Net::HTTPServerException)
|
59
|
+
expect(get('http://127.0.0.1:8899/roles/blah')['name']).to eq('blah')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
when_the_chef_server 'is in OSC mode' do
|
67
|
+
context 'and is empty' do
|
68
|
+
context 'and we run a recipe that creates role "blah"' do
|
69
|
+
it 'the role gets created' do
|
70
|
+
expect_recipe {
|
71
|
+
chef_role 'blah'
|
72
|
+
}.to have_updated 'chef_role[blah]', :create
|
73
|
+
expect(get('roles/blah')['name']).to eq('blah')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|