stormpath-sdk 1.6.0 → 1.7.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +21 -0
- data/CHANGES.md +11 -0
- data/README.md +23 -25
- data/lib/stormpath-sdk.rb +11 -2
- data/lib/stormpath-sdk/api_key.rb +0 -1
- data/lib/stormpath-sdk/auth/basic_authenticator.rb +7 -7
- data/lib/stormpath-sdk/auth/basic_login_attempt.rb +7 -11
- data/lib/stormpath-sdk/auth/create_factor.rb +1 -1
- data/lib/stormpath-sdk/auth/register_service_provider.rb +41 -0
- data/lib/stormpath-sdk/auth/username_password_request.rb +3 -5
- data/lib/stormpath-sdk/cache/cache.rb +3 -3
- data/lib/stormpath-sdk/cache/cache_entry.rb +2 -2
- data/lib/stormpath-sdk/cache/cache_manager.rb +3 -4
- data/lib/stormpath-sdk/cache/cache_stats.rb +1 -3
- data/lib/stormpath-sdk/cache/disabled_cache_store.rb +5 -8
- data/lib/stormpath-sdk/cache/memory_store.rb +1 -1
- data/lib/stormpath-sdk/cache/redis_store.rb +4 -4
- data/lib/stormpath-sdk/client.rb +35 -33
- data/lib/stormpath-sdk/data_store.rb +278 -257
- data/lib/stormpath-sdk/error.rb +18 -7
- data/lib/stormpath-sdk/http/authc/sauthc1_signer.rb +76 -82
- data/lib/stormpath-sdk/http/http_client_request_executor.rb +10 -8
- data/lib/stormpath-sdk/http/response.rb +5 -7
- data/lib/stormpath-sdk/id_site/id_site_result.rb +5 -6
- data/lib/stormpath-sdk/oauth/access_token_authentication_result.rb +5 -9
- data/lib/stormpath-sdk/oauth/authenticator.rb +2 -2
- data/lib/stormpath-sdk/oauth/error.rb +4 -4
- data/lib/stormpath-sdk/oauth/id_site_grant_request.rb +1 -1
- data/lib/stormpath-sdk/oauth/password_grant_request.rb +1 -1
- data/lib/stormpath-sdk/oauth/refresh_grant_request.rb +2 -2
- data/lib/stormpath-sdk/oauth/stormpath_grant_request.rb +2 -2
- data/lib/stormpath-sdk/provider/account_access.rb +0 -2
- data/lib/stormpath-sdk/provider/account_result.rb +1 -2
- data/lib/stormpath-sdk/provider/facebook/facebook_provider.rb +6 -2
- data/lib/stormpath-sdk/provider/facebook/facebook_provider_data.rb +7 -3
- data/lib/stormpath-sdk/provider/github/github_provider.rb +6 -2
- data/lib/stormpath-sdk/provider/github/github_provider_data.rb +6 -2
- data/lib/stormpath-sdk/provider/google/google_provider.rb +7 -3
- data/lib/stormpath-sdk/provider/google/google_provider_data.rb +6 -2
- data/lib/stormpath-sdk/provider/linkedin/linkedin_provider.rb +6 -2
- data/lib/stormpath-sdk/provider/linkedin/linkedin_provider_data.rb +6 -2
- data/lib/stormpath-sdk/provider/provider.rb +8 -4
- data/lib/stormpath-sdk/provider/provider_data.rb +6 -2
- data/lib/stormpath-sdk/provider/saml/saml_provider.rb +10 -4
- data/lib/stormpath-sdk/provider/saml/saml_provider_data.rb +6 -3
- data/lib/stormpath-sdk/provider/stormpath/stormpath_provider.rb +6 -2
- data/lib/stormpath-sdk/provider/stormpath/stormpath_provider_data.rb +6 -2
- data/lib/stormpath-sdk/provider/twitter/twitter_provider.rb +6 -2
- data/lib/stormpath-sdk/provider/twitter/twitter_provider_data.rb +6 -2
- data/lib/stormpath-sdk/resource/account.rb +46 -40
- data/lib/stormpath-sdk/resource/account_link.rb +9 -5
- data/lib/stormpath-sdk/resource/account_linking_policy.rb +8 -4
- data/lib/stormpath-sdk/resource/account_membership.rb +1 -1
- data/lib/stormpath-sdk/resource/account_overrides.rb +20 -16
- data/lib/stormpath-sdk/resource/account_store.rb +15 -11
- data/lib/stormpath-sdk/resource/account_store_mapping.rb +14 -13
- data/lib/stormpath-sdk/resource/application.rb +147 -136
- data/lib/stormpath-sdk/resource/application_web_config.rb +11 -7
- data/lib/stormpath-sdk/resource/associations.rb +36 -43
- data/lib/stormpath-sdk/resource/attribute_statement_mapping_rules.rb +8 -0
- data/lib/stormpath-sdk/resource/base.rb +201 -200
- data/lib/stormpath-sdk/resource/challenge.rb +12 -8
- data/lib/stormpath-sdk/resource/collection.rb +77 -76
- data/lib/stormpath-sdk/resource/custom_data.rb +60 -61
- data/lib/stormpath-sdk/resource/custom_data_hash_methods.rb +28 -25
- data/lib/stormpath-sdk/resource/custom_data_storage.rb +18 -16
- data/lib/stormpath-sdk/resource/directory.rb +37 -60
- data/lib/stormpath-sdk/resource/email_verification_token.rb +7 -3
- data/lib/stormpath-sdk/resource/error.rb +8 -4
- data/lib/stormpath-sdk/resource/expansion.rb +22 -20
- data/lib/stormpath-sdk/resource/factor.rb +12 -8
- data/lib/stormpath-sdk/resource/field.rb +8 -4
- data/lib/stormpath-sdk/resource/group.rb +21 -16
- data/lib/stormpath-sdk/resource/group_membership.rb +7 -5
- data/lib/stormpath-sdk/resource/instance.rb +10 -6
- data/lib/stormpath-sdk/resource/linked_account.rb +7 -3
- data/lib/stormpath-sdk/resource/oauth_policy.rb +7 -3
- data/lib/stormpath-sdk/resource/organization.rb +14 -10
- data/lib/stormpath-sdk/resource/organization_account_store_mapping.rb +8 -4
- data/lib/stormpath-sdk/resource/password_reset_token.rb +9 -5
- data/lib/stormpath-sdk/resource/phone.rb +8 -4
- data/lib/stormpath-sdk/resource/registered_saml_service_provider.rb +8 -0
- data/lib/stormpath-sdk/resource/saml_identity_provider.rb +14 -0
- data/lib/stormpath-sdk/resource/saml_identity_provider_metadata.rb +9 -0
- data/lib/stormpath-sdk/resource/saml_policy.rb +10 -0
- data/lib/stormpath-sdk/resource/saml_service_provider.rb +7 -0
- data/lib/stormpath-sdk/{provider/saml/saml_mapping_rules.rb → resource/saml_service_provider_metadata.rb} +6 -5
- data/lib/stormpath-sdk/resource/saml_service_provider_registration.rb +11 -0
- data/lib/stormpath-sdk/resource/schema.rb +8 -4
- data/lib/stormpath-sdk/resource/tenant.rb +11 -8
- data/lib/stormpath-sdk/resource/user_info_mapping_rules.rb +7 -3
- data/lib/stormpath-sdk/resource/utils.rb +7 -10
- data/lib/stormpath-sdk/resource/verification_email.rb +7 -3
- data/lib/stormpath-sdk/resource/x_509_certificate.rb +7 -0
- data/lib/stormpath-sdk/util/assert.rb +1 -3
- data/lib/stormpath-sdk/version.rb +2 -2
- data/spec/auth/basic_authenticator_spec.rb +28 -24
- data/spec/auth/register_service_provider_spec.rb +68 -0
- data/spec/auth/sauthc1_signer_spec.rb +8 -4
- data/spec/cache/cache_entry_spec.rb +28 -29
- data/spec/cache/cache_spec.rb +9 -9
- data/spec/cache/cache_stats_spec.rb +1 -1
- data/spec/client_spec.rb +63 -63
- data/spec/data_store_spec.rb +23 -14
- data/spec/oauth/access_token_authentication_result_spec.rb +8 -2
- data/spec/provider/account_resolver_spec.rb +6 -4
- data/spec/provider/provider_spec.rb +6 -6
- data/spec/resource/account_creation_policy_spec.rb +1 -1
- data/spec/resource/account_link_spec.rb +7 -15
- data/spec/resource/account_spec.rb +17 -17
- data/spec/resource/account_store_mapping_spec.rb +16 -22
- data/spec/resource/account_store_spec.rb +3 -3
- data/spec/resource/application_spec.rb +324 -330
- data/spec/resource/base_spec.rb +7 -31
- data/spec/resource/collection_spec.rb +63 -114
- data/spec/resource/custom_data_spec.rb +1 -1
- data/spec/resource/directory_spec.rb +91 -87
- data/spec/resource/expansion_spec.rb +10 -10
- data/spec/resource/factor_spec.rb +1 -1
- data/spec/resource/group_spec.rb +1 -1
- data/spec/resource/linked_account_spec.rb +7 -7
- data/spec/resource/organization_spec.rb +12 -11
- data/spec/resource/phone_spec.rb +1 -1
- data/spec/resource/registered_saml_service_provider_spec.rb +35 -0
- data/spec/resource/saml_identity_provider_metadata_spec.rb +27 -0
- data/spec/resource/saml_identity_provider_spec.rb +94 -0
- data/spec/resource/saml_policy_spec.rb +27 -0
- data/spec/resource/saml_service_provider_registration_spec.rb +58 -0
- data/spec/resource/saml_service_provider_spec.rb +19 -0
- data/spec/resource/status_spec.rb +4 -3
- data/spec/resource/tenant_spec.rb +4 -6
- data/spec/spec_helper.rb +1 -1
- data/spec/support/custom_data_save_period.rb +4 -0
- data/spec/support/custom_data_storage_behavior.rb +7 -8
- data/spec/support/mocked_provider_accounts.rb +101 -101
- data/spec/support/mocked_saml_responses.rb +130 -0
- data/spec/support/resource_factory.rb +4 -4
- data/spec/support/resource_helpers.rb +10 -4
- data/spec/support/resource_matchers.rb +4 -4
- data/spec/support/test_request_executor.rb +2 -2
- metadata +21 -8
- data/lib/stormpath-sdk/provider/saml/saml_provider_metadata.rb +0 -19
- data/spec/fixtures/response/create_saml_directory.json +0 -26
- data/spec/fixtures/response/create_saml_directory_mapping_rules.json +0 -12
- data/spec/fixtures/response/get_saml_directory_provider.json +0 -16
- data/spec/fixtures/response/get_saml_directory_provider_metadata.json +0 -12
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Stormpath
|
|
2
|
+
module Resource
|
|
3
|
+
class SamlIdentityProvider < Stormpath::Resource::Instance
|
|
4
|
+
prop_reader :sso_login_endpoint, :signature_algorithm, :sha_fingerprint, :created_at, :modified_at
|
|
5
|
+
prop_accessor :status
|
|
6
|
+
|
|
7
|
+
has_one :metadata, class_name: :samlIdentityProviderMetadata
|
|
8
|
+
has_one :attribute_statement_mapping_rules
|
|
9
|
+
has_one :x509_signing_cert, class_name: :x509Certificate
|
|
10
|
+
has_many :registered_saml_service_providers
|
|
11
|
+
has_many :saml_service_provider_registrations, can: [:get, :create]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module Stormpath
|
|
2
|
+
module Resource
|
|
3
|
+
class SamlIdentityProviderMetadata < Stormpath::Resource::Instance
|
|
4
|
+
prop_reader :entity_id
|
|
5
|
+
belongs_to :identity_provider, class_name: :samlIdentityProvider
|
|
6
|
+
has_one :x509_signing_cert, class_name: :x509Certificate
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module Stormpath
|
|
2
|
+
module Resource
|
|
3
|
+
class SamlPolicy < Stormpath::Resource::Instance
|
|
4
|
+
prop_reader :created_at, :modified_at
|
|
5
|
+
|
|
6
|
+
has_one :service_provider, class_name: :samlServiceProvider
|
|
7
|
+
has_one :identity_provider, class_name: :samlIdentityProvider
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
module Stormpath
|
|
17
|
+
module Resource
|
|
18
|
+
class SamlServiceProviderMetadata < Stormpath::Resource::Instance
|
|
19
|
+
prop_reader :href, :created_at, :modified_at, :entity_id, :x509_signing_cert,
|
|
20
|
+
:assertion_consumer_service_post_endpoint
|
|
21
|
+
end
|
|
21
22
|
end
|
|
22
23
|
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Stormpath
|
|
2
|
+
module Resource
|
|
3
|
+
class SamlServiceProviderRegistration < Stormpath::Resource::Instance
|
|
4
|
+
prop_reader :created_at, :modified_at
|
|
5
|
+
prop_accessor :status, :default_relay_state
|
|
6
|
+
|
|
7
|
+
has_one :service_provider, class_name: :registeredSamlServiceProvider
|
|
8
|
+
has_one :identity_provider, class_name: :samlIdentityProvider
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -13,9 +13,13 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
module Stormpath
|
|
17
|
+
module Resource
|
|
18
|
+
class Schema < Stormpath::Resource::Instance
|
|
19
|
+
prop_reader :created_at, :modified_at
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
has_many :fields
|
|
22
|
+
belongs_to :directory
|
|
23
|
+
end
|
|
24
|
+
end
|
|
21
25
|
end
|
|
@@ -13,14 +13,17 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
module Stormpath
|
|
17
|
+
module Resource
|
|
18
|
+
class Tenant < Stormpath::Resource::Instance
|
|
19
|
+
include Stormpath::Resource::CustomDataStorage
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
has_many :applications
|
|
22
|
-
has_many :directories
|
|
23
|
-
has_many :organizations
|
|
24
|
-
has_one :custom_data
|
|
21
|
+
prop_reader :name, :key, :created_at, :modified_at
|
|
25
22
|
|
|
23
|
+
has_many :applications
|
|
24
|
+
has_many :directories
|
|
25
|
+
has_many :organizations
|
|
26
|
+
has_one :custom_data
|
|
27
|
+
end
|
|
28
|
+
end
|
|
26
29
|
end
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
module Stormpath
|
|
17
|
+
module Resource
|
|
18
|
+
class UserInfoMappingRules < Stormpath::Resource::Instance
|
|
19
|
+
prop_accessor :items
|
|
20
|
+
prop_reader :href, :created_at, :modified_at
|
|
21
|
+
end
|
|
22
|
+
end
|
|
19
23
|
end
|
|
@@ -21,16 +21,15 @@ module Stormpath
|
|
|
21
21
|
|
|
22
22
|
def inspect
|
|
23
23
|
''.tap do |str|
|
|
24
|
-
str << %
|
|
24
|
+
str << %(#<#{class_name_with_id} @properties={)
|
|
25
25
|
@read_lock.lock
|
|
26
26
|
begin
|
|
27
27
|
str << properties.map do |key, value|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
%Q["#{key} => #{value}"]
|
|
28
|
+
next unless printable_property? key
|
|
29
|
+
if value.is_a?(Hash) && value.key?(Stormpath::Resource::Base::HREF_PROP_NAME)
|
|
30
|
+
value = %({ "#{Stormpath::Resource::Base::HREF_PROP_NAME}" => "#{value[Stormpath::Resource::Base::HREF_PROP_NAME]}" })
|
|
33
31
|
end
|
|
32
|
+
%("#{key} => #{value}")
|
|
34
33
|
end.compact.join(',')
|
|
35
34
|
ensure
|
|
36
35
|
@read_lock.unlock
|
|
@@ -49,9 +48,7 @@ module Stormpath
|
|
|
49
48
|
|
|
50
49
|
begin
|
|
51
50
|
properties_yaml = properties.each do |key, value|
|
|
52
|
-
if printable_property? key
|
|
53
|
-
" #{key}: #{value} \n"
|
|
54
|
-
end
|
|
51
|
+
" #{key}: #{value} \n" if printable_property? key
|
|
55
52
|
end.compact.join("\n")
|
|
56
53
|
unless properties_yaml.empty?
|
|
57
54
|
yaml << " properties\n "
|
|
@@ -64,7 +61,7 @@ module Stormpath
|
|
|
64
61
|
end
|
|
65
62
|
|
|
66
63
|
def class_name_with_id
|
|
67
|
-
object_id_hex = '%x' % (
|
|
64
|
+
object_id_hex = '%x' % (object_id << 1)
|
|
68
65
|
"#{self.class.name}:0x#{object_id_hex}"
|
|
69
66
|
end
|
|
70
67
|
end
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
module Stormpath
|
|
2
|
+
module Resource
|
|
3
|
+
class VerificationEmail < Stormpath::Resource::Instance
|
|
4
|
+
prop_accessor :login, :account_store
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
belongs_to :application
|
|
7
|
+
end
|
|
8
|
+
end
|
|
5
9
|
end
|
|
@@ -16,13 +16,12 @@
|
|
|
16
16
|
module Stormpath
|
|
17
17
|
module Util
|
|
18
18
|
module Assert
|
|
19
|
-
|
|
20
19
|
def assert_not_nil(object, message)
|
|
21
20
|
raise(ArgumentError, message, caller) if object.nil?
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
def assert_kind_of(clazz, object, message)
|
|
25
|
-
raise(ArgumentError, message, caller) unless object.
|
|
24
|
+
raise(ArgumentError, message, caller) unless object.is_a?(clazz)
|
|
26
25
|
end
|
|
27
26
|
|
|
28
27
|
def assert_true(arg, message)
|
|
@@ -32,7 +31,6 @@ module Stormpath
|
|
|
32
31
|
def assert_false(arg, message)
|
|
33
32
|
raise(ArgumentError, message, caller) if arg
|
|
34
33
|
end
|
|
35
|
-
|
|
36
34
|
end
|
|
37
35
|
end
|
|
38
36
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe 'BasicAuthenticator', vcr
|
|
3
|
+
describe 'BasicAuthenticator', :vcr do
|
|
4
4
|
let(:application) { test_api_client.applications.create(application_attrs) }
|
|
5
5
|
let(:directory) { test_api_client.directories.create(directory_attrs) }
|
|
6
6
|
let(:directory2) { test_api_client.directories.create(directory_attrs) }
|
|
@@ -10,16 +10,14 @@ describe 'BasicAuthenticator', vcr: true do
|
|
|
10
10
|
end
|
|
11
11
|
let(:password) { 'F00barfoo' }
|
|
12
12
|
let(:invalid_password) { 'Wr00ngPassw0rd' }
|
|
13
|
-
let(:dir_account)
|
|
14
|
-
|
|
15
|
-
end
|
|
16
|
-
let(:org_account) do
|
|
17
|
-
organization.accounts.create(account_attrs(username: 'ruby_cilim_org', password: password))
|
|
18
|
-
end
|
|
13
|
+
let(:dir_account) { directory.accounts.create(account_attrs(password: password)) }
|
|
14
|
+
let(:org_account) { organization.accounts.create(account_attrs(password: password)) }
|
|
19
15
|
let(:request) do
|
|
20
|
-
Stormpath::Authentication::UsernamePasswordRequest.new(
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
Stormpath::Authentication::UsernamePasswordRequest.new(
|
|
17
|
+
account.username,
|
|
18
|
+
password,
|
|
19
|
+
account_store: account_store
|
|
20
|
+
)
|
|
23
21
|
end
|
|
24
22
|
let(:authenticate) { authenticator.authenticate(application.href, request) }
|
|
25
23
|
|
|
@@ -61,8 +59,10 @@ describe 'BasicAuthenticator', vcr: true do
|
|
|
61
59
|
|
|
62
60
|
context 'wrong password' do
|
|
63
61
|
let(:request) do
|
|
64
|
-
Stormpath::Authentication::UsernamePasswordRequest.new(
|
|
65
|
-
|
|
62
|
+
Stormpath::Authentication::UsernamePasswordRequest.new(
|
|
63
|
+
org_account.username,
|
|
64
|
+
invalid_password
|
|
65
|
+
)
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
it_behaves_like 'an invalid username or password error'
|
|
@@ -75,9 +75,11 @@ describe 'BasicAuthenticator', vcr: true do
|
|
|
75
75
|
|
|
76
76
|
context 'successful authentication' do
|
|
77
77
|
let(:request) do
|
|
78
|
-
Stormpath::Authentication::UsernamePasswordRequest.new(
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
Stormpath::Authentication::UsernamePasswordRequest.new(
|
|
79
|
+
org_account.username,
|
|
80
|
+
password,
|
|
81
|
+
account_store: organization
|
|
82
|
+
)
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
it_should_behave_like 'an AuthenticationResult'
|
|
@@ -85,9 +87,11 @@ describe 'BasicAuthenticator', vcr: true do
|
|
|
85
87
|
|
|
86
88
|
context 'wrong password' do
|
|
87
89
|
let(:request) do
|
|
88
|
-
Stormpath::Authentication::UsernamePasswordRequest.new(
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
Stormpath::Authentication::UsernamePasswordRequest.new(
|
|
91
|
+
org_account.username,
|
|
92
|
+
invalid_password,
|
|
93
|
+
account_store: organization
|
|
94
|
+
)
|
|
91
95
|
end
|
|
92
96
|
|
|
93
97
|
it_behaves_like 'an invalid username or password error'
|
|
@@ -97,13 +101,13 @@ describe 'BasicAuthenticator', vcr: true do
|
|
|
97
101
|
before { map_account_store(application, directory2, 1, false, false) }
|
|
98
102
|
after { directory2.delete }
|
|
99
103
|
|
|
100
|
-
let(:another_account)
|
|
101
|
-
directory2.accounts.create(account_attrs(username: 'ruby-dir-acc', password: password))
|
|
102
|
-
end
|
|
104
|
+
let(:another_account) { directory2.accounts.create(account_attrs(password: password)) }
|
|
103
105
|
let(:request) do
|
|
104
|
-
Stormpath::Authentication::UsernamePasswordRequest.new(
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
Stormpath::Authentication::UsernamePasswordRequest.new(
|
|
107
|
+
another_account.username,
|
|
108
|
+
password,
|
|
109
|
+
account_store: organization
|
|
110
|
+
)
|
|
107
111
|
end
|
|
108
112
|
|
|
109
113
|
it_behaves_like 'an invalid username or password error'
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'RegisterServiceProvider', vcr: true do
|
|
4
|
+
let(:client) { test_api_client }
|
|
5
|
+
let(:application) { test_api_client.applications.create(application_attrs) }
|
|
6
|
+
let(:identity_provider) { application.saml_policy.identity_provider }
|
|
7
|
+
let(:assertion_consumer_service_url) { "http://example#{random_number}.zendesk.com/access/saml" }
|
|
8
|
+
let(:entity_id) { "unique-name-#{random_number}" }
|
|
9
|
+
let(:registered_service_provider) do
|
|
10
|
+
Stormpath::Authentication::RegisterServiceProvider.new(identity_provider, options).call
|
|
11
|
+
end
|
|
12
|
+
let(:options) do
|
|
13
|
+
{
|
|
14
|
+
assertion_consumer_service_url: assertion_consumer_service_url,
|
|
15
|
+
entity_id: entity_id
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
after { application.delete }
|
|
20
|
+
|
|
21
|
+
describe 'successfull service provider registration' do
|
|
22
|
+
after { registered_service_provider.delete }
|
|
23
|
+
|
|
24
|
+
context 'without optional parameters' do
|
|
25
|
+
it 'should successfully create a registered_service_provider' do
|
|
26
|
+
expect(registered_service_provider).to(
|
|
27
|
+
be_a(Stormpath::Resource::RegisteredSamlServiceProvider)
|
|
28
|
+
)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'should successfully map the registered_service_provider to the identity_provider' do
|
|
32
|
+
expect(identity_provider.registered_saml_service_providers).to(
|
|
33
|
+
include(registered_service_provider)
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context 'with optional parameters' do
|
|
39
|
+
before do
|
|
40
|
+
options[:name] = "service-provider-name-#{random_number}"
|
|
41
|
+
options[:description] = 'stormpath example'
|
|
42
|
+
options[:name_id_format] = 'PERSISTENT'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'should successfully create a registered_service_provider' do
|
|
46
|
+
expect(registered_service_provider).to(
|
|
47
|
+
be_a(Stormpath::Resource::RegisteredSamlServiceProvider)
|
|
48
|
+
)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'should successfully map the registered_service_provider to the identity_provider' do
|
|
52
|
+
expect(identity_provider.registered_saml_service_providers).to(
|
|
53
|
+
include(registered_service_provider)
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe 'unsuccessfull service provider registration' do
|
|
60
|
+
before do
|
|
61
|
+
options.delete(:assertion_consumer_service_url)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'should raise Stormpath::Error' do
|
|
65
|
+
expect { registered_service_provider }.to raise_error(Stormpath::Error)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -3,10 +3,10 @@ require 'timecop'
|
|
|
3
3
|
|
|
4
4
|
describe Stormpath::Http::Authc::Sauthc1Signer do
|
|
5
5
|
let(:fake_uuid_generator) do
|
|
6
|
-
|
|
6
|
+
proc { 'fake-uuid' }
|
|
7
7
|
end
|
|
8
8
|
let(:signer) do
|
|
9
|
-
Stormpath::Http::Authc::Sauthc1Signer.new
|
|
9
|
+
Stormpath::Http::Authc::Sauthc1Signer.new(fake_uuid_generator)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
after do
|
|
@@ -19,11 +19,15 @@ describe Stormpath::Http::Authc::Sauthc1Signer do
|
|
|
19
19
|
let(:fake_api_key) { Stormpath::ApiKey.new('foo', 'bar') }
|
|
20
20
|
|
|
21
21
|
let(:empty_query_hash_request) do
|
|
22
|
-
Stormpath::Http::Request.new
|
|
22
|
+
Stormpath::Http::Request.new(
|
|
23
|
+
'get', 'http://example.com/resources/abc123?q=red blue', nil, {}, nil, test_api_key
|
|
24
|
+
)
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
let(:filled_query_hash_request) do
|
|
26
|
-
Stormpath::Http::Request.new
|
|
28
|
+
Stormpath::Http::Request.new(
|
|
29
|
+
'get', 'http://example.com/resources/abc123', { 'q' => 'red blue' }, {}, nil, test_api_key
|
|
30
|
+
)
|
|
27
31
|
end
|
|
28
32
|
|
|
29
33
|
before do
|
|
@@ -8,7 +8,7 @@ describe Stormpath::Cache::CacheEntry do
|
|
|
8
8
|
|
|
9
9
|
context 'by default' do
|
|
10
10
|
let(:cache_entry) do
|
|
11
|
-
Stormpath::Cache::CacheEntry.new
|
|
11
|
+
Stormpath::Cache::CacheEntry.new('foo')
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
let(:now) { Time.now }
|
|
@@ -19,19 +19,19 @@ describe Stormpath::Cache::CacheEntry do
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it 'initializes the creation time to now' do
|
|
22
|
-
#commenting because it passes locally but not on travis :/
|
|
23
|
-
#expect(cache_entry.created_at).to eq now
|
|
22
|
+
# commenting because it passes locally but not on travis :/
|
|
23
|
+
# expect(cache_entry.created_at).to eq now
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it 'initializes the last accessed time to now' do
|
|
27
|
-
#commenting because it passes locally but not on travis :/
|
|
28
|
-
#expect(cache_entry.last_accessed_at).to eq now
|
|
27
|
+
# commenting because it passes locally but not on travis :/
|
|
28
|
+
# expect(cache_entry.last_accessed_at).to eq now
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
describe '#touch' do
|
|
33
33
|
let(:cache_entry) do
|
|
34
|
-
Stormpath::Cache::CacheEntry.new
|
|
34
|
+
Stormpath::Cache::CacheEntry.new('foo')
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
let(:now) { Time.now }
|
|
@@ -42,8 +42,8 @@ describe Stormpath::Cache::CacheEntry do
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it 'updates the last accessed at time' do
|
|
45
|
-
#commenting because it passes locally but not on travis :/
|
|
46
|
-
#expect(cache_entry.last_accessed_at).to eq now
|
|
45
|
+
# commenting because it passes locally but not on travis :/
|
|
46
|
+
# expect(cache_entry.last_accessed_at).to eq now
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
@@ -55,7 +55,7 @@ describe Stormpath::Cache::CacheEntry do
|
|
|
55
55
|
|
|
56
56
|
context 'has not expired' do
|
|
57
57
|
let(:cache_entry) do
|
|
58
|
-
Stormpath::Cache::CacheEntry.new
|
|
58
|
+
Stormpath::Cache::CacheEntry.new('foo')
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
let(:expired) do
|
|
@@ -69,7 +69,7 @@ describe Stormpath::Cache::CacheEntry do
|
|
|
69
69
|
|
|
70
70
|
context 'when TTL has expired' do
|
|
71
71
|
before do
|
|
72
|
-
cache_entry = Stormpath::Cache::CacheEntry.new
|
|
72
|
+
cache_entry = Stormpath::Cache::CacheEntry.new('foo')
|
|
73
73
|
Timecop.freeze now + ttl_seconds + 1
|
|
74
74
|
|
|
75
75
|
@expired = cache_entry.expired? ttl_seconds, tti_seconds
|
|
@@ -82,7 +82,7 @@ describe Stormpath::Cache::CacheEntry do
|
|
|
82
82
|
|
|
83
83
|
context 'when TTI has expired' do
|
|
84
84
|
before do
|
|
85
|
-
cache_entry = Stormpath::Cache::CacheEntry.new
|
|
85
|
+
cache_entry = Stormpath::Cache::CacheEntry.new('foo')
|
|
86
86
|
Timecop.freeze now + tti_seconds + 1
|
|
87
87
|
|
|
88
88
|
@expired = cache_entry.expired? ttl_seconds, tti_seconds
|
|
@@ -96,40 +96,39 @@ describe Stormpath::Cache::CacheEntry do
|
|
|
96
96
|
|
|
97
97
|
describe '#to_h' do
|
|
98
98
|
let(:cache_entry) do
|
|
99
|
-
Stormpath::Cache::CacheEntry.new
|
|
99
|
+
Stormpath::Cache::CacheEntry.new('foo')
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
let(:now) { Time.now }
|
|
103
103
|
before { Timecop.freeze now }
|
|
104
104
|
|
|
105
105
|
it 'returns a hash of the attributes' do
|
|
106
|
-
expect(cache_entry.to_h).to eq(
|
|
106
|
+
expect(cache_entry.to_h).to eq(
|
|
107
107
|
'value' => cache_entry.value,
|
|
108
108
|
'created_at' => cache_entry.created_at,
|
|
109
109
|
'last_accessed_at' => cache_entry.last_accessed_at
|
|
110
|
-
|
|
110
|
+
)
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
describe '.from_h=' do
|
|
115
115
|
let(:hash) do
|
|
116
116
|
{
|
|
117
|
-
|
|
117
|
+
'value' =>
|
|
118
118
|
{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
'href' => 'https://api.stormpath.com/v1/applications/app1',
|
|
120
|
+
'name' => 'application app1',
|
|
121
|
+
'tenant' => {
|
|
122
|
+
'href' => 'https://api.stormpath.com/v1/tenants/ten2'
|
|
123
123
|
},
|
|
124
|
-
|
|
125
|
-
{
|
|
126
|
-
|
|
127
|
-
[{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
"last_accessed_at" => "2013-06-05T10:01:31-07:00"
|
|
124
|
+
'groups' =>
|
|
125
|
+
{ 'href' => 'https://api.stormpath.com/v1/applications/app3/groups',
|
|
126
|
+
'items' =>
|
|
127
|
+
[{ 'href' => 'https://api.stormpath.com/v1/groups/gro4' },
|
|
128
|
+
{ 'href' => 'https://api.stormpath.com/v1/groups/gro5' }] }
|
|
129
|
+
},
|
|
130
|
+
'created_at' => '2013-06-05T10:01:31-07:00',
|
|
131
|
+
'last_accessed_at' => '2013-06-05T10:01:31-07:00'
|
|
133
132
|
}
|
|
134
133
|
end
|
|
135
134
|
|
|
@@ -157,4 +156,4 @@ describe Stormpath::Cache::CacheEntry do
|
|
|
157
156
|
expect(cache_entry.last_accessed_at).to eq last_accessed_at
|
|
158
157
|
end
|
|
159
158
|
end
|
|
160
|
-
end
|
|
159
|
+
end
|