stormpath-sdk 1.0.0.beta.4 → 1.0.0.beta.5

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.
Files changed (37) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGES.md +15 -0
  3. data/README.md +35 -3
  4. data/lib/stormpath-sdk.rb +5 -6
  5. data/lib/stormpath-sdk/auth/basic_authenticator.rb +2 -0
  6. data/lib/stormpath-sdk/auth/basic_login_attempt.rb +11 -0
  7. data/lib/stormpath-sdk/auth/username_password_request.rb +6 -12
  8. data/lib/stormpath-sdk/data_store.rb +118 -127
  9. data/lib/stormpath-sdk/http/http_client_request_executor.rb +10 -42
  10. data/lib/stormpath-sdk/resource/account.rb +13 -3
  11. data/lib/stormpath-sdk/resource/account_membership.rb +16 -0
  12. data/lib/stormpath-sdk/resource/account_status.rb +26 -0
  13. data/lib/stormpath-sdk/resource/account_store_mapping.rb +4 -2
  14. data/lib/stormpath-sdk/resource/application.rb +4 -2
  15. data/lib/stormpath-sdk/resource/associations.rb +7 -3
  16. data/lib/stormpath-sdk/resource/base.rb +21 -15
  17. data/lib/stormpath-sdk/resource/custom_data.rb +86 -0
  18. data/lib/stormpath-sdk/resource/custom_data_hash_methods.rb +33 -0
  19. data/lib/stormpath-sdk/resource/custom_data_storage.rb +39 -0
  20. data/lib/stormpath-sdk/resource/directory.rb +4 -4
  21. data/lib/stormpath-sdk/resource/expansion.rb +15 -0
  22. data/lib/stormpath-sdk/resource/group.rb +10 -0
  23. data/lib/stormpath-sdk/resource/status.rb +16 -5
  24. data/lib/stormpath-sdk/version.rb +2 -2
  25. data/spec/client_spec.rb +6 -1
  26. data/spec/data_store_spec.rb +7 -2
  27. data/spec/resource/account_spec.rb +73 -30
  28. data/spec/resource/account_store_mapping_spec.rb +20 -5
  29. data/spec/resource/application_spec.rb +135 -0
  30. data/spec/resource/custom_data_spec.rb +198 -0
  31. data/spec/resource/directory_spec.rb +192 -9
  32. data/spec/resource/group_membership_spec.rb +35 -0
  33. data/spec/resource/group_spec.rb +44 -26
  34. data/spec/resource/status_spec.rb +81 -0
  35. data/spec/resource/tenant_spec.rb +19 -0
  36. data/stormpath-sdk.gemspec +2 -2
  37. metadata +13 -3
@@ -1,34 +1,40 @@
1
-
2
1
  require 'spec_helper'
3
2
 
4
3
  describe Stormpath::Resource::Group, :vcr do
5
- describe '#add_account' do
6
- context "given an account" do
7
- let(:directory) do
8
- test_api_client.directories.create name: 'testDirectory'
9
- end
10
4
 
11
- let(:group) do
12
- directory.groups.create name: 'someGroup'
13
- end
5
+ describe "instances should respond to attribute property methods" do
6
+ let(:directory) { test_directory }
14
7
 
15
- let(:account) do
16
- directory.accounts.create({
17
- email: 'rubysdk@example.com',
18
- given_name: 'Ruby SDK',
19
- password: 'P@$$w0rd',
20
- surname: 'SDK',
21
- username: 'rubysdk'
22
- })
23
- end
8
+ subject(:group) { directory.groups.create name: 'someTestGroup', description: 'someTestDescription' }
24
9
 
25
- let(:reloaded_account) do
26
- test_api_client.accounts.get account.href
27
- end
10
+ [:name, :description, :status].each do |property_accessor|
11
+ it { should respond_to property_accessor }
12
+ it { should respond_to "#{property_accessor}="}
13
+ its(property_accessor) { should be_instance_of String }
14
+ end
28
15
 
