socialcast 1.3.16 → 1.3.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +2 -2
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/config/ldap.yml +3 -0
- data/lib/socialcast/command_line/provision_user.rb +22 -2
- data/lib/socialcast/command_line/version.rb +1 -1
- data/lib/socialcast.rb +4 -1
- data/socialcast.gemspec +2 -2
- data/spec/socialcast/command_line/authenticate_spec.rb +5 -5
- data/spec/socialcast/command_line/cli_spec.rb +110 -110
- data/spec/socialcast/command_line/ldap_connector_spec.rb +45 -45
- data/spec/socialcast/command_line/provision_photo_spec.rb +35 -35
- data/spec/socialcast/command_line/provision_user_spec.rb +97 -71
- data/spec/socialcast/socialcast_spec.rb +32 -10
- data/spec/spec_helper.rb +1 -2
- metadata +5 -5
@@ -15,20 +15,20 @@ describe Socialcast::CommandLine::CLI do
|
|
15
15
|
let(:another_profile_photo_id) { 4 }
|
16
16
|
|
17
17
|
before do
|
18
|
-
Socialcast::CommandLine.
|
19
|
-
Socialcast::CommandLine::ProvisionPhoto.
|
18
|
+
allow(Socialcast::CommandLine).to receive(:credentials).and_return(credentials)
|
19
|
+
allow_any_instance_of(Socialcast::CommandLine::ProvisionPhoto).to receive(:default_profile_photo_id).and_return(default_profile_photo_id)
|
20
20
|
end
|
21
21
|
|
22
22
|
let(:ldap) do
|
23
23
|
ldap_instance = double(Net::LDAP, :auth => nil, :encryption => nil)
|
24
|
-
ldap_instance.
|
25
|
-
Net::LDAP.
|
24
|
+
expect(ldap_instance).to receive(:open).and_yield
|
25
|
+
expect(Net::LDAP).to receive(:new).and_return(ldap_instance)
|
26
26
|
ldap_instance
|
27
27
|
end
|
28
28
|
|
29
29
|
describe '#info' do
|
30
30
|
before do
|
31
|
-
Socialcast::CommandLine::CLI.
|
31
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:say).with("Socialcast Command Line #{Socialcast::CommandLine::VERSION}")
|
32
32
|
end
|
33
33
|
context '--version' do
|
34
34
|
before do
|
@@ -51,11 +51,11 @@ describe Socialcast::CommandLine::CLI do
|
|
51
51
|
let(:first_tenant_domain) { 'test1.socialcast.com' }
|
52
52
|
let(:second_tenant_domain) { 'test2.socialcast.com' }
|
53
53
|
before do
|
54
|
-
Socialcast::CommandLine.
|
54
|
+
expect(Socialcast::CommandLine).to receive(:credentials=).with({
|
55
55
|
:domain => default_domain,
|
56
56
|
:proxy => nil
|
57
57
|
})
|
58
|
-
Socialcast::CommandLine.
|
58
|
+
expect(Socialcast::CommandLine).to receive(:credentials=).with({
|
59
59
|
:user => user,
|
60
60
|
:password => password,
|
61
61
|
:domain => domain_to_set
|
@@ -88,11 +88,11 @@ describe Socialcast::CommandLine::CLI do
|
|
88
88
|
let(:api_client_secret) { 'my-client-secret' }
|
89
89
|
let(:domain) { 'api.socialcast.com' }
|
90
90
|
before do
|
91
|
-
Socialcast::CommandLine.
|
91
|
+
expect(Socialcast::CommandLine).to receive(:credentials=).with({
|
92
92
|
:domain => 'api.socialcast.com',
|
93
93
|
:proxy => nil
|
94
94
|
})
|
95
|
-
Socialcast::CommandLine.
|
95
|
+
expect(Socialcast::CommandLine).to receive(:credentials=).with({
|
96
96
|
:api_client_identifier => api_client_identifier,
|
97
97
|
:api_client_secret => api_client_secret,
|
98
98
|
})
|
@@ -168,7 +168,7 @@ describe Socialcast::CommandLine::CLI do
|
|
168
168
|
context "with no profile_photo mapping" do
|
169
169
|
let(:config_file) { ldap_default_config_file }
|
170
170
|
it "reports an error" do
|
171
|
-
|
171
|
+
expect { Socialcast::CommandLine::CLI.start ['sync_photos', '-c', config_file] }.to raise_error Socialcast::CommandLine::Provisioner::ProvisionError
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
@@ -179,7 +179,7 @@ describe Socialcast::CommandLine::CLI do
|
|
179
179
|
@entry = Net::LDAP::Entry.new("dc=example,dc=com")
|
180
180
|
@entry[:mail] = 'ryan@example.com'
|
181
181
|
@entry[:jpegPhoto] = photo_data
|
182
|
-
ldap.
|
182
|
+
expect(ldap).to receive(:search).and_yield(@entry)
|
183
183
|
|
184
184
|
user_search_resource = double(:user_search_resource)
|
185
185
|
search_api_response = {
|
@@ -195,16 +195,16 @@ describe Socialcast::CommandLine::CLI do
|
|
195
195
|
}
|
196
196
|
]
|
197
197
|
}
|
198
|
-
user_search_resource.
|
199
|
-
Socialcast::CommandLine.
|
198
|
+
expect(user_search_resource).to receive(:get).and_return(search_api_response.to_json)
|
199
|
+
allow(Socialcast::CommandLine).to receive(:resource_for_path).with('/api/users/search', anything).and_return(user_search_resource)
|
200
200
|
|
201
201
|
user_resource = double(:user_resource)
|
202
|
-
user_resource.
|
202
|
+
expect(user_resource).to receive(:put) do |data|
|
203
203
|
uploaded_data = data[:user][:profile_photo][:data]
|
204
|
-
uploaded_data.read.force_encoding('binary').
|
205
|
-
uploaded_data.path.
|
204
|
+
expect(uploaded_data.read.force_encoding('binary')).to eq(photo_data)
|
205
|
+
expect(uploaded_data.path).to match(/\.png\Z/)
|
206
206
|
end
|
207
|
-
Socialcast::CommandLine.
|
207
|
+
allow(Socialcast::CommandLine).to receive(:resource_for_path).with('/api/users/7', anything).and_return(user_resource)
|
208
208
|
|
209
209
|
Socialcast::CommandLine::CLI.start ['sync_photos', '-c', config_file]
|
210
210
|
end
|
@@ -218,7 +218,7 @@ describe Socialcast::CommandLine::CLI do
|
|
218
218
|
@entry = Net::LDAP::Entry.new("dc=example,dc=com")
|
219
219
|
@entry[:mail] = 'ryan@example.com'
|
220
220
|
@entry[:jpegPhoto] = photo_data
|
221
|
-
ldap.
|
221
|
+
expect(ldap).to receive(:search).and_yield(@entry)
|
222
222
|
|
223
223
|
user_search_resource = double(:user_search_resource)
|
224
224
|
search_api_response = {
|
@@ -234,12 +234,12 @@ describe Socialcast::CommandLine::CLI do
|
|
234
234
|
}
|
235
235
|
]
|
236
236
|
}
|
237
|
-
user_search_resource.
|
238
|
-
Socialcast::CommandLine.
|
237
|
+
expect(user_search_resource).to receive(:get).and_return(search_api_response.to_json)
|
238
|
+
allow(Socialcast::CommandLine).to receive(:resource_for_path).with('/api/users/search', anything).and_return(user_search_resource)
|
239
239
|
|
240
240
|
user_resource = double(:user_resource)
|
241
|
-
user_resource.
|
242
|
-
Socialcast::CommandLine.
|
241
|
+
expect(user_resource).not_to receive(:put)
|
242
|
+
allow(Socialcast::CommandLine).to receive(:resource_for_path).with('/api/users/7', anything).and_return(user_resource)
|
243
243
|
|
244
244
|
Socialcast::CommandLine::CLI.start ['sync_photos', '-c', config_file]
|
245
245
|
end
|
@@ -253,7 +253,7 @@ describe Socialcast::CommandLine::CLI do
|
|
253
253
|
@entry = Net::LDAP::Entry.new("dc=example,dc=com")
|
254
254
|
@entry[:mail] = 'ryan@example.com'
|
255
255
|
@entry[:jpegPhoto] = photo_data
|
256
|
-
ldap.
|
256
|
+
expect(ldap).to receive(:search).and_yield(@entry)
|
257
257
|
|
258
258
|
user_search_resource = double(:user_search_resource)
|
259
259
|
search_api_response = {
|
@@ -269,12 +269,12 @@ describe Socialcast::CommandLine::CLI do
|
|
269
269
|
}
|
270
270
|
]
|
271
271
|
}
|
272
|
-
user_search_resource.
|
273
|
-
Socialcast::CommandLine.
|
272
|
+
expect(user_search_resource).to receive(:get).and_return(search_api_response.to_json)
|
273
|
+
allow(Socialcast::CommandLine).to receive(:resource_for_path).with('/api/users/search', anything).and_return(user_search_resource)
|
274
274
|
|
275
275
|
user_resource = double(:user_resource)
|
276
|
-
user_resource.
|
277
|
-
Socialcast::CommandLine.
|
276
|
+
expect(user_resource).not_to receive(:put)
|
277
|
+
allow(Socialcast::CommandLine).to receive(:resource_for_path).with('/api/users/7', anything).and_return(user_resource)
|
278
278
|
|
279
279
|
Socialcast::CommandLine::CLI.start ['sync_photos', '-c', config_file]
|
280
280
|
end
|
@@ -290,30 +290,30 @@ describe Socialcast::CommandLine::CLI do
|
|
290
290
|
end
|
291
291
|
context 'with 0 users found in ldap' do
|
292
292
|
before do
|
293
|
-
ldap.
|
293
|
+
expect(ldap).to receive(:search).and_return(nil)
|
294
294
|
|
295
295
|
@result = ''
|
296
|
-
Zlib::GzipWriter.
|
297
|
-
Socialcast::CommandLine::CLI.
|
298
|
-
File.
|
296
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(@result)
|
297
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).and_return(ldap_without_permission_mappings_config)
|
298
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
299
299
|
|
300
|
-
RestClient::Resource.
|
300
|
+
expect_any_instance_of(RestClient::Resource).not_to receive(:post)
|
301
301
|
end
|
302
302
|
it 'does not post to Socialcast and raises error' do
|
303
|
-
|
303
|
+
expect { Socialcast::CommandLine::CLI.start ['provision'] }.to raise_error SystemExit
|
304
304
|
end
|
305
305
|
end
|
306
306
|
context 'with 0 users found in ldap and force option passed' do
|
307
307
|
before do
|
308
|
-
ldap.
|
308
|
+
expect(ldap).to receive(:search).and_return(nil)
|
309
309
|
|
310
310
|
@result = ''
|
311
|
-
Zlib::GzipWriter.
|
312
|
-
Socialcast::CommandLine::CLI.
|
311
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(@result)
|
312
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).and_return(ldap_without_permission_mappings_config)
|
313
313
|
|
314
|
-
File.
|
314
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
315
315
|
|
316
|
-
RestClient::Resource.
|
316
|
+
expect_any_instance_of(RestClient::Resource).to receive(:post).once
|
317
317
|
|
318
318
|
Socialcast::CommandLine::CLI.start ['provision', '-f']
|
319
319
|
end
|
@@ -321,17 +321,17 @@ describe Socialcast::CommandLine::CLI do
|
|
321
321
|
end
|
322
322
|
context 'with socialcast returning 401' do
|
323
323
|
before do
|
324
|
-
ldap.
|
324
|
+
expect(ldap).to receive(:search).and_return(nil)
|
325
325
|
|
326
326
|
@result = ''
|
327
|
-
Zlib::GzipWriter.
|
328
|
-
Socialcast::CommandLine::CLI.
|
327
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(@result)
|
328
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).and_return(ldap_without_permission_mappings_config)
|
329
329
|
|
330
|
-
File.
|
330
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
331
331
|
rest_client_resource = double(:rest_client_resource)
|
332
|
-
rest_client_resource.
|
333
|
-
Socialcast::CommandLine.
|
334
|
-
Kernel.
|
332
|
+
allow(rest_client_resource).to receive(:post).and_raise(RestClient::Unauthorized.new(double('Unauthorized HTTP Response', :code => '401', :body => 'Unauthorized HTTP Response')))
|
333
|
+
allow(Socialcast::CommandLine).to receive(:resource_for_path).and_return(rest_client_resource)
|
334
|
+
expect(Kernel).to receive(:abort).with(an_instance_of(String)).once
|
335
335
|
|
336
336
|
Socialcast::CommandLine::CLI.start ['provision', '-f']
|
337
337
|
end
|
@@ -341,13 +341,13 @@ describe Socialcast::CommandLine::CLI do
|
|
341
341
|
before do
|
342
342
|
@entry = Net::LDAP::Entry.new("dc=example,dc=com")
|
343
343
|
@entry[:mail] = 'ryan@example.com'
|
344
|
-
ldap.
|
344
|
+
expect(ldap).to receive(:search).and_yield(@entry)
|
345
345
|
|
346
346
|
@result = ''
|
347
|
-
Zlib::GzipWriter.
|
348
|
-
Socialcast::CommandLine::CLI.
|
349
|
-
File.
|
350
|
-
RestClient::Resource.
|
347
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(@result)
|
348
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).with(hash_including('config' => '/my/path/to/ldap.yml')).and_return(ldap_without_permission_mappings_config)
|
349
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
350
|
+
allow_any_instance_of(RestClient::Resource).to receive(:post)
|
351
351
|
|
352
352
|
Socialcast::CommandLine::CLI.start ['provision', '-c', '/my/path/to/ldap.yml']
|
353
353
|
end
|
@@ -355,7 +355,7 @@ describe Socialcast::CommandLine::CLI do
|
|
355
355
|
end
|
356
356
|
context 'with plugins option used with non-existent ruby files' do
|
357
357
|
it 'does not post to Socialcast and raises an error' do
|
358
|
-
|
358
|
+
expect { Socialcast::CommandLine::CLI.start ['provision', '-c', '/my/path/to/ldap.yml', '--plugins', ['does_not_exist.rb', 'also_does_not_exist.rb']] }.to raise_error
|
359
359
|
end
|
360
360
|
end
|
361
361
|
context 'with plugins option used with existent ruby file' do
|
@@ -363,18 +363,18 @@ describe Socialcast::CommandLine::CLI do
|
|
363
363
|
@entry = Net::LDAP::Entry.new("dc=example,dc=com")
|
364
364
|
@entry[:mail] = 'ryan@example.com'
|
365
365
|
@entry[:plugin_attr] = 'some value'
|
366
|
-
ldap.
|
366
|
+
expect(ldap).to receive(:search).with(hash_including(:attributes => ['plugin_attr', 'sn', 'mail', 'memberof'])).and_yield(@entry)
|
367
367
|
|
368
368
|
@result = ''
|
369
|
-
Zlib::GzipWriter.
|
370
|
-
Socialcast::CommandLine::CLI.
|
371
|
-
File.
|
372
|
-
RestClient::Resource.
|
369
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(@result)
|
370
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).and_return(ldap_with_plugin_mapping_config)
|
371
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
372
|
+
allow_any_instance_of(RestClient::Resource).to receive(:post)
|
373
373
|
|
374
374
|
Socialcast::CommandLine::CLI.start ['provision', '--plugins', [File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'fake_attribute_map')]]
|
375
375
|
end
|
376
376
|
it 'successfully processes' do
|
377
|
-
@result.
|
377
|
+
expect(@result).to match(%r{some vblue})
|
378
378
|
end # see expectations
|
379
379
|
end
|
380
380
|
context 'with ldap.yml configuration excluding permission_mappings' do
|
@@ -382,19 +382,19 @@ describe Socialcast::CommandLine::CLI do
|
|
382
382
|
@entry = Net::LDAP::Entry.new("dc=example,dc=com")
|
383
383
|
@entry[:mail] = 'ryan@example.com'
|
384
384
|
|
385
|
-
ldap.
|
385
|
+
expect(ldap).to receive(:search).and_yield(@entry)
|
386
386
|
|
387
387
|
@result = ''
|
388
|
-
Zlib::GzipWriter.
|
389
|
-
Socialcast::CommandLine::CLI.
|
390
|
-
File.
|
388
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(@result)
|
389
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).and_return(ldap_without_permission_mappings_config)
|
390
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
391
391
|
|
392
|
-
RestClient::Resource.
|
392
|
+
allow_any_instance_of(RestClient::Resource).to receive(:post)
|
393
393
|
|
394
394
|
Socialcast::CommandLine::CLI.start ['provision']
|
395
395
|
end
|
396
396
|
it 'excludes roles element' do
|
397
|
-
@result.
|
397
|
+
expect(@result).not_to match(%r{roles})
|
398
398
|
end
|
399
399
|
end
|
400
400
|
context 'with external group member' do
|
@@ -403,19 +403,19 @@ describe Socialcast::CommandLine::CLI do
|
|
403
403
|
@entry[:mail] = 'ryan@example.com'
|
404
404
|
@entry[:isMemberOf] = 'cn=External,dc=example,dc=com'
|
405
405
|
|
406
|
-
ldap.
|
406
|
+
expect(ldap).to receive(:search).and_yield(@entry)
|
407
407
|
|
408
408
|
@result = ''
|
409
|
-
Zlib::GzipWriter.
|
410
|
-
Socialcast::CommandLine::CLI.
|
411
|
-
File.
|
409
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(@result)
|
410
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).and_return(ldap_default_config)
|
411
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
412
412
|
|
413
|
-
RestClient::Resource.
|
413
|
+
allow_any_instance_of(RestClient::Resource).to receive(:post)
|
414
414
|
|
415
415
|
Socialcast::CommandLine::CLI.start ['provision']
|
416
416
|
end
|
417
417
|
it 'sets account-type to external' do
|
418
|
-
@result.
|
418
|
+
expect(@result).to match(%r{<account-type>external</account-type>})
|
419
419
|
end
|
420
420
|
end
|
421
421
|
context 'with multiple possible external group member' do
|
@@ -424,19 +424,19 @@ describe Socialcast::CommandLine::CLI do
|
|
424
424
|
@entry[:mail] = 'ryan@example.com'
|
425
425
|
@entry[:isMemberOf] = 'cn=Contractor,dc=example,dc=com'
|
426
426
|
|
427
|
-
ldap.
|
427
|
+
expect(ldap).to receive(:search).and_yield(@entry)
|
428
428
|
|
429
429
|
@result = ''
|
430
|
-
Zlib::GzipWriter.
|
431
|
-
Socialcast::CommandLine::CLI.
|
432
|
-
File.
|
430
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(@result)
|
431
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).and_return(ldap_with_array_permission_mapping_config)
|
432
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
433
433
|
|
434
|
-
RestClient::Resource.
|
434
|
+
allow_any_instance_of(RestClient::Resource).to receive(:post)
|
435
435
|
|
436
436
|
Socialcast::CommandLine::CLI.start ['provision']
|
437
437
|
end
|
438
438
|
it 'sets account-type to external' do
|
439
|
-
@result.
|
439
|
+
expect(@result).to match(%r{<account-type>external</account-type>})
|
440
440
|
end
|
441
441
|
end
|
442
442
|
|
@@ -446,22 +446,22 @@ describe Socialcast::CommandLine::CLI do
|
|
446
446
|
@entry[:mail] = 'ryan@example.com'
|
447
447
|
@entry[:isMemberOf] = 'cn=Admins,dc=example,dc=com'
|
448
448
|
|
449
|
-
ldap.
|
449
|
+
expect(ldap).to receive(:search).and_yield(@entry)
|
450
450
|
|
451
451
|
@result = ''
|
452
|
-
Zlib::GzipWriter.
|
453
|
-
Socialcast::CommandLine::CLI.
|
454
|
-
File.
|
452
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(@result)
|
453
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).and_return(ldap_default_config)
|
454
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
455
455
|
|
456
|
-
RestClient::Resource.
|
456
|
+
allow_any_instance_of(RestClient::Resource).to receive(:post)
|
457
457
|
|
458
458
|
Socialcast::CommandLine::CLI.start ['provision']
|
459
459
|
end
|
460
460
|
it 'sets account-type to member' do
|
461
|
-
@result.
|
461
|
+
expect(@result).to match(%r{<account-type>member</account-type>})
|
462
462
|
end
|
463
463
|
it 'adds tenant_admin role' do
|
464
|
-
@result.
|
464
|
+
expect(@result).to match(%r{<role>tenant_admin</role>})
|
465
465
|
end
|
466
466
|
end
|
467
467
|
context 'entry isMemberOf Marketing group' do
|
@@ -470,22 +470,22 @@ describe Socialcast::CommandLine::CLI do
|
|
470
470
|
@entry[:mail] = 'ryan@example.com'
|
471
471
|
@entry[:isMemberOf] = 'cn=Marketing,dc=example,dc=com'
|
472
472
|
|
473
|
-
ldap.
|
473
|
+
expect(ldap).to receive(:search).and_yield(@entry)
|
474
474
|
|
475
475
|
@result = ''
|
476
|
-
Zlib::GzipWriter.
|
477
|
-
Socialcast::CommandLine::CLI.
|
478
|
-
File.
|
476
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(@result)
|
477
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).and_return(ldap_with_array_permission_mapping_config)
|
478
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
479
479
|
|
480
|
-
RestClient::Resource.
|
480
|
+
allow_any_instance_of(RestClient::Resource).to receive(:post)
|
481
481
|
|
482
482
|
Socialcast::CommandLine::CLI.start ['provision', '-c', 'spec/fixtures/ldap.yml']
|
483
483
|
end
|
484
484
|
it 'sets account-type to member' do
|
485
|
-
@result.
|
485
|
+
expect(@result).to match(%r{<account-type>member</account-type>})
|
486
486
|
end
|
487
487
|
it 'adds sbi_admin role' do
|
488
|
-
@result.
|
488
|
+
expect(@result).to match(%r{<role>sbi_admin</role>})
|
489
489
|
end
|
490
490
|
end
|
491
491
|
context 'entry isMemberOf Engineering group' do
|
@@ -494,22 +494,22 @@ describe Socialcast::CommandLine::CLI do
|
|
494
494
|
@entry[:mail] = 'ryan@example.com'
|
495
495
|
@entry[:isMemberOf] = 'cn=Engineering,dc=example,dc=com'
|
496
496
|
|
497
|
-
ldap.
|
497
|
+
expect(ldap).to receive(:search).and_yield(@entry)
|
498
498
|
|
499
499
|
@result = ''
|
500
|
-
Zlib::GzipWriter.
|
501
|
-
Socialcast::CommandLine::CLI.
|
502
|
-
File.
|
500
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(@result)
|
501
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).and_return(ldap_with_array_permission_mapping_config)
|
502
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
503
503
|
|
504
|
-
RestClient::Resource.
|
504
|
+
allow_any_instance_of(RestClient::Resource).to receive(:post)
|
505
505
|
|
506
506
|
Socialcast::CommandLine::CLI.start ['provision']
|
507
507
|
end
|
508
508
|
it 'sets account-type to member' do
|
509
|
-
@result.
|
509
|
+
expect(@result).to match(%r{<account-type>member</account-type>})
|
510
510
|
end
|
511
511
|
it 'adds sbi_admin role' do
|
512
|
-
@result.
|
512
|
+
expect(@result).to match(%r{<role>sbi_admin</role>})
|
513
513
|
end
|
514
514
|
end
|
515
515
|
|
@@ -520,20 +520,20 @@ describe Socialcast::CommandLine::CLI do
|
|
520
520
|
@entry[:l] = 'San Francisco'
|
521
521
|
@entry[:co] = 'USA'
|
522
522
|
|
523
|
-
ldap.
|
523
|
+
expect(ldap).to receive(:search).and_yield(@entry)
|
524
524
|
|
525
525
|
@result = ''
|
526
|
-
Zlib::GzipWriter.
|
527
|
-
Socialcast::CommandLine::CLI.
|
528
|
-
File.
|
526
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(@result)
|
527
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).and_return(ldap_with_interpolated_values_config)
|
528
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
529
529
|
|
530
|
-
RestClient::Resource.
|
530
|
+
allow_any_instance_of(RestClient::Resource).to receive(:post)
|
531
531
|
|
532
532
|
Socialcast::CommandLine::CLI.start ['provision']
|
533
533
|
end
|
534
534
|
|
535
535
|
it 'formats l and co according to template' do
|
536
|
-
@result.
|
536
|
+
expect(@result).to match(%r{<location>San Francisco, USA</location>})
|
537
537
|
end
|
538
538
|
end
|
539
539
|
|
@@ -546,21 +546,21 @@ describe Socialcast::CommandLine::CLI do
|
|
546
546
|
manager_entry = Net::LDAP::Entry.new("cn=manager,dc=example,dc=com")
|
547
547
|
manager_entry[:mail] = 'manager@example.com'
|
548
548
|
|
549
|
-
ldap.
|
550
|
-
ldap.
|
549
|
+
expect(ldap).to receive(:search).once.ordered.and_yield(manager_entry).and_yield(employee_entry)
|
550
|
+
expect(ldap).to receive(:search).once.ordered.and_yield(manager_entry).and_yield(employee_entry)
|
551
551
|
|
552
|
-
Zlib::GzipWriter.
|
553
|
-
Socialcast::CommandLine::CLI.
|
554
|
-
File.
|
552
|
+
allow(Zlib::GzipWriter).to receive(:open).and_yield(result)
|
553
|
+
expect_any_instance_of(Socialcast::CommandLine::CLI).to receive(:ldap_config).and_return(ldap_with_manager_attribute_config)
|
554
|
+
allow(File).to receive(:open).with(/users.xml.gz/, anything).and_yield(@result)
|
555
555
|
|
556
|
-
RestClient::Resource.
|
556
|
+
allow_any_instance_of(RestClient::Resource).to receive(:post)
|
557
557
|
|
558
558
|
Socialcast::CommandLine::CLI.start ['provision', '-c', 'spec/fixtures/ldap.yml']
|
559
559
|
end
|
560
560
|
|
561
561
|
it 'adds a manager_email entry of bossman@example.com' do
|
562
|
-
result.
|
563
|
-
result.
|
562
|
+
expect(result).to match(/<email>employee@example.com<\/email>/)
|
563
|
+
expect(result).to match(/<label>manager_email<\/label>\s*<value>manager@example.com<\/value>/)
|
564
564
|
end
|
565
565
|
end
|
566
566
|
end
|