stormpath-sdk 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/CHANGES.md +11 -0
- data/README.md +234 -3
- data/Rakefile +3 -1
- data/lib/stormpath-sdk.rb +4 -0
- data/lib/stormpath-sdk/auth/basic_login_attempt.rb +4 -0
- data/lib/stormpath-sdk/auth/username_password_request.rb +0 -1
- data/lib/stormpath-sdk/client.rb +1 -1
- data/lib/stormpath-sdk/data_store.rb +17 -9
- data/lib/stormpath-sdk/provider/saml/saml_mapping_rules.rb +22 -0
- data/lib/stormpath-sdk/provider/saml/saml_provider.rb +20 -0
- data/lib/stormpath-sdk/provider/saml/saml_provider_data.rb +19 -0
- data/lib/stormpath-sdk/provider/saml/saml_provider_metadata.rb +19 -0
- data/lib/stormpath-sdk/resource/application.rb +22 -7
- data/lib/stormpath-sdk/resource/directory.rb +16 -0
- data/lib/stormpath-sdk/version.rb +2 -2
- data/spec/client_spec.rb +108 -13
- data/spec/fixtures/response/create_saml_directory.json +26 -0
- data/spec/fixtures/response/create_saml_directory_mapping_rules.json +12 -0
- data/spec/fixtures/response/get_saml_directory_provider.json +16 -0
- data/spec/fixtures/response/get_saml_directory_provider_metadata.json +12 -0
- data/spec/resource/application_spec.rb +378 -33
- data/spec/resource/directory_spec.rb +168 -0
- data/spec/spec_helper.rb +14 -1
- data/stormpath-sdk.gemspec +1 -0
- metadata +25 -3
@@ -271,6 +271,174 @@ describe Stormpath::Resource::Directory, :vcr do
|
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
|
+
describe 'create directory with provider data' do
|
275
|
+
context 'valida data' do
|
276
|
+
let(:directory) do
|
277
|
+
test_api_client.directories.create(
|
278
|
+
name: random_directory_name,
|
279
|
+
description: 'description_for_some_test_directory',
|
280
|
+
provider: {
|
281
|
+
provider_id: "saml",
|
282
|
+
sso_login_url:"https://yourIdp.com/saml2/sso/login",
|
283
|
+
sso_logout_url:"https://yourIdp.com/saml2/sso/logout",
|
284
|
+
encoded_x509_signing_cert:"-----BEGIN CERTIFICATE-----\n...Certificate goes here...\n-----END CERTIFICATE-----",
|
285
|
+
request_signature_algorithm:"RSA-SHA256"
|
286
|
+
}
|
287
|
+
)
|
288
|
+
end
|
289
|
+
|
290
|
+
after do
|
291
|
+
directory.delete if directory
|
292
|
+
end
|
293
|
+
|
294
|
+
it 'creates the directory with provider data' do
|
295
|
+
stub_request(:post, "https://api.stormpath.com/v1/directories").
|
296
|
+
to_return(status:200, body: fixture('create_saml_directory.json'), headers:{})
|
297
|
+
|
298
|
+
stub_request(:get, directory.href + "/provider").
|
299
|
+
to_return(status: 200, body: fixture('get_saml_directory_provider.json'), headers:{})
|
300
|
+
|
301
|
+
directory
|
302
|
+
expect(directory.provider.provider_id).to eq("saml")
|
303
|
+
expect(directory.provider.sso_login_url).to eq("https://yourIdp.com/saml2/sso/login")
|
304
|
+
expect(directory.provider.sso_logout_url).to eq("https://yourIdp.com/saml2/sso/logout")
|
305
|
+
expect(directory.provider.request_signature_algorithm).to eq("RSA-SHA256")
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
context 'invalid data' do
|
310
|
+
it 'raises Stormpath::Error' do
|
311
|
+
expect do
|
312
|
+
test_api_client.directories.create(
|
313
|
+
name: random_directory_name,
|
314
|
+
description: 'description_for_some_test_directory',
|
315
|
+
provider: {
|
316
|
+
provider_id: "saml",
|
317
|
+
sso_login_url:"",
|
318
|
+
sso_logout_url:"",
|
319
|
+
encoded_x509_signing_cert:"",
|
320
|
+
request_signature_algorithm:"RSA-SHA256"
|
321
|
+
}
|
322
|
+
)
|
323
|
+
end.to raise_error Stormpath::Error
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
describe 'saml #provider' do
|
329
|
+
let(:directory) do
|
330
|
+
test_api_client.directories.create(
|
331
|
+
name: random_directory_name,
|
332
|
+
description: 'description_for_some_test_directory',
|
333
|
+
provider: {
|
334
|
+
provider_id: "saml",
|
335
|
+
sso_login_url:"https://yourIdp.com/saml2/sso/login",
|
336
|
+
sso_logout_url:"https://yourIdp.com/saml2/sso/logout",
|
337
|
+
encoded_x509_signing_cert:"-----BEGIN CERTIFICATE-----\n...Certificate goes here...\n-----END CERTIFICATE-----",
|
338
|
+
request_signature_algorithm:"RSA-SHA256"
|
339
|
+
}
|
340
|
+
)
|
341
|
+
end
|
342
|
+
|
343
|
+
after do
|
344
|
+
directory.delete if directory
|
345
|
+
end
|
346
|
+
|
347
|
+
it 'returnes provider data' do
|
348
|
+
stub_request(:post, "https://api.stormpath.com/v1/directories").
|
349
|
+
to_return(status:200, body: fixture('create_saml_directory.json'), headers:{})
|
350
|
+
|
351
|
+
stub_request(:get, directory.href + "/provider").
|
352
|
+
to_return(status: 200, body: fixture('get_saml_directory_provider.json'), headers:{})
|
353
|
+
|
354
|
+
directory
|
355
|
+
expect(directory.provider.href).not_to be_empty
|
356
|
+
expect(directory.provider.provider_id).to eq("saml")
|
357
|
+
expect(directory.provider.sso_login_url).to eq("https://yourIdp.com/saml2/sso/login")
|
358
|
+
expect(directory.provider.sso_logout_url).to eq("https://yourIdp.com/saml2/sso/logout")
|
359
|
+
expect(directory.provider.encoded_x509_signing_cert).not_to be_empty
|
360
|
+
expect(directory.provider.request_signature_algorithm).to eq("RSA-SHA256")
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
describe 'saml #provider_metadata' do
|
365
|
+
let(:directory) do
|
366
|
+
test_api_client.directories.create(
|
367
|
+
name: random_directory_name,
|
368
|
+
description: 'description_for_some_test_directory',
|
369
|
+
provider: {
|
370
|
+
provider_id: "saml",
|
371
|
+
sso_login_url:"https://yourIdp.com/saml2/sso/login",
|
372
|
+
sso_logout_url:"https://yourIdp.com/saml2/sso/logout",
|
373
|
+
encoded_x509_signing_cert:"-----BEGIN CERTIFICATE-----\n...Certificate goes here...\n-----END CERTIFICATE-----",
|
374
|
+
request_signature_algorithm:"RSA-SHA256"
|
375
|
+
}
|
376
|
+
)
|
377
|
+
end
|
378
|
+
|
379
|
+
after do
|
380
|
+
directory.delete if directory
|
381
|
+
end
|
382
|
+
|
383
|
+
it 'returnes provider metadata' do
|
384
|
+
stub_request(:post, "https://api.stormpath.com/v1/directories").
|
385
|
+
to_return(status:200, body: fixture('create_saml_directory.json'), headers:{})
|
386
|
+
|
387
|
+
stub_request(:get, directory.href + "/provider").
|
388
|
+
to_return(status: 200, body: fixture('get_saml_directory_provider.json'), headers:{})
|
389
|
+
|
390
|
+
stub_request(:get, directory.provider.service_provider_metadata["href"]).
|
391
|
+
to_return(status: 200, body: fixture('get_saml_directory_provider_metadata.json'), headers: {})
|
392
|
+
|
393
|
+
expect(directory.provider_metadata.href).not_to be_empty
|
394
|
+
expect(directory.provider_metadata.entity_id).not_to be_empty
|
395
|
+
expect(directory.provider_metadata.assertion_consumer_service_post_endpoint).not_to be_empty
|
396
|
+
expect(directory.provider_metadata.x509_signing_cert).not_to be_empty
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
describe 'saml mapping rules' do
|
401
|
+
let(:directory) do
|
402
|
+
test_api_client.directories.create(
|
403
|
+
name: random_directory_name,
|
404
|
+
description: 'description_for_some_test_directory',
|
405
|
+
provider: {
|
406
|
+
provider_id: "saml",
|
407
|
+
sso_login_url:"https://yourIdp.com/saml2/sso/login",
|
408
|
+
sso_logout_url:"https://yourIdp.com/saml2/sso/logout",
|
409
|
+
encoded_x509_signing_cert:"-----BEGIN CERTIFICATE-----\n...Certificate goes here...\n-----END CERTIFICATE-----",
|
410
|
+
request_signature_algorithm:"RSA-SHA256"
|
411
|
+
}
|
412
|
+
)
|
413
|
+
end
|
414
|
+
|
415
|
+
after do
|
416
|
+
directory.delete if directory
|
417
|
+
end
|
418
|
+
|
419
|
+
it 'updates the directory mappings' do
|
420
|
+
mappings = Stormpath::Provider::SamlMappingRules.new(items: [
|
421
|
+
{
|
422
|
+
name: "uid",
|
423
|
+
account_attributes: ["username"]
|
424
|
+
}
|
425
|
+
])
|
426
|
+
|
427
|
+
stub_request(:post, "https://api.stormpath.com/v1/directories").
|
428
|
+
to_return(status:200, body: fixture('create_saml_directory.json'), headers:{})
|
429
|
+
|
430
|
+
stub_request(:get, directory.href + "/provider").
|
431
|
+
to_return(status: 200, body: fixture('get_saml_directory_provider.json'), headers:{})
|
432
|
+
|
433
|
+
stub_request(:post, directory.provider.attribute_statement_mapping_rules["href"]).
|
434
|
+
to_return(status:200, body: fixture('create_saml_directory_mapping_rules.json'), headers:{})
|
435
|
+
|
436
|
+
response = directory.create_attribute_mappings(mappings)
|
437
|
+
expect(response.items).to eq( [ { "name" => "uid4", "name_format" => "nil", "account_attributes" => ["username"] } ] )
|
438
|
+
end
|
439
|
+
|
440
|
+
end
|
441
|
+
|
274
442
|
describe '#create_account_with_custom_data' do
|
275
443
|
let(:directory) { test_api_client.directories.create name: random_directory_name, description: 'description_for_some_test_directory' }
|
276
444
|
|
data/spec/spec_helper.rb
CHANGED
@@ -92,6 +92,15 @@ module Stormpath
|
|
92
92
|
def test_directory_with_verification
|
93
93
|
test_api_client.directories.get test_directory_with_verification_url
|
94
94
|
end
|
95
|
+
|
96
|
+
|
97
|
+
def fixture_path
|
98
|
+
File.expand_path('../fixtures/response', __FILE__)
|
99
|
+
end
|
100
|
+
|
101
|
+
def fixture(file)
|
102
|
+
File.new(fixture_path + '/' + file)
|
103
|
+
end
|
95
104
|
end
|
96
105
|
|
97
106
|
module TestResourceHelpers
|
@@ -109,12 +118,16 @@ module Stormpath
|
|
109
118
|
module RandomResourceNameGenerator
|
110
119
|
include UUIDTools
|
111
120
|
|
112
|
-
%w(application directory group user).each do |resource|
|
121
|
+
%w(application directory organization group user).each do |resource|
|
113
122
|
define_method "random_#{resource}_name" do |suffix=nil|
|
114
123
|
"#{random_string}_#{resource}_#{suffix}"
|
115
124
|
end
|
116
125
|
end
|
117
126
|
|
127
|
+
def random_name_key(suffix='test')
|
128
|
+
"#{random_string}-namekey-#{suffix}"
|
129
|
+
end
|
130
|
+
|
118
131
|
def random_email
|
119
132
|
"#{random_string}@stormpath.com"
|
120
133
|
end
|
data/stormpath-sdk.gemspec
CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.add_development_dependency 'vcr', '~> 2.9.2'
|
35
35
|
s.add_development_dependency 'timecop', '~> 0.6.1'
|
36
36
|
s.add_development_dependency 'redis', '~> 3.0.4'
|
37
|
+
s.add_development_dependency 'listen', '~> 3.0.6'
|
37
38
|
|
38
39
|
s.rdoc_options = ['--line-numbers', '--inline-source', '--title', 'stormpath-sdk', '--main']
|
39
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stormpath-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stormpath, Inc
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -263,6 +263,20 @@ dependencies:
|
|
263
263
|
- - "~>"
|
264
264
|
- !ruby/object:Gem::Version
|
265
265
|
version: 3.0.4
|
266
|
+
- !ruby/object:Gem::Dependency
|
267
|
+
name: listen
|
268
|
+
requirement: !ruby/object:Gem::Requirement
|
269
|
+
requirements:
|
270
|
+
- - "~>"
|
271
|
+
- !ruby/object:Gem::Version
|
272
|
+
version: 3.0.6
|
273
|
+
type: :development
|
274
|
+
prerelease: false
|
275
|
+
version_requirements: !ruby/object:Gem::Requirement
|
276
|
+
requirements:
|
277
|
+
- - "~>"
|
278
|
+
- !ruby/object:Gem::Version
|
279
|
+
version: 3.0.6
|
266
280
|
description: Stormpath SDK used to interact with the Stormpath REST API
|
267
281
|
email: support@stormpath.com
|
268
282
|
executables: []
|
@@ -322,6 +336,10 @@ files:
|
|
322
336
|
- lib/stormpath-sdk/provider/linkedin/linkedin_provider_data.rb
|
323
337
|
- lib/stormpath-sdk/provider/provider.rb
|
324
338
|
- lib/stormpath-sdk/provider/provider_data.rb
|
339
|
+
- lib/stormpath-sdk/provider/saml/saml_mapping_rules.rb
|
340
|
+
- lib/stormpath-sdk/provider/saml/saml_provider.rb
|
341
|
+
- lib/stormpath-sdk/provider/saml/saml_provider_data.rb
|
342
|
+
- lib/stormpath-sdk/provider/saml/saml_provider_metadata.rb
|
325
343
|
- lib/stormpath-sdk/provider/stormpath/stormpath_provider.rb
|
326
344
|
- lib/stormpath-sdk/provider/stormpath/stormpath_provider_data.rb
|
327
345
|
- lib/stormpath-sdk/resource/access_token.rb
|
@@ -363,6 +381,10 @@ files:
|
|
363
381
|
- spec/cache/cache_stats_spec.rb
|
364
382
|
- spec/client_spec.rb
|
365
383
|
- spec/data_store_spec.rb
|
384
|
+
- spec/fixtures/response/create_saml_directory.json
|
385
|
+
- spec/fixtures/response/create_saml_directory_mapping_rules.json
|
386
|
+
- spec/fixtures/response/get_saml_directory_provider.json
|
387
|
+
- spec/fixtures/response/get_saml_directory_provider_metadata.json
|
366
388
|
- spec/provider/account_resolver_spec.rb
|
367
389
|
- spec/provider/provider_spec.rb
|
368
390
|
- spec/resource/account_spec.rb
|
@@ -413,7 +435,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
413
435
|
version: '0'
|
414
436
|
requirements: []
|
415
437
|
rubyforge_project:
|
416
|
-
rubygems_version: 2.
|
438
|
+
rubygems_version: 2.5.1
|
417
439
|
signing_key:
|
418
440
|
specification_version: 4
|
419
441
|
summary: Stormpath SDK
|