29
- let(:reloaded_group) do
30
- test_api_client.groups.get group.href
31
- end
16
+ its(:tenant) { should be_instance_of Stormpath::Resource::Tenant }
17
+ its(:directory) { should be_instance_of Stormpath::Resource::Directory }
18
+ its(:custom_data) { should be_instance_of Stormpath::Resource::CustomData }
19
+
20
+ its(:accounts) { should be_instance_of Stormpath::Resource::Collection }
21
+ its(:account_memberships) { should be_instance_of Stormpath::Resource::Collection}
22
+
23
+
24
+ after do
25
+ group.delete if group
26
+ end
27
+
28
+ end
29
+
30
+ describe '#add_or_remove_account' do
31
+ context "given an account" do
32
+
33
+ let(:directory) { test_api_client.directories.create name: 'testDirectory' }
34
+
35
+ let(:group) { directory.groups.create name: 'someGroup' }
36
+
37
+ let(:account) { directory.accounts.create({ email: 'rubysdk@example.com', given_name: 'Ruby SDK', password: 'P@$$w0rd',surname: 'SDK' }) }
32
38
 
33
39
  before do
34
40
  group.add_account account
@@ -41,9 +47,21 @@ describe Stormpath::Resource::Group, :vcr do
41
47
  end
42
48
 
43
49
  it "adds the account to the group" do
44
- found = reloaded_group.accounts.find { |a| a.href == account.href }
45
- expect(found).to be
50
+ expect(group.accounts).to include(account)
46
51
  end
52
+
53
+ it 'has one account membership resource' do
54
+ expect(group.account_memberships).to have(1).item
55
+ end
56
+
57
+ it 'adds and removes the group from the account' do
58
+ expect(group.accounts).to include(account)
59
+
60
+ group.remove_account account
61
+
62
+ expect(group.accounts).not_to include(account)
63
+ end
64
+
47
65
  end
48
66
  end
49
67
  end
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stormpath::Resource::Status, :vcr do
4
+
5
+ def authenticate_user
6
+ auth_request = Stormpath::Authentication::UsernamePasswordRequest.new 'test@example.com', 'P@$$w0rd'
7
+ account_store_mapping unless account_store_mapping
8
+ application.authenticate_account auth_request
9
+ end
10
+
11
+ let(:directory) { test_api_client.directories.create name: 'testDirectory', description: 'testDirectory' }
12
+
13
+ let(:application) { test_api_client.applications.create name: 'testApplication', description: 'testApplication' }
14
+
15
+ let(:group) { directory.groups.create name: 'testGroup', description: 'testGroup' }
16
+
17
+ let(:account_store_mapping) { test_api_client.account_store_mappings.create application: application, account_store: directory }
18
+
19
+ let!(:account) { directory.accounts.create email: 'test@example.com', password: 'P@$$w0rd', given_name: "Ruby SDK", surname: 'SDK' }
20
+
21
+ let(:status_hash) {{ "ENABLED" => "ENABLED", "DISABLED" => "DISABLED" }}
22
+
23
+ let(:account_status_hash) { status_hash.merge "UNVERIFIED" => "UNVERIFIED", "LOCKED" => "LOCKED"}
24
+
25
+ let(:reloaded_account) { test_api_client.accounts.get account.href }
26
+
27
+ after do
28
+ application.delete if application
29
+ directory.delete if directory
30
+ end
31
+
32
+ it "should respond to status getter and setter" do
33
+ expect(directory.respond_to? :status).to be_true
34
+ expect(directory.respond_to? :status=).to be_true
35
+
36
+ expect(application.respond_to? :status).to be_true
37
+ expect(application.respond_to? :status=).to be_true
38
+
39
+ expect(group.respond_to? :status).to be_true
40
+ expect(group.respond_to? :status=).to be_true
41
+
42
+ expect(account.respond_to? :status).to be_true
43
+ expect(account.respond_to? :status=).to be_true
44
+ end
45
+
46
+ it "compare status hashes" do
47
+ expect(directory.status_hash).to eq(status_hash)
48
+ expect(application.status_hash).to eq(status_hash)
49
+
50
+ expect(group.status_hash).to eq(status_hash)
51
+ expect(account.status_hash).to eq(account_status_hash)
52
+ end
53
+
54
+ it "users status by default should be ENABLED" do
55
+ expect(account.status).to eq("ENABLED")
56
+ end
57
+
58
+ it "change user status" do
59
+ account.status = "DISABLED"
60
+ account.save
61
+ expect(reloaded_account.status).to eq("DISABLED")
62
+ end
63
+
64
+ it "authenticate user with status ENABLED" do
65
+ expect(authenticate_user.properties["account"]["href"]).to eq(account.href)
66
+ end
67
+
68
+ it "shouldn't authenticate users with status DISABLED, UNVERIFIED or LOCKED" do
69
+ ["DISABLED", "UNVERIFIED", "LOCKED"].each do |status|
70
+ account.status = status
71
+ account.save
72
+ expect{authenticate_user}.to raise_exception(Stormpath::Error)
73
+ end
74
+ end
75
+
76
+ it 'assigning inappropriate status states should fail silently' do
77
+ account.status = "INVALID_STATUS_VALUE"
78
+ expect(account.status).to eq("ENABLED")
79
+ end
80
+
81
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stormpath::Resource::Tenant, :vcr do
4
+
5
+ describe "instances should respond to attribute property methods" do
6
+ subject(:tenant) { test_api_client.tenant }
7
+
8
+ it { should be_instance_of Stormpath::Resource::Tenant }
9
+
10
+ [:name, :key].each do |property_accessor|
11
+ it { should respond_to property_accessor }
12
+ its(property_accessor) { should be_instance_of String }
13
+ end
14
+
15
+ its(:applications) { should be_instance_of Stormpath::Resource::Collection }
16
+ its(:directories) { should be_instance_of Stormpath::Resource::Collection }
17
+ end
18
+
19
+ end
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  s.date = Stormpath::VERSION_DATE
7
7
  s.summary = "Stormpath SDK"
