stormpath-sdk 1.0.0.beta.6 → 1.0.0.beta.7

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 (45) hide show
  1. data/.travis.yml +2 -0
  2. data/CHANGES.md +10 -0
  3. data/lib/stormpath-sdk.rb +15 -0
  4. data/lib/stormpath-sdk/data_store.rb +30 -14
  5. data/lib/stormpath-sdk/http/request.rb +5 -25
  6. data/lib/stormpath-sdk/http/response.rb +0 -5
  7. data/lib/stormpath-sdk/provider/account_access.rb +28 -0
  8. data/lib/stormpath-sdk/provider/account_request.rb +30 -0
  9. data/lib/stormpath-sdk/provider/account_resolver.rb +43 -0
  10. data/lib/stormpath-sdk/provider/account_result.rb +27 -0
  11. data/lib/stormpath-sdk/provider/facebook/facebook_provider.rb +18 -0
  12. data/lib/stormpath-sdk/provider/facebook/facebook_provider_data.rb +18 -0
  13. data/lib/stormpath-sdk/provider/google/google_provider.rb +18 -0
  14. data/lib/stormpath-sdk/provider/google/google_provider_data.rb +19 -0
  15. data/lib/stormpath-sdk/provider/provider.rb +18 -0
  16. data/lib/stormpath-sdk/provider/provider_data.rb +18 -0
  17. data/lib/stormpath-sdk/provider/stormpath/stormpath_provider.rb +17 -0
  18. data/lib/stormpath-sdk/provider/stormpath/stormpath_provider_data.rb +17 -0
  19. data/lib/stormpath-sdk/resource/account.rb +15 -0
  20. data/lib/stormpath-sdk/resource/application.rb +5 -2
  21. data/lib/stormpath-sdk/resource/associations.rb +7 -5
  22. data/lib/stormpath-sdk/resource/directory.rb +15 -0
  23. data/lib/stormpath-sdk/version.rb +2 -2
  24. data/spec/auth/basic_authenticator_spec.rb +5 -5
  25. data/spec/cache/cache_entry_spec.rb +3 -3
  26. data/spec/client_spec.rb +27 -20
  27. data/spec/provider/account_resolver_spec.rb +25 -0
  28. data/spec/provider/provider_spec.rb +152 -0
  29. data/spec/resource/account_spec.rb +26 -30
  30. data/spec/resource/account_store_mapping_spec.rb +28 -27
  31. data/spec/resource/account_store_spec.rb +7 -7
  32. data/spec/resource/application_spec.rb +34 -26
  33. data/spec/resource/collection_spec.rb +34 -34
  34. data/spec/resource/custom_data_spec.rb +2 -2
  35. data/spec/resource/directory_spec.rb +25 -23
  36. data/spec/resource/group_membership_spec.rb +3 -3
  37. data/spec/resource/group_spec.rb +16 -17
  38. data/spec/resource/status_spec.rb +16 -16
  39. data/spec/resource/tenant_spec.rb +10 -8
  40. data/spec/spec_helper.rb +37 -18
  41. data/spec/support/custom_data_storage_behavior.rb +19 -19
  42. data/spec/support/mocked_provider_accounts.rb +72 -0
  43. data/stormpath-sdk.gemspec +5 -9
  44. metadata +104 -111
  45. checksums.yaml +0 -7
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2014 Stormpath, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ class Stormpath::Provider::GoogleProviderData < Stormpath::Provider::ProviderData
17
+ prop_reader :access_token, :refresh_token
18
+ end
19
+
@@ -0,0 +1,18 @@
1
+ #
2
+ # Copyright 2014 Stormpath, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ class Stormpath::Provider::Provider < Stormpath::Resource::Base
17
+ prop_reader :provider_id, :created_at, :modified_at
18
+ end
@@ -0,0 +1,18 @@
1
+ #
2
+ # Copyright 2014 Stormpath, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ class Stormpath::Provider::ProviderData < Stormpath::Resource::Base
17
+ prop_reader :provider_id, :created_at, :modified_at
18
+ end
@@ -0,0 +1,17 @@
1
+ #
2
+ # Copyright 2014 Stormpath, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ class Stormpath::Provider::StormpathProvider < Stormpath::Provider::Provider
17
+ end
@@ -0,0 +1,17 @@
1
+ #
2
+ # Copyright 2014 Stormpath, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ class Stormpath::Provider::StormpathProviderData < Stormpath::Provider::ProviderData
17
+ end
@@ -41,4 +41,19 @@ class Stormpath::Resource::Account < Stormpath::Resource::Instance
41
41
  group_membership.delete if group_membership
