stormpath-sdk 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stormpath::Resource::AccountLinkingPolicy, :vcr do
4
+ describe 'instances should respond to attribute property methods' do
5
+ let!(:application) { test_api_client.applications.create(application_attrs) }
6
+ let(:account_linking_policy) { application.account_linking_policy }
7
+
8
+ after { application.delete }
9
+
10
+ it do
11
+ expect(account_linking_policy).to be_a Stormpath::Resource::AccountLinkingPolicy
12
+
13
+ [:status, :automatic_provisioning].each do |property_accessor|
14
+ expect(account_linking_policy).to respond_to(property_accessor)
15
+ expect(account_linking_policy).to respond_to("#{property_accessor}=")
16
+ expect(account_linking_policy.send(property_accessor)).to be_a String
17
+ end
18
+
19
+ expect(account_linking_policy).to respond_to(:matching_property)
20
+ expect(account_linking_policy).to respond_to('matching_property=')
21
+ expect(account_linking_policy.send(:matching_property)).to be_nil
22
+
23
+ [:created_at, :modified_at].each do |property_getter|
24
+ expect(account_linking_policy).to respond_to(property_getter)
25
+ expect(account_linking_policy.send(property_getter)).to be_a String
26
+ end
27
+
28
+ expect(account_linking_policy.tenant).to be_a Stormpath::Resource::Tenant
29
+ end
30
+ end
31
+ end
@@ -15,7 +15,7 @@ describe Stormpath::Resource::Application, :vcr do
15
15
  directory.delete if directory
16
16
  end
17
17
 
18
- it "instances should respond to attribute property methods" do
18
+ it 'instances should respond to attribute property methods' do
19
19
 
20
20
  expect(application).to be_a Stormpath::Resource::Application
21
21
 
@@ -25,6 +25,12 @@ describe Stormpath::Resource::Application, :vcr do
25
25
  expect(application.send property_accessor).to be_a String
26
26
  end
27
27
 
28
+ [:authorized_callback_uris, :authorized_origin_uris].each do |property_accessor|
29
+ expect(application).to respond_to(property_accessor)
30
+ expect(application).to respond_to("#{property_accessor}=")
31
+ expect(application.send property_accessor).to be_a Array
32
+ end
33
+
28
34
  [:created_at, :modified_at].each do |property_getter|
29
35
  expect(application).to respond_to(property_getter)
30
36
  expect(application.send property_getter).to be_a String
@@ -40,6 +46,7 @@ describe Stormpath::Resource::Application, :vcr do
40
46
  expect(application.password_reset_tokens).to be_a Stormpath::Resource::Collection
41
47
  expect(application.verification_emails).to be_a Stormpath::Resource::Collection
42
48
  expect(application.account_store_mappings).to be_a Stormpath::Resource::Collection
49
+ expect(application.account_linking_policy).to be_a Stormpath::Resource::AccountLinkingPolicy
43
50
  end
44
51
 
45
52
  describe '.load' do
@@ -98,6 +105,29 @@ describe Stormpath::Resource::Application, :vcr do
98
105
  end
99
106
  end
100
107
 
108
+ context '#web_config' do
109
+ let(:web_config) { application.web_config }
110
+
111
+ it 'should have web_config' do
112
+ expect(application.web_config).to be_a Stormpath::Resource::ApplicationWebConfig
113
+ end
114
+
115
+ it 'should be able to change config' do
116
+ web_config.status = 'ENABLED'
117
+ web_config.save
118
+ expect(application.web_config.status).to eq 'ENABLED'
119
+
120
+ web_config.status = 'DISABLED'
121
+ web_config.save
122
+ expect(application.web_config.status).to eq 'DISABLED'
123
+ end
124
+
125
+ it 'changing dns_label should affect domain_name' do
126
+ web_config.dns_label = 'stormtrooper'
127
+ web_config.save
128
+ expect(application.web_config.domain_name).to eq 'stormtrooper.apps.stormpath.io'
129
+ end
130
+ end
101
131
  end
102
132
 
103
133
  describe 'edit authorized_callback_uris' do
@@ -108,10 +138,22 @@ describe Stormpath::Resource::Application, :vcr do
108
138
  response = application.save
109
139
 
110
140
  expect(response).to eq application
111
- #expect(application.authorized_callback_uris).to eq(authorized_callback_uris)
141
+ expect(application.authorized_callback_uris).to eq(authorized_callback_uris)
112
142
  end
113
143
  end
114
144
 
145
+ describe 'edit authorized_origin_uris' do
146
+ let(:authorized_origin_uris) do
147
+ ['https://dnsLabel1.apps.stormpath.io', 'https://dnsLabel2.apps.stormpath.io']
148
+ end
149
+
150
+ it 'changes authorized origin uris on application' do
151
+ application.authorized_origin_uris = authorized_origin_uris
152
+ application.save
153
+
154
+ expect(application.authorized_origin_uris.size).to eq 3
155
+ end
156
+ end
115
157
 