8
8
  s.description = "Stormpath SDK used to interact with the Stormpath REST API"
9
- s.authors = ["Elder Crisostomo"]
10
- s.email = 'elder@stormpath.com'
9
+ s.authors = ["Stormpath, Inc", "Elder Crisostomo"]
10
+ s.email = 'support@stormpath.com'
11
11
  s.homepage = 'https://github.com/stormpath/stormpath-sdk-ruby'
12
12
 
13
13
  s.platform = Gem::Platform::RUBY
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stormpath-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta.4
4
+ version: 1.0.0.beta.5
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
+ - Stormpath, Inc
8
9
  - Elder Crisostomo
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2013-12-10 00:00:00.000000000 Z
13
+ date: 2014-03-03 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: multi_json
@@ -332,7 +333,7 @@ dependencies:
332
333
  - !ruby/object:Gem::Version
333
334
  version: 3.0.4
334
335
  description: Stormpath SDK used to interact with the Stormpath REST API
335
- email: elder@stormpath.com
336
+ email: support@stormpath.com
336
337
  executables: []
337
338
  extensions: []
338
339
  extra_rdoc_files: []
@@ -367,12 +368,17 @@ files:
367
368
  - lib/stormpath-sdk/http/response.rb
368
369
  - lib/stormpath-sdk/http/utils.rb
369
370
  - lib/stormpath-sdk/resource/account.rb
371
+ - lib/stormpath-sdk/resource/account_membership.rb
372
+ - lib/stormpath-sdk/resource/account_status.rb
370
373
  - lib/stormpath-sdk/resource/account_store.rb
371
374
  - lib/stormpath-sdk/resource/account_store_mapping.rb
372
375
  - lib/stormpath-sdk/resource/application.rb
373
376
  - lib/stormpath-sdk/resource/associations.rb
374
377
  - lib/stormpath-sdk/resource/base.rb
375
378
  - lib/stormpath-sdk/resource/collection.rb
379
+ - lib/stormpath-sdk/resource/custom_data.rb
380
+ - lib/stormpath-sdk/resource/custom_data_hash_methods.rb
381
+ - lib/stormpath-sdk/resource/custom_data_storage.rb
376
382
  - lib/stormpath-sdk/resource/directory.rb
377
383
  - lib/stormpath-sdk/resource/email_verification_token.rb
378
384
  - lib/stormpath-sdk/resource/error.rb
@@ -400,9 +406,13 @@ files:
400
406
  - spec/resource/application_spec.rb
401
407
  - spec/resource/base_spec.rb
402
408
  - spec/resource/collection_spec.rb
409
+ - spec/resource/custom_data_spec.rb
403
410
  - spec/resource/directory_spec.rb
404
411
  - spec/resource/expansion_spec.rb
412
+ - spec/resource/group_membership_spec.rb
405
413
  - spec/resource/group_spec.rb
414
+ - spec/resource/status_spec.rb
415
+ - spec/resource/tenant_spec.rb
406
416
  - spec/spec_helper.rb
407
417
  - spec/support/resource_factory.rb
408
418
  - spec/support/resource_matchers.rb