42
42
  end
43
43
 
44
+ def provider_data
45
+ internal_instance = instance_variable_get "@_provider_data"
46
+ return internal_instance if internal_instance
47
+
48
+ provider_data_href = self.href + '/providerData'
49
+
50
+ clazz_proc = Proc.new do |data|
51
+ provider_id = data['providerId']
52
+ "Stormpath::Provider::#{provider_id.capitalize}ProviderData".constantize
53
+ end
54
+
55
+ provider_data = data_store.get_resource provider_data_href, clazz_proc
56
+ instance_variable_set "@_provider_data", provider_data
57
+ end
58
+
44
59
  end
@@ -57,8 +57,11 @@ class Stormpath::Resource::Application < Stormpath::Resource::Instance
57
57
  end
58
58
 
59
59
  def authenticate_account request
60
- response = Stormpath::Authentication::BasicAuthenticator.new data_store
61
- response.authenticate href, request
60
+ Stormpath::Authentication::BasicAuthenticator.new(data_store).authenticate(href, request)
61
+ end
62
+
63
+ def get_provider_account request
64
+ Stormpath::Provider::AccountResolver.new(data_store).resolve_provider_account(href, request)
62
65
  end
63
66
 
64
67
  private
@@ -88,15 +88,17 @@ module Stormpath
88
88
  if value.is_a? Hash
89
89
  resource_href = get_href_from_hash value
90
90
  end
91
-
92
- if instance_variable_get("@_#{key.underscore}").nil?
91
+
92
+ key_name = "@_#{key.underscore}"
93
+
94
+ if instance_variable_get(key_name).nil?
93
95
  if resource_href
94
- instance_variable_set("@_#{key.underscore}", data_store.instantiate(clazz, value))
96
+ instance_variable_set(key_name, data_store.instantiate(clazz, value))
95
97
  else
96
- instance_variable_set("@_#{key.underscore}", clazz.new(value))
98
+ instance_variable_set(key_name, clazz.new(value))
97
99
  end
98
100
  end
99
- instance_variable_get("@_#{key.underscore}")
101
+ instance_variable_get(key_name)
100
102
  end
101
103
 
102
104
  def get_resource_href_property(key)
@@ -31,4 +31,19 @@ class Stormpath::Resource::Directory < Stormpath::Resource::Instance
31
31
  account.apply_custom_data_updates_if_necessary
32
32
  data_store.create href, account, Stormpath::Resource::Account
33
33
  end
34
+
35
+ def provider
36
+ internal_instance = instance_variable_get "@_provider"
37
+ return internal_instance if internal_instance
38
+
39
+ provider_href = self.href + '/provider'
40
+
41
+ clazz_proc = Proc.new do |data|
42
+ provider_id = data['providerId']
43
+ "Stormpath::Provider::#{provider_id.capitalize}Provider".constantize
44
+ end
45
+
46
+ provider = data_store.get_resource provider_href, clazz_proc
47
+ instance_variable_set "@_provider", provider
48
+ end
34
49
  end
@@ -14,6 +14,6 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Stormpath
17
- VERSION = '1.0.0.beta.6'
18
- VERSION_DATE = '2014-07-07'
17
+ VERSION = '1.0.0.beta.7'
18
+ VERSION_DATE = '2014-07-21'
19
19
  end