116
158
  describe '#create_account' do
117
159
  let(:account) { Stormpath::Resource::Account.new(account_attrs) }
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stormpath::Resource::ApplicationWebConfig, :vcr do
4
+ let(:application) { test_api_client.applications.create(application_attrs) }
5
+ let(:web_config) { application.web_config }
6
+ after { application.delete }
7
+
8
+ describe 'instances should respond to attribute property methods' do
9
+ it do
10
+ expect(web_config).to be_a Stormpath::Resource::ApplicationWebConfig
11
+
12
+ [:dns_label, :status].each do |property_accessor|
13
+ expect(web_config).to respond_to(property_accessor)
14
+ expect(web_config).to respond_to("#{property_accessor}=")
15
+ expect(web_config.send(property_accessor)).to be_a String
16
+ end
17
+
18
+ [:domain_name, :created_at, :modified_at].each do |property_getter|
19
+ expect(web_config).to respond_to(property_getter)
20
+ expect(web_config.send(property_getter)).to be_a String
21
+ end
22
+
23
+ expect(web_config.tenant).to be_a Stormpath::Resource::Tenant
24
+ expect(web_config.application).to be_a Stormpath::Resource::Application
25
+ expect(web_config.signing_api_key).to be_a Stormpath::Resource::ApiKey
26
+ end
27
+
28
+ it 'should respond to endpoints' do
29
+ Stormpath::Resource::ApplicationWebConfig::ENDPOINTS.each do |endpoint|
30
+ expect(web_config).to respond_to(endpoint)
31
+ expect(web_config).to respond_to("#{endpoint}=")
32
+ expect(web_config.send(endpoint)).to be_a Hash
33
+ end
34
+ end
35
+ end
36
+
37
+ describe 'enabling/disabling endpoints' do
38
+ it 'should be able to switch to enabled and disabled' do
39
+ Stormpath::Resource::ApplicationWebConfig::ENDPOINTS.each do |endpoint_name|
40
+ web_config.send("#{endpoint_name}=", enabled: false)
41
+ web_config.save
42
+
43
+ expect(application.web_config.send(endpoint_name).send(:[], 'enabled')).to eq false
44
+ end
45
+ end
46
+
47
+ it 'should switch configuration options for the /me endpoint' do
48
+ web_config.me = {
49
+ enabled: true,
50
+ expand: {
51
+ tenant: true,
52
+ directory: true,
53
+ groups: false,
54
+ providerData: true
55
+ }
56
+ }
57
+
58
+ web_config.save
59
+ expect(application.web_config.me['expand']['tenant']).to eq true
60
+ expect(application.web_config.me['expand']['directory']).to eq true
61
+ expect(application.web_config.me['expand']['groups']).to eq false
62
+ expect(application.web_config.me['expand']['providerData']).to eq true
63
+ end
64
+ end
65
+ end
@@ -402,7 +402,7 @@ describe Stormpath::Resource::Collection, :vcr do
402
402
  it 'should search accounts by custom data attribute' do
403
403
  expect(account.custom_data['targetAttribute']).to eq 'findMe'
404
404
  expect(directory.accounts.count).to eq 2
405
- sleep 5
405
+ wait_for_custom_data_indexing
406
406
  expect(directory.accounts.search('customData.targetAttribute' => 'findMe').count).to eq(2)
407
407
  end
408
408
  end
@@ -418,7 +418,7 @@ describe Stormpath::Resource::Collection, :vcr do
418
418
  it 'should be able to fetch custom data attributes with snake case' do
419
419
  expect(account.custom_data['target_attribute']).to eq 'findMe'
420
420
  expect(directory.accounts.count).to eq 2
421
- sleep 5
421
+ wait_for_custom_data_indexing
422
422
  expect(directory.accounts.search('customData.target_attribute' => 'findMe').count).to eq(2)
423
423
  end
424
424
  end
@@ -66,6 +66,8 @@ describe Stormpath::Resource::Directory, :vcr do
66
66
  before do
67
67
  directory.groups.create(name: 'US group', description: 'Described groups from United S.')
68
68
  directory.groups.create(name: 'EU group', description: 'Described groups from Europe')
69
+ group.custom_data['status'] = 'active'
70
+ group.save
69
71
  end
70
72
 
71
73
  it 'should return groups by name' do
@@ -83,6 +85,11 @@ describe Stormpath::Resource::Directory, :vcr do
83
85
  it 'should return groups when searching description with asterisks' do
84
86
  expect(directory.groups.search(description: '*groups*').count).to eq 2
85
87
  end
88
+
89
+ it 'should return groups when searching custom data' do
90
+ wait_for_custom_data_indexing
91
+ expect(directory.groups.search('customData.status' => 'active').first).to eq group
92
+ end
86
93
  end
87
94
  end
88
95
 
@@ -26,6 +26,7 @@ describe Stormpath::Resource::Organization, :vcr do
26
26
  expect(organization.custom_data).to be_a Stormpath::Resource::CustomData
27
27
  expect(organization.groups).to be_a Stormpath::Resource::Collection
28
28
  expect(organization.accounts).to be_a Stormpath::Resource::Collection
29
+ expect(organization.account_linking_policy).to be_a Stormpath::Resource::AccountLinkingPolicy
29
30
  end
30
31
  end
31
32
 
@@ -23,11 +23,19 @@ describe Stormpath::Resource::Schema, :vcr do
23
23
 
24
24
  describe 'schema associations' do
25
25
  context '#fields' do
26
- let(:field) { directory.fields.first }
27
-
28
26
  it 'should be able to get a list of fields' do
29
27
  expect(schema.fields).to be_a Stormpath::Resource::Collection
30
28
  end
29
+
30
+ it 'should be able to update the required property' do
31
+ surname_field = schema.fields.search(name: 'surname').first
32
+ expect(surname_field.required).to be(false)
33
+
34
+ surname_field.required = true
35
+ surname_field.save
36
+
37
+ expect(schema.fields.search(name: 'surname').first.required).to eq true
38
+ end
31
39
  end
32
40
 
33
41
  context '#directory' do
@@ -41,6 +41,7 @@ RSpec.configure do |c|
41
41
  c.include Stormpath::Test::ApiKeyHelpers
42
42
  c.include Stormpath::Test::EnvNamesWarning
43
43
  c.include Stormpath::Test::ResourceHelpers
44
+ c.include Stormpath::Test::CustomDataSavePeriod
44
45
 
45
46
  Stormpath::Test::EnvNamesWarning.check_env_variable_names
46
47
  end
@@ -0,0 +1,12 @@
1
+ # The wait_for_custom_data_indexing method is used throughout the specs when we search
2
+ # the recently saved custom data. Since Elasticsearch is being used in the backend,
3
+ # a small time period is needed for the data to finish indexing.
4
+ module Stormpath
5
+ module Test
6
+ module CustomDataSavePeriod
7
+ def wait_for_custom_data_indexing
8
+ sleep 5
9
+ end
10
+ end
11
+ end
12
+ end
@@ -9,6 +9,8 @@ module Stormpath
9
9
  MultiJson.dump(LINKEDIN_ACCOUNT)
10
10
  elsif provider.to_sym == :github
11
11
  MultiJson.dump(GITHUB_ACCOUNT)
12
+ elsif provider.to_sym == :twitter
13
+ MultiJson.dump(TWITTER_ACCOUNT)
12
14
  end
13
15
  end
14
16
 
@@ -21,6 +23,8 @@ module Stormpath
21
23
  MultiJson.dump(LINKEDIN_PROVIDER_DATA)
22
24
  elsif provider.to_sym == :github
23
25
  MultiJson.dump(GITHUB_PROVIDER_DATA)
26
+ elsif provider.to_sym == :twitter
27
+ MultiJson.dump(TWITTER_PROVIDER_DATA)
24
28
  end
25
29
  end
26
30
 
@@ -122,6 +126,24 @@ module Stormpath
122
126
  groupMemberships: { href: "https://api.stormpath.com/v1/accounts/7jdiPam0PWES317hwRR5a7/groupMemberships"}
123
127
  }
124
128
 
129
+ TWITTER_ACCOUNT = {
130
+ href: "https://api.stormpath.com/v1/accounts/7jdiPam0PWES317hwRR5a7",
131
+ username: "nenad.nikolic",
132
+ email: "nnikolic87@gmail.com",
133
+ givenName: "Nenad",
134
+ middleName: nil,
135
+ surname: "Nikolic",
136
+ fullName: "Nenad Nikolic",
137
+ status: "ENABLED",
138
+ emailVerificationToken: nil,
139
+ customData: { href: "https://api.stormpath.com/v1/accounts/7jdiPam0PWES317hwRR5a7/customData"},
140
+ providerData: { href:"https://api.stormpath.com/v1/accounts/7jdiPam0PWES317hwRR5a7/providerData"},
141
+ directory: { href: "https://api.stormpath.com/v1/directories/7ibyn2idP1d9p3qJOomeNP"},
142
+ tenant: { href: "https://api.stormpath.com/v1/tenants/60bD3bKLej6JoFhyKFHiOk"},
143
+ groups: { href: "https://api.stormpath.com/v1/accounts/7jdiPam0PWES317hwRR5a7/groups"},
144
+ groupMemberships: { href: "https://api.stormpath.com/v1/accounts/7jdiPam0PWES317hwRR5a7/groupMemberships"}
145
+ }
146
+
125
147
  GITHUB_PROVIDER_DATA = {
126
148
  href: "https://api.stormpath.com/v1/accounts/7jdiPam0PWES317hwRR5a7/providerData",
127
149
  createdAt: "2014-05-19T13:32:16.884Z",
@@ -130,6 +152,14 @@ module Stormpath
130
152
  providerId: "github"
131
153
  }