@@ -4,17 +4,17 @@ describe "BasicAuthenticator" do
4
4
  context "given an instance of BasicAuthenticator" do
5
5
 
6
6
  before do
7
- ds = Stormpath::DataStore.new "", {}, ""
8
- allow(test_api_client).to receive(:data_store).and_return(ds)
7
+ data_store = Stormpath::DataStore.new "", {}, ""
8
+ allow(test_api_client).to receive(:data_store).and_return(data_store)
9
9
  auth_result = Stormpath::Authentication::AuthenticationResult.new({}, test_api_client)
10
- allow(ds).to receive(:create).and_return(auth_result)
10
+ allow(data_store).to receive(:create).and_return(auth_result)
11
11
 
12
- @ba = Stormpath::Authentication::BasicAuthenticator.new ds
12
+ @basic_authenticator = Stormpath::Authentication::BasicAuthenticator.new data_store
13
13
  end
14
14
 
15
15
  context "when authenticating" do
16
16
  before do
17
- @response = @ba.authenticate "foo/bar", Stormpath::Authentication::UsernamePasswordRequest.new("fake-username", "fake-password")
17
+ @response = @basic_authenticator.authenticate "foo/bar", Stormpath::Authentication::UsernamePasswordRequest.new("fake-username", "fake-password")
18
18
  end
19
19
 
20
20
  it "an AuthenticationResult is returned" do
@@ -63,7 +63,7 @@ describe Stormpath::Cache::CacheEntry do
63
63
  end
64
64
 
65
65
  it 'returns false' do
66
- expect(expired).to be_false
66
+ expect(expired).to be_falsey
67
67
  end
68
68
  end
69
69
 
@@ -76,7 +76,7 @@ describe Stormpath::Cache::CacheEntry do
76
76
  end
77
77
 
78
78
  it 'returns true' do
79
- expect(@expired).to be_true
79
+ expect(@expired).to be_truthy
80
80
  end
81
81
  end
82
82
 
@@ -89,7 +89,7 @@ describe Stormpath::Cache::CacheEntry do
89
89
  end
90
90
 
91
91
  it 'returns true' do
92
- expect(@expired).to be_true
92
+ expect(@expired).to be_truthy
93
93
  end
94
94
  end
95
95
  end
data/spec/client_spec.rb CHANGED
@@ -285,7 +285,7 @@ properties
285
285
 
286
286
  it 'returns the collection' do
287
287
  expect(applications).to be_kind_of(Stormpath::Resource::Collection)
288
- expect(applications).to have_at_least(1).item
288
+ expect(applications.count).to be >= 1
289
289
  end
290
290
 
291
291
  after do
@@ -296,13 +296,13 @@ properties
296
296
  context 'pagination' do
297
297
  let!(:applications) do
298
298
  (0..2).to_a.map do |index|
299
- test_api_client.applications.create name: "Pagination Test #{index + 1}", description: 'foo'
299
+ test_api_client.applications.create name: random_application_name(index), description: 'foo'
300
300
  end
301
301
  end
302
302
 
303
303
  it 'accepts offset and limit' do
304
- expect(test_api_client.applications.limit(2)).to have_at_least(3).items
305
- expect(test_api_client.applications.offset(1).limit(2)).to have_at_least(2).items
304
+ expect(test_api_client.applications.limit(2).count).to be >= 3
305
+ expect(test_api_client.applications.offset(1).limit(2).count).to be >= 2
306
306
  end
307
307
 
308
308
  after do
@@ -337,11 +337,11 @@ properties
337
337
  end
338
338
 
339
339
  let(:directory) do
340
- client.directories.create name: 'testDirectory'
340
+ client.directories.create name: random_directory_name
341
341
  end
342
342
 
343
343
  let(:group) do
344
- directory.groups.create name: 'someGroup'
344
+ directory.groups.create name: random_group_name
345
345
  end
346
346
 
347
347
  let(:account) do
@@ -385,7 +385,7 @@ properties
385
385
  end
386
386
 
387
387
  let(:group) do
388
- directory.groups.create name: 'someGroup'
388
+ directory.groups.create name: random_group_name
389
389
  end
390
390
 
391
391
  before do
@@ -401,16 +401,20 @@ properties
401
401
  end
402
402
 
403
403
  context 'search' do
404
+
405
+ let(:first_application_name) { random_application_name(1) }
406
+ let(:second_application_name ) { random_application_name(2) }
407
+
404
408
  let!(:applications) do
405
409
  [
406
- test_api_client.applications.create(name: 'Test Alpha', description: 'foo'),
407
- test_api_client.applications.create(name: 'Test Beta', description: 'foo')
410
+ test_api_client.applications.create(name: first_application_name, description: 'foo'),
411
+ test_api_client.applications.create(name: second_application_name, description: 'foo')
408
412
  ]
409
413
  end
410
414
 
411
415
  context 'by any attribute' do
412
416
  let(:search_results) do
413
- test_api_client.applications.search('Test Alpha')
417
+ test_api_client.applications.search(first_application_name)
414
418
  end
415
419
 
416
420
  it 'returns the application' do
@@ -420,7 +424,7 @@ properties
420
424
 
421
425
  context 'by an explicit attribute' do
422
426
  let(:search_results) do
423
- test_api_client.applications.search(name: 'Test Alpha')
427
+ test_api_client.applications.search(name: first_application_name)
424
428
  end
425
429
 
426
430
  it 'returns the application' do
@@ -436,7 +440,7 @@ properties
436
440
  end
437
441
 
438
442
  describe '.create' do
439
- let(:application_name) { 'Client Application Create Test' }
443
+ let(:application_name) { random_application_name }
440
444
 
441
445
  let(:application_attributes) do
442
446
  {
@@ -543,7 +547,7 @@ properties
543
547
  end
544
548
  end
545
549
 
546
- after(:each) do
550
+ after(:each) do |example|
547
551
  unless example.metadata[:skip_cleanup]
548
552
  application.delete
549
553
  test_api_client.directories.each do |d|
@@ -570,7 +574,7 @@ properties
570
574
 
571
575
  it 'returns the collection' do
572
576
  expect(directories).to be_kind_of(Stormpath::Resource::Collection)
573
- expect(directories).to have_at_least(1).item
577
+ expect(directories.count).to be >= 1
574
578
  end
575
579
 
576
580
  after do
@@ -580,11 +584,11 @@ properties
580
584
 
581
585
  context 'given a collection with a limit' do
582
586
  let!(:directory_1) do
583
- test_api_client.directories.create name: "0000_test_directory_with_limit"
587
+ test_api_client.directories.create name: random_directory_name(1)
584
588
  end
585
589
 
586
590
  let!(:directory_2) do
587
- test_api_client.directories.create name: "0001_test_directory_with_limit"
591
+ test_api_client.directories.create name: random_directory_name(2)
588
592
  end
589
593
 
590
594
  after do
@@ -593,14 +597,17 @@ properties
593
597
  end
594
598
 
595
599
  it 'should retrieve the number of directories described with the limit' do
596
- expect(test_api_client.directories).to have_at_least(2).items
600
+ expect(test_api_client.directories.count).to be >= 2
597
601
  end
598
602
  end
599
603
 
600
604
  describe '.create' do
605
+
606
+ let(:directory_name) { random_directory_name }
607
+
601
608
  let(:directory_attributes) do
602
609
  {
603
- name: 'Client Directory Create Test',
610
+ name: directory_name,
604
611
  description: 'A test description'
605
612
  }
606
613
  end
@@ -627,11 +634,11 @@ properties
627
634
 
628
635
  let(:account) do
629
636
  account = Stormpath::Resource::Account.new({
630
- email: "test@example.com",
637
+ email: random_email,
631
638
  givenName: 'Ruby SDK',
632
639
  password: 'P@$$w0rd',
633
640
  surname: 'SDK',
634
- username: "testusername"
641
+ username: random_user_name
635
642
  })
636
643
  directory.create_account account
637
644
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ProviderAccountResolver" do
4
+ context "given an instance of ProviderAccountResolver" do
5
+
6
+ before do
7
+ data_store = Stormpath::DataStore.new "", {}, ""
8
+ allow(test_api_client).to receive(:data_store).and_return(data_store)
9
+ auth_result = Stormpath::Provider::AccountResult.new({}, test_api_client)
10
+ allow(data_store).to receive(:create).and_return(auth_result)
11
+
12
+ @provider_account_resolver = Stormpath::Provider::AccountResolver.new data_store
13
+ end
14
+
15
+ context "when integrating" do
16
+ before do
17
+ @response = @provider_account_resolver.resolve_provider_account "foo/bar", Stormpath::Provider::AccountRequest.new(:facebook, :access_token, "some-token")
18
+ end
19
+
20
+ it "an ProviderResult is returned" do
21
+ expect(@response).to be_a Stormpath::Provider::AccountResult
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,152 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stormpath::Provider::Provider, :vcr do
4
+
5
+ let(:application) do
6
+ test_api_client.applications.create name: random_application_name,
7
+ description: 'Test Provider Application for AccountStoreMappings'
8
+ end
9
+
10
+ let(:account_store_mapping) do
11
+ test_api_client.account_store_mappings.create application: application, account_store: directory
12
+ end
13
+
14
+ let(:directory) do
15
+ test_api_client.directories.create directory_hash
16
+ end
17
+
18
+ let(:directory_hash) do
19
+ Hash.new.tap do |hash|
20
+ hash[:name] = name
21
+ hash[:description] = description
22
+ hash[:provider] = provider_info if defined? provider_info
23
+ end
24
+ end
25
+
26
+ subject(:provider) do
27
+ directory.provider
28
+ end
29
+
30
+ after do
31
+ directory.delete
32
+ application.delete
33
+ end
34
+
35
+ shared_examples 'a provider directory' do
36
+ it { should be_kind_of Stormpath::Provider::Provider }
37
+
38
+ it "assign provider directory to an application" do
39
+ expect(application.account_store_mappings.count).to eq(0)
40
+ expect(account_store_mapping.application).to eq(application)
41
+ expect(account_store_mapping.account_store).to eq(directory)
42
+ expect(application.account_store_mappings.count).to eq(1)
43
+ end
44
+
45
+ it 'should properly respond to attributes' do
46
+ expect(provider.provider_id).to eq(provider_id)
47
+ expect(provider.created_at).to be
48
+ expect(provider.modified_at).to be
49
+ expect(provider.href).to eq(directory.href + "/provider")
50
+
51
+ provider_clazz = "Stormpath::Provider::#{provider_id.capitalize}Provider".constantize
52
+ expect(provider).to be_instance_of(provider_clazz)
53
+
54
+ if provider_id == "google" || provider_id == "facebook"
55
+ expect(provider.client_id).to eq(client_id)
56
+ expect(provider.client_secret).to eq(client_secret)
57
+ end
58
+
59
+ if provider_id == "google"
60
+ expect(provider.redirect_uri).to eq(redirect_uri)
61
+ end
62
+ end
63
+ end
64
+
65
+ shared_examples 'a syncrhonizeable directory' do
66
+ it 'should be able to store provider accounts' do
67
+ account_store_mapping
68
+
69
+ access_token = "xyz"
70
+ request = Stormpath::Provider::AccountRequest.new(provider_id, :access_token, access_token)
71
+
72
+ stub_request(:post, application.href + "/accounts").to_return(body: Stormpath::Test.mocked_account(provider_id), status: 201)
73
+ result = application.get_provider_account(request)
74
+ expect(result.is_new_account?).to be
75
+ expect(result.account).to be_kind_of(Stormpath::Resource::Account)
76
+
77
+ stub_request(:get, result.account.href + "/providerData").to_return(body: Stormpath::Test.mocked_provider_data(provider_id))
78
+
79
+ expect(result.account.provider_data).to be_kind_of(Stormpath::Provider::ProviderData)
80
+ provider_data_clazz = "Stormpath::Provider::#{provider_id.capitalize}ProviderData".constantize
81
+ expect(result.account.provider_data).to be_instance_of(provider_data_clazz)
82
+
83
+ expect(result.account.provider_data.provider_id).to eq(provider_id)
84
+ expect(result.account.provider_data.created_at).to be
85
+ expect(result.account.provider_data.modified_at).to be
86
+ expect(result.account.provider_data.access_token).to be
87
+
88
+ if provider_id == 'google'
89
+ expect(result.account.provider_data.refresh_token).to be
90
+ end
91
+
92
+ stub_request(:post, application.href + "/accounts").to_return(body: Stormpath::Test.mocked_account(provider_id), status: 200)
93
+ new_result = application.get_provider_account(request)
94
+ expect(new_result.is_new_account).not_to be
95
+ end
96
+ end
97
+
98
+ describe 'create stormpath directory with empty provider credentials' do
99
+ let(:name) { random_directory_name('Stormpath') }
100
+ let(:description) { 'Directory for testing Stormpath directories.' }
101
+ let(:provider_id) { "stormpath" }
102
+
103
+ it_behaves_like 'a provider directory'
104
+
105
+ it 'should be able to retrieve provider data from a regular account' do
106
+ account = directory.accounts.create({
107
+ given_name: 'John',
108
+ surname: 'Smith',
109
+ email: 'john.smith@example.com',
110
+ username: 'johnsmith',
111
+ password: '4P@$$w0rd!'
112
+ })
113
+
114
+ expect(account.provider_data).to be_kind_of(Stormpath::Provider::ProviderData)
115
+ expect(account.provider_data.provider_id).to eq(provider_id)
116
+ expect(account.provider_data.created_at).to be
117
+ expect(account.provider_data.modified_at).to be
118
+ expect(account.provider_data).to be_instance_of(Stormpath::Provider::StormpathProviderData)
119
+ end
120
+ end
121
+
122
+ describe 'create facebook directory with provider credentials' do
123
+ let(:name) { random_directory_name('Facebook') }
124
+ let(:description) { 'Directory for testing Facebook directories.' }
125
+
126
+ let(:provider_id) { "facebook" }
127
+ let(:client_id) { 'FACEBOOK_APP_ID' }
128
+ let(:client_secret) { 'FACEBOOK_APP_SECRET' }
129
+ let(:provider_info) do
130
+ { provider_id: provider_id, client_id: client_id, client_secret: client_secret }
131
+ end
132
+
133
+ it_behaves_like 'a provider directory'
134
+ it_behaves_like 'a syncrhonizeable directory'
135
+ end
136
+
137
+ describe 'create google directory with provider credentials' do
138
+ let(:name) { random_directory_name('Google') }
139
+ let(:description) { 'Directory for testing Google directories.' }
140
+
141
+ let(:provider_id) { "google" }
142
+ let(:client_id) { 'GOOGLE_CLIENT_ID' }
143
+ let(:client_secret) { 'GOOGLE_CLIENT_SECRET' }
144
+ let(:redirect_uri) { 'GOOGLE_REDIRECT_URI' }
145
+ let(:provider_info) do
146
+ { provider_id: provider_id, client_id: client_id, client_secret: client_secret, redirect_uri: redirect_uri }
147
+ end
148
+
149
+ it_behaves_like 'a provider directory'
150
+ it_behaves_like 'a syncrhonizeable directory'
151
+ end
152
+ end