132
154
 
155
+ TWITTER_PROVIDER_DATA = {
156
+ href: "https://api.stormpath.com/v1/accounts/7jdiPam0PWES317hwRR5a7/providerData",
157
+ createdAt: "2014-05-19T13:32:16.884Z",
158
+ modifiedAt: "2014-05-19T13:32:16.927Z",
159
+ accessToken: "CAATmZBgxF6rMBAPYbfBhGrVPRw27nn9fAz6bR0DBV1XGfOcSYXSBrhZCkE1y1lWue348fboRxqX7nz88KBYi05qCHw4AQoZCqyIaWedEXrV2vFVzVHo2glq6Vb1ofAWcEHva7baZAaojA8KN5DVz4UTToKgvoIMa1kjyvZCmFZBpYXoG7H3aIKoyWJzUGCDIUrcFjvjnNZBvAZDZD",
160
+ providerId: "twitter"
161
+ }
162
+
133
163
  GOOGLE_ACCOUNT = {
134
164
  href: "https://api.stormpath.com/v1/accounts/2XdHmcyFG8HJCYBTEL1dJj",
135
165
  username: "damir.svrtan@gmail.com",
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.4.0
4
+ version: 1.5.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-11-22 00:00:00.000000000 Z
12
+ date: 2017-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -386,16 +386,20 @@ files:
386
386
  - lib/stormpath-sdk/provider/saml/saml_provider_metadata.rb
387
387
  - lib/stormpath-sdk/provider/stormpath/stormpath_provider.rb
388
388
  - lib/stormpath-sdk/provider/stormpath/stormpath_provider_data.rb
389
+ - lib/stormpath-sdk/provider/twitter/twitter_provider.rb
390
+ - lib/stormpath-sdk/provider/twitter/twitter_provider_data.rb
389
391
  - lib/stormpath-sdk/resource/access_token.rb
390
392
  - lib/stormpath-sdk/resource/account.rb
391
393
  - lib/stormpath-sdk/resource/account_creation_policy.rb
392
394
  - lib/stormpath-sdk/resource/account_link.rb
395
+ - lib/stormpath-sdk/resource/account_linking_policy.rb
393
396
  - lib/stormpath-sdk/resource/account_membership.rb
394
397
  - lib/stormpath-sdk/resource/account_overrides.rb
395
398
  - lib/stormpath-sdk/resource/account_store.rb
396
399
  - lib/stormpath-sdk/resource/account_store_mapping.rb
397
400
  - lib/stormpath-sdk/resource/api_key.rb
398
401
  - lib/stormpath-sdk/resource/application.rb
402
+ - lib/stormpath-sdk/resource/application_web_config.rb
399
403
  - lib/stormpath-sdk/resource/associations.rb
400
404
  - lib/stormpath-sdk/resource/base.rb
401
405
  - lib/stormpath-sdk/resource/challenge.rb
@@ -449,11 +453,13 @@ files:
449
453
  - spec/provider/provider_spec.rb
450
454
  - spec/resource/account_creation_policy_spec.rb
451
455
  - spec/resource/account_link_spec.rb
456
+ - spec/resource/account_linking_policy_spec.rb
452
457
  - spec/resource/account_spec.rb
453
458
  - spec/resource/account_store_mapping_spec.rb
454
459
  - spec/resource/account_store_spec.rb
455
460
  - spec/resource/api_key_spec.rb
456
461
  - spec/resource/application_spec.rb
462
+ - spec/resource/application_web_config_spec.rb
457
463
  - spec/resource/base_spec.rb
458
464
  - spec/resource/challenge_spec.rb
459
465
  - spec/resource/collection_spec.rb
@@ -475,6 +481,7 @@ files:
475
481
  - spec/resource/tenant_spec.rb
476
482
  - spec/spec_helper.rb
477
483
  - spec/support/api_key_helpers.rb
484
+ - spec/support/custom_data_save_period.rb
478
485
  - spec/support/custom_data_storage_behavior.rb
479
486
  - spec/support/env_names_warning.rb
480
487
  - spec/support/mocked_provider_accounts.rb