auth0 5.0.1 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +3 -5
- data/CHANGELOG.md +13 -0
- data/README.md +80 -1
- data/lib/auth0/api/authentication_endpoints.rb +16 -6
- data/lib/auth0/api/v2.rb +8 -4
- data/lib/auth0/api/v2/branding.rb +66 -0
- data/lib/auth0/api/v2/connections.rb +3 -0
- data/lib/auth0/api/v2/jobs.rb +3 -1
- data/lib/auth0/api/v2/organizations.rb +332 -0
- data/lib/auth0/api/v2/tickets.rb +14 -2
- data/lib/auth0/api/v2/users.rb +12 -0
- data/lib/auth0/exception.rb +2 -0
- data/lib/auth0/mixins/initializer.rb +3 -1
- data/lib/auth0/mixins/validation.rb +14 -0
- data/lib/auth0/version.rb +1 -1
- data/spec/lib/auth0/api/v2/branding_spec.rb +70 -0
- data/spec/lib/auth0/api/v2/connections_spec.rb +4 -0
- data/spec/lib/auth0/api/v2/jobs_spec.rb +11 -0
- data/spec/lib/auth0/api/v2/organizations_spec.rb +588 -0
- data/spec/lib/auth0/api/v2/tickets_spec.rb +55 -0
- data/spec/lib/auth0/api/v2/users_spec.rb +19 -0
- data/spec/lib/auth0/client_spec.rb +79 -9
- data/spec/lib/auth0/mixins/validation_spec.rb +32 -0
- metadata +9 -3
data/lib/auth0/api/v2/tickets.rb
CHANGED
@@ -15,9 +15,11 @@ module Auth0
|
|
15
15
|
# @param identity [hash] Used to verify secondary, federated, and passwordless-email identities.
|
16
16
|
# * :user_id [string] user_id of the identity.
|
17
17
|
# * :provider [string] provider of the identity.
|
18
|
+
# @param client_id [string] client id
|
19
|
+
# @param organization_id [string] organization id
|
18
20
|
#
|
19
21
|
# @return [json] Returns the created ticket url.
|
20
|
-
def post_email_verification(user_id, result_url: nil, ttl_sec: nil, identity: nil)
|
22
|
+
def post_email_verification(user_id, result_url: nil, ttl_sec: nil, identity: nil, client_id: nil, organization_id: nil)
|
21
23
|
if user_id.to_s.empty?
|
22
24
|
raise Auth0::InvalidParameter, 'Must supply a valid user id to post an email verification'
|
23
25
|
end
|
@@ -27,6 +29,8 @@ module Auth0
|
|
27
29
|
result_url: result_url,
|
28
30
|
ttl_sec: ttl_sec.is_a?(Integer) ? ttl_sec : nil
|
29
31
|
}
|
32
|
+
request_params[:client_id] = client_id unless client_id.nil?
|
33
|
+
request_params[:organization_id] = organization_id unless organization_id.nil?
|
30
34
|
|
31
35
|
if identity
|
32
36
|
unless identity.is_a? Hash
|
@@ -53,6 +57,8 @@ module Auth0
|
|
53
57
|
# @param includeEmailInRedirect [boolean] Whether or not we include the email as part of the returnUrl
|
54
58
|
# in the reset_email
|
55
59
|
# @param new_password [string] The password to be set for the user once the ticket is used.
|
60
|
+
# @param client_id [string] client id
|
61
|
+
# @param organization_id [string] organization id
|
56
62
|
#
|
57
63
|
# @return [json] Returns the created ticket url.
|
58
64
|
def post_password_change(
|
@@ -63,7 +69,10 @@ module Auth0
|
|
63
69
|
ttl_sec: nil,
|
64
70
|
mark_email_as_verified: nil,
|
65
71
|
includeEmailInRedirect: nil,
|
66
|
-
new_password: nil
|
72
|
+
new_password: nil,
|
73
|
+
client_id: nil,
|
74
|
+
organization_id: nil
|
75
|
+
)
|
67
76
|
|
68
77
|
booleans = [true, false]
|
69
78
|
path = "#{tickets_path}/password-change"
|
@@ -77,6 +86,9 @@ module Auth0
|
|
77
86
|
includeEmailInRedirect: booleans.include?(includeEmailInRedirect) ? includeEmailInRedirect : nil,
|
78
87
|
new_password: new_password
|
79
88
|
}
|
89
|
+
request_params[:client_id] = client_id unless client_id.nil?
|
90
|
+
request_params[:organization_id] = organization_id unless organization_id.nil?
|
91
|
+
|
80
92
|
post(path, request_params)
|
81
93
|
end
|
82
94
|
|
data/lib/auth0/api/v2/users.rb
CHANGED
@@ -308,6 +308,18 @@ module Auth0
|
|
308
308
|
post "#{users_path}/#{user_id}/multifactor/actions/invalidate-remember-browser"
|
309
309
|
end
|
310
310
|
|
311
|
+
|
312
|
+
# Get a list of organizations for a user.
|
313
|
+
#
|
314
|
+
# @param user_id [string] The user_id of the permissions to get.
|
315
|
+
#
|
316
|
+
# @return [json] Returns organizations for the given user_id.
|
317
|
+
def get_user_organizations(user_id)
|
318
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
319
|
+
|
320
|
+
get "#{users_path}/#{user_id}/organizations"
|
321
|
+
end
|
322
|
+
|
311
323
|
private
|
312
324
|
|
313
325
|
# Users API path
|
data/lib/auth0/exception.rb
CHANGED
@@ -38,6 +38,8 @@ module Auth0
|
|
38
38
|
class MissingUserId < Auth0::Exception; end
|
39
39
|
# exception for unset client_id
|
40
40
|
class MissingClientId < Auth0::Exception; end
|
41
|
+
# exception for unset organization_id
|
42
|
+
class MissingOrganizationId < Auth0::Exception; end
|
41
43
|
# exception for an unset parameter
|
42
44
|
class MissingParameter < Auth0::Exception; end
|
43
45
|
# Api v2 access denied
|
@@ -18,6 +18,7 @@ module Auth0
|
|
18
18
|
extend Auth0::Api::AuthenticationEndpoints
|
19
19
|
@client_id = options[:client_id]
|
20
20
|
@client_secret = options[:client_secret]
|
21
|
+
@organization = options[:organization]
|
21
22
|
initialize_api(options)
|
22
23
|
end
|
23
24
|
|
@@ -58,7 +59,8 @@ module Auth0
|
|
58
59
|
def initialize_v2(options)
|
59
60
|
extend Auth0::Api::V2
|
60
61
|
@token = options[:access_token] || options[:token]
|
61
|
-
|
62
|
+
api_identifier = options[:api_identifier] || "https://#{@domain}/api/v2/"
|
63
|
+
@token = api_token(audience: api_identifier).token if @token.nil? && @client_id && @client_secret
|
62
64
|
end
|
63
65
|
|
64
66
|
def api_v2?(options)
|
@@ -100,11 +100,13 @@ module Auth0
|
|
100
100
|
issuer = @context[:issuer]
|
101
101
|
audience = @context[:audience]
|
102
102
|
max_age = @context[:max_age]
|
103
|
+
org = @context[:organization]
|
103
104
|
|
104
105
|
raise Auth0::InvalidParameter, 'Must supply a valid leeway' unless leeway.is_a?(Integer) && leeway >= 0
|
105
106
|
raise Auth0::InvalidParameter, 'Must supply a valid nonce' unless nonce.nil? || !nonce.to_s.empty?
|
106
107
|
raise Auth0::InvalidParameter, 'Must supply a valid issuer' unless issuer.nil? || !issuer.to_s.empty?
|
107
108
|
raise Auth0::InvalidParameter, 'Must supply a valid audience' unless audience.nil? || !audience.to_s.empty?
|
109
|
+
raise Auth0::InvalidParameter, 'Must supply a valid organization' unless org.nil? || !org.to_s.empty?
|
108
110
|
|
109
111
|
unless max_age.nil? || (max_age.is_a?(Integer) && max_age >= 0)
|
110
112
|
raise Auth0::InvalidParameter, 'Must supply a valid max_age'
|
@@ -118,6 +120,7 @@ module Auth0
|
|
118
120
|
validate_nonce(claims, nonce) if nonce
|
119
121
|
validate_azp(claims, audience) if claims['aud'].is_a?(Array) && claims['aud'].count > 1
|
120
122
|
validate_auth_time(claims, max_age, leeway) if max_age
|
123
|
+
validate_org(claims, org) if org
|
121
124
|
end
|
122
125
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
123
126
|
|
@@ -184,6 +187,17 @@ module Auth0
|
|
184
187
|
end
|
185
188
|
end
|
186
189
|
|
190
|
+
def validate_org(claims, expected)
|
191
|
+
unless claims.key?('org_id') && claims['org_id'].is_a?(String)
|
192
|
+
raise Auth0::InvalidIdToken, 'Organization Id (org_id) claim must be a string present in the ID token'
|
193
|
+
end
|
194
|
+
|
195
|
+
unless expected == claims['org_id']
|
196
|
+
raise Auth0::InvalidIdToken, "Organization Id (org_id) claim value mismatch in the ID token; expected \"#{expected}\","\
|
197
|
+
" found \"#{claims['org_id']}\""
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
187
201
|
def validate_azp(claims, expected)
|
188
202
|
unless claims.key?('azp') && claims['azp'].is_a?(String)
|
189
203
|
raise Auth0::InvalidIdToken, 'Authorized Party (azp) claim must be a string present in the ID token'
|
data/lib/auth0/version.rb
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Auth0::Api::V2::Branding do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::Branding)
|
6
|
+
dummy_instance.extend(Auth0::Mixins::Initializer)
|
7
|
+
@instance = dummy_instance
|
8
|
+
end
|
9
|
+
|
10
|
+
context '.branding' do
|
11
|
+
it { expect(@instance).to respond_to(:branding) }
|
12
|
+
|
13
|
+
it 'is expected to call get /api/v2/branding' do
|
14
|
+
expect(@instance).to receive(:get).with('/api/v2/branding')
|
15
|
+
expect { @instance.branding }.not_to raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'is expected to respond to a get_branding method' do
|
19
|
+
expect(@instance).to respond_to(:get_branding)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context '.patch_branding' do
|
24
|
+
it { expect(@instance).to respond_to(:patch_branding) }
|
25
|
+
it 'is expected to call post /api/v2/branding' do
|
26
|
+
expect(@instance).to receive(:patch).with(
|
27
|
+
'/api/v2/branding',
|
28
|
+
template: 'Test'
|
29
|
+
)
|
30
|
+
expect { @instance.patch_branding({ template: 'Test' }) }.not_to raise_error
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'is expected to respond to a get_branding method' do
|
34
|
+
expect(@instance).to respond_to(:update_branding)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context '.branding_templates_for_universal_login' do
|
39
|
+
it { expect(@instance).to respond_to(:branding) }
|
40
|
+
|
41
|
+
it 'is expected to call get /api/v2/branding/templates/universal-login' do
|
42
|
+
expect(@instance).to receive(:get).with('/api/v2/branding/templates/universal-login')
|
43
|
+
expect { @instance.branding_templates_for_universal_login }.not_to raise_error
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'is expected to respond to a get_branding_templates_for_universal_login method' do
|
47
|
+
expect(@instance).to respond_to(:get_branding_templates_for_universal_login)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context '.put_branding_templates_for_universal_login' do
|
52
|
+
it { expect(@instance).to respond_to(:put_branding_templates_for_universal_login) }
|
53
|
+
it 'is expected to call put /api/v2/branding/templates/universal-login' do
|
54
|
+
expect(@instance).to receive(:put).with(
|
55
|
+
'/api/v2/branding/templates/universal-login', template: 'Template'
|
56
|
+
)
|
57
|
+
expect do
|
58
|
+
@instance.put_branding_templates_for_universal_login(template: 'Template')
|
59
|
+
end.not_to raise_error
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context '.delete_branding_templates_for_universal_login' do
|
64
|
+
it { expect(@instance).to respond_to(:delete_branding_templates_for_universal_login) }
|
65
|
+
it 'is expected to call delete /api/v2/branding/templates/universal-login' do
|
66
|
+
expect(@instance).to receive(:delete).with('/api/v2/branding/templates/universal-login')
|
67
|
+
expect { @instance.delete_branding_templates_for_universal_login() }.not_to raise_error
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -14,6 +14,7 @@ describe Auth0::Api::V2::Connections do
|
|
14
14
|
expect(@instance).to receive(:get).with(
|
15
15
|
'/api/v2/connections',
|
16
16
|
strategy: nil,
|
17
|
+
name: nil,
|
17
18
|
fields: nil,
|
18
19
|
include_fields: nil,
|
19
20
|
page: nil,
|
@@ -28,6 +29,7 @@ describe Auth0::Api::V2::Connections do
|
|
28
29
|
include_fields: true,
|
29
30
|
fields: 'name',
|
30
31
|
strategy: nil,
|
32
|
+
name: nil,
|
31
33
|
page: nil,
|
32
34
|
per_page: nil
|
33
35
|
)
|
@@ -42,6 +44,7 @@ describe Auth0::Api::V2::Connections do
|
|
42
44
|
include_fields: true,
|
43
45
|
fields: 'name,strategy',
|
44
46
|
strategy: nil,
|
47
|
+
name: nil,
|
45
48
|
page: nil,
|
46
49
|
per_page: nil
|
47
50
|
)
|
@@ -56,6 +59,7 @@ describe Auth0::Api::V2::Connections do
|
|
56
59
|
page: 1,
|
57
60
|
per_page: 10,
|
58
61
|
strategy: nil,
|
62
|
+
name: nil,
|
59
63
|
fields: nil,
|
60
64
|
include_fields: nil
|
61
65
|
)
|
@@ -119,6 +119,17 @@ describe Auth0::Api::V2::Jobs do
|
|
119
119
|
)
|
120
120
|
end
|
121
121
|
|
122
|
+
it 'expect client to accept organization_id' do
|
123
|
+
expect(@instance).to receive(:post).with('/api/v2/jobs/verification-email',
|
124
|
+
user_id: 'user_id',
|
125
|
+
organization_id: 'org_id'
|
126
|
+
)
|
127
|
+
|
128
|
+
expect {
|
129
|
+
@instance.send_verification_email('user_id', organization_id: 'org_id')
|
130
|
+
}.not_to raise_error
|
131
|
+
end
|
132
|
+
|
122
133
|
it 'should raise an error if the user_id is empty' do
|
123
134
|
expect do
|
124
135
|
@instance.send_verification_email('')
|
@@ -0,0 +1,588 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Auth0::Api::V2::Organizations do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::Organizations)
|
6
|
+
@instance = dummy_instance
|
7
|
+
end
|
8
|
+
|
9
|
+
context '.organizations' do
|
10
|
+
it 'is expected to respond to a organizations method' do
|
11
|
+
expect(@instance).to respond_to(:organizations)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'is expected to respond to a get_organizations method' do
|
15
|
+
expect(@instance).to respond_to(:get_organizations)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'is expected to get /api/v2/organizations' do
|
19
|
+
expect(@instance).to receive(:get).with(
|
20
|
+
'/api/v2/organizations',
|
21
|
+
per_page: nil,
|
22
|
+
page: nil,
|
23
|
+
include_totals: nil
|
24
|
+
)
|
25
|
+
expect { @instance.organizations }.not_to raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'is expected to get /api/v2/organizations with custom parameters' do
|
29
|
+
expect(@instance).to receive(:get).with(
|
30
|
+
'/api/v2/organizations',
|
31
|
+
per_page: 10,
|
32
|
+
page: 1,
|
33
|
+
include_totals: true
|
34
|
+
)
|
35
|
+
expect do
|
36
|
+
@instance.organizations(
|
37
|
+
per_page: 10,
|
38
|
+
page: 1,
|
39
|
+
include_totals: true
|
40
|
+
)
|
41
|
+
end.not_to raise_error
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context '.organization' do
|
46
|
+
it 'is expected to respond to a user method' do
|
47
|
+
expect(@instance).to respond_to(:organization)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'is expected to call get request to /api/v2/users/org_id' do
|
51
|
+
expect(@instance).to receive(:get).with(
|
52
|
+
'/api/v2/organizations/org_id'
|
53
|
+
)
|
54
|
+
expect { @instance.organization('org_id') }.not_to raise_error
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'is expected to raise an exception when the organization ID is empty' do
|
58
|
+
expect { @instance.organization(nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context '.create_organization' do
|
63
|
+
it 'is expected to respond to a create_organization method' do
|
64
|
+
expect(@instance).to respond_to(:create_organization)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'is expected to post to /api/v2/organizations' do
|
68
|
+
expect(@instance).to receive(:post).with(
|
69
|
+
'/api/v2/organizations',
|
70
|
+
name: 'test_org'
|
71
|
+
)
|
72
|
+
expect do
|
73
|
+
@instance.create_organization(
|
74
|
+
name: 'test_org'
|
75
|
+
)
|
76
|
+
end.not_to raise_error
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context '.delete_organization' do
|
81
|
+
it 'is expected to respond to a delete_organization method' do
|
82
|
+
expect(@instance).to respond_to :delete_organization
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'is expected to call delete to /api/v2/organizations/org_id' do
|
86
|
+
expect(@instance).to receive(:delete).with('/api/v2/organizations/org_id')
|
87
|
+
expect { @instance.delete_organization('org_id') }.not_to raise_error
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'is expected not to delete /api/v2/organizations if organization_id is blank' do
|
91
|
+
expect(@instance).not_to receive(:delete)
|
92
|
+
expect { @instance.delete_organization(nil) }.to raise_exception(
|
93
|
+
Auth0::MissingOrganizationId
|
94
|
+
)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context '.organization_by_name' do
|
99
|
+
it 'is expected to respond to a user method' do
|
100
|
+
expect(@instance).to respond_to(:organization_by_name)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'is expected to call get request to /api/v2/users/org_id' do
|
104
|
+
expect(@instance).to receive(:get).with(
|
105
|
+
'/api/v2/organizations/name/org_id'
|
106
|
+
)
|
107
|
+
expect { @instance.organization_by_name('org_id') }.not_to raise_error
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'is expected to raise an exception when the organization ID is empty' do
|
111
|
+
expect { @instance.organization_by_name(nil) }.to raise_exception(Auth0::InvalidParameter)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
context '.patch_organization' do
|
117
|
+
it 'is expected to respond to a patch_organization method' do
|
118
|
+
expect(@instance).to respond_to(:patch_organization)
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'is expected to respond to a update_organization method' do
|
122
|
+
expect(@instance).to respond_to(:update_organization)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'is expected to patch /api/v2/organizations/org_id' do
|
126
|
+
expect(@instance).to receive(:patch).with(
|
127
|
+
'/api/v2/organizations/org_id',
|
128
|
+
name: 'name'
|
129
|
+
)
|
130
|
+
@instance.patch_organization(
|
131
|
+
'org_id',
|
132
|
+
name: 'name'
|
133
|
+
)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'is expected to raise an exception when the organization id is empty' do
|
137
|
+
expect { @instance.patch_organization(nil, 'BODY') }.to raise_exception(Auth0::MissingOrganizationId)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'is expected to raise an error when the body is empty' do
|
141
|
+
expect { @instance.patch_organization('org_id', nil) }.to raise_error 'Must supply a valid body'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context '.get_organizations_enabled_connections' do
|
146
|
+
it 'is expected to respond to a get_organizations_enabled_connections method' do
|
147
|
+
expect(@instance).to respond_to(:get_organizations_enabled_connections)
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'is expected to raise an exception when the org ID is empty' do
|
151
|
+
expect { @instance.get_organizations_enabled_connections(nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'is expected to get enabled_connections for an org' do
|
155
|
+
expect(@instance).to receive(:get).with(
|
156
|
+
'/api/v2/organizations/org_id/enabled_connections'
|
157
|
+
)
|
158
|
+
expect { @instance.get_organizations_enabled_connections('org_id') }.not_to raise_error
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'is expected to get enabled_connections for an org' do
|
162
|
+
expect(@instance).to receive(:get).with(
|
163
|
+
'/api/v2/organizations/org_id/enabled_connections'
|
164
|
+
)
|
165
|
+
expect do
|
166
|
+
@instance.get_organizations_enabled_connections('org_id')
|
167
|
+
end.not_to raise_error
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context '.get_organizations_enabled_connection' do
|
172
|
+
it 'is expected to respond to a get_organizations_enabled_connection method' do
|
173
|
+
expect(@instance).to respond_to(:get_organizations_enabled_connection)
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'is expected to raise an exception when the org ID is empty' do
|
177
|
+
expect { @instance.get_organizations_enabled_connection(nil, nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'is expected to raise an exception when the org ID is empty' do
|
181
|
+
expect { @instance.get_organizations_enabled_connection('org_id', nil) }.to raise_exception(Auth0::InvalidParameter)
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'is expected to get enabled connection for an org' do
|
185
|
+
expect(@instance).to receive(:get).with(
|
186
|
+
'/api/v2/organizations/org_id/enabled_connections/connection_id'
|
187
|
+
)
|
188
|
+
expect { @instance.get_organizations_enabled_connection('org_id', 'connection_id') }.not_to raise_error
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'is expected to get enabled connection for an org' do
|
192
|
+
expect(@instance).to receive(:get).with(
|
193
|
+
'/api/v2/organizations/org_id/enabled_connections/connection_id'
|
194
|
+
)
|
195
|
+
expect do
|
196
|
+
@instance.get_organizations_enabled_connection('org_id', 'connection_id')
|
197
|
+
end.not_to raise_error
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
context '.patch_organizations_enabled_connection' do
|
202
|
+
it 'is expected to respond to a patch_organizations_enabled_connection method' do
|
203
|
+
expect(@instance).to respond_to(:patch_organizations_enabled_connection)
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'is expected to respond to a update_organizations_enabled_connection method' do
|
207
|
+
expect(@instance).to respond_to(:update_organizations_enabled_connection)
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'is expected to patch /api/v2/organizations/org_id/enabled_connections/connection_id' do
|
211
|
+
expect(@instance).to receive(:patch).with(
|
212
|
+
'/api/v2/organizations/org_id/enabled_connections/connection_id',
|
213
|
+
{
|
214
|
+
assign_membership_on_login: false
|
215
|
+
}
|
216
|
+
)
|
217
|
+
@instance.patch_organizations_enabled_connection(
|
218
|
+
'org_id',
|
219
|
+
'connection_id',
|
220
|
+
assign_membership_on_login: false
|
221
|
+
)
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'is expected to raise an exception when the organization id is empty' do
|
225
|
+
expect { @instance.patch_organizations_enabled_connection(nil, 'BODY') }.to raise_exception(Auth0::MissingOrganizationId)
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'is expected to raise an error when the connection_id is empty' do
|
229
|
+
expect { @instance.patch_organizations_enabled_connection('org_id', nil) }.to raise_error 'Must supply a valid connection id'
|
230
|
+
end
|
231
|
+
|
232
|
+
it 'is expected to raise an error when assign_membership_on_login is nil' do
|
233
|
+
expect { @instance.patch_organizations_enabled_connection('org_id', 'connection_id') }.to raise_error 'Must supply a valid assign_membership_on_login value'
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
context '.create_organizations_enabled_connection' do
|
238
|
+
it 'is expected to respond to a create_organizations_enabled_connection method' do
|
239
|
+
expect(@instance).to respond_to(:create_organizations_enabled_connection)
|
240
|
+
end
|
241
|
+
|
242
|
+
it 'is expected to respond to a add_organizations_enabled_connection method' do
|
243
|
+
expect(@instance).to respond_to(:add_organizations_enabled_connection)
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'is expected to post /api/v2/organizations/org_id/enabled_connections' do
|
247
|
+
expect(@instance).to receive(:post).with(
|
248
|
+
'/api/v2/organizations/org_id/enabled_connections',
|
249
|
+
{
|
250
|
+
assign_membership_on_login: true
|
251
|
+
}
|
252
|
+
)
|
253
|
+
@instance.create_organizations_enabled_connection('org_id', assign_membership_on_login: true)
|
254
|
+
end
|
255
|
+
|
256
|
+
it 'is expected to raise an exception when the organization id is empty' do
|
257
|
+
expect { @instance.create_organizations_enabled_connection(nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
context '.delete_organizations_enabled_connection' do
|
262
|
+
it 'is expected to respond to a delete_organizations_enabled_connection method' do
|
263
|
+
expect(@instance).to respond_to(:delete_organizations_enabled_connection)
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'is expected to respond to a remove_organizations_enabled_connection method' do
|
267
|
+
expect(@instance).to respond_to(:remove_organizations_enabled_connection)
|
268
|
+
end
|
269
|
+
|
270
|
+
it 'is expected to delete /api/v2/organizations/org_id/enabled_connections/connection_id' do
|
271
|
+
expect(@instance).to receive(:delete).with(
|
272
|
+
'/api/v2/organizations/org_id/enabled_connections/connection_id'
|
273
|
+
)
|
274
|
+
@instance.delete_organizations_enabled_connection('org_id', 'connection_id')
|
275
|
+
end
|
276
|
+
|
277
|
+
it 'is expected to raise an exception when the organization id is empty' do
|
278
|
+
expect { @instance.delete_organizations_enabled_connection(nil, nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
279
|
+
end
|
280
|
+
|
281
|
+
it 'is expected to raise an exception when the connection id is empty' do
|
282
|
+
expect { @instance.delete_organizations_enabled_connection('org_id', nil) }.to raise_error 'Must supply a valid connection id'
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
context '.get_organizations_invites' do
|
287
|
+
it 'is expected to respond to a get_organizations_invites method' do
|
288
|
+
expect(@instance).to respond_to(:get_organizations_invites)
|
289
|
+
end
|
290
|
+
|
291
|
+
it 'is expected to raise an exception when the org ID is empty' do
|
292
|
+
expect { @instance.get_organizations_invites(nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'is expected to get invitations for an org' do
|
296
|
+
expect(@instance).to receive(:get).with(
|
297
|
+
'/api/v2/organizations/org_id/invitations'
|
298
|
+
)
|
299
|
+
expect { @instance.get_organizations_invites('org_id') }.not_to raise_error
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'is expected to get invitations for an org' do
|
303
|
+
expect(@instance).to receive(:get).with(
|
304
|
+
'/api/v2/organizations/org_id/invitations'
|
305
|
+
)
|
306
|
+
expect do
|
307
|
+
@instance.get_organizations_invites('org_id')
|
308
|
+
end.not_to raise_error
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
context '.get_organizations_invite' do
|
313
|
+
it 'is expected to respond to a get_organizations_invite method' do
|
314
|
+
expect(@instance).to respond_to(:get_organizations_invite)
|
315
|
+
end
|
316
|
+
|
317
|
+
it 'is expected to raise an exception when the org ID is empty' do
|
318
|
+
expect { @instance.get_organizations_invite(nil, nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
319
|
+
end
|
320
|
+
|
321
|
+
it 'is expected to raise an exception when the org ID is empty' do
|
322
|
+
expect { @instance.get_organizations_invite('org_id', nil) }.to raise_exception(Auth0::InvalidParameter)
|
323
|
+
end
|
324
|
+
|
325
|
+
it 'is expected to get enabled connection for an org' do
|
326
|
+
expect(@instance).to receive(:get).with(
|
327
|
+
'/api/v2/organizations/org_id/invitations/invite_id'
|
328
|
+
)
|
329
|
+
expect { @instance.get_organizations_invite('org_id', 'invite_id') }.not_to raise_error
|
330
|
+
end
|
331
|
+
|
332
|
+
it 'is expected to get enabled connection for an org' do
|
333
|
+
expect(@instance).to receive(:get).with(
|
334
|
+
'/api/v2/organizations/org_id/invitations/invite_id'
|
335
|
+
)
|
336
|
+
expect do
|
337
|
+
@instance.get_organizations_invite('org_id', 'invite_id')
|
338
|
+
end.not_to raise_error
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
context '.patch_organizations_enabled_connection' do
|
343
|
+
it 'is expected to respond to a patch_organizations_enabled_connection method' do
|
344
|
+
expect(@instance).to respond_to(:patch_organizations_enabled_connection)
|
345
|
+
end
|
346
|
+
|
347
|
+
it 'is expected to respond to a update_organizations_enabled_connection method' do
|
348
|
+
expect(@instance).to respond_to(:update_organizations_enabled_connection)
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'is expected to patch /api/v2/organizations/org_id/enabled_connections/connection_id' do
|
352
|
+
expect(@instance).to receive(:patch).with(
|
353
|
+
'/api/v2/organizations/org_id/enabled_connections/connection_id',
|
354
|
+
{
|
355
|
+
assign_membership_on_login: false
|
356
|
+
}
|
357
|
+
)
|
358
|
+
@instance.patch_organizations_enabled_connection(
|
359
|
+
'org_id',
|
360
|
+
'connection_id',
|
361
|
+
assign_membership_on_login: false
|
362
|
+
)
|
363
|
+
end
|
364
|
+
|
365
|
+
it 'is expected to raise an exception when the organization id is empty' do
|
366
|
+
expect { @instance.patch_organizations_enabled_connection(nil, 'BODY') }.to raise_exception(Auth0::MissingOrganizationId)
|
367
|
+
end
|
368
|
+
|
369
|
+
it 'is expected to raise an error when the connection_id is empty' do
|
370
|
+
expect { @instance.patch_organizations_enabled_connection('org_id', nil) }.to raise_error 'Must supply a valid connection id'
|
371
|
+
end
|
372
|
+
|
373
|
+
it 'is expected to raise an error when assign_membership_on_login is nil' do
|
374
|
+
expect { @instance.patch_organizations_enabled_connection('org_id', 'connection_id') }.to raise_error 'Must supply a valid assign_membership_on_login value'
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
context '.create_organizations_invite' do
|
379
|
+
it 'is expected to respond to a create_organizations_invite method' do
|
380
|
+
expect(@instance).to respond_to(:create_organizations_invite)
|
381
|
+
end
|
382
|
+
|
383
|
+
it 'is expected to respond to a add_organizations_invite method' do
|
384
|
+
expect(@instance).to respond_to(:add_organizations_invite)
|
385
|
+
end
|
386
|
+
|
387
|
+
it 'is expected to post /api/v2/organizations/org_id/invitations' do
|
388
|
+
expect(@instance).to receive(:post).with(
|
389
|
+
'/api/v2/organizations/org_id/invitations',
|
390
|
+
{
|
391
|
+
ttl_sec: 60000
|
392
|
+
}
|
393
|
+
)
|
394
|
+
@instance.create_organizations_invite('org_id', ttl_sec: 60000)
|
395
|
+
end
|
396
|
+
|
397
|
+
it 'is expected to raise an exception when the organization id is empty' do
|
398
|
+
expect { @instance.create_organizations_invite(nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
context '.delete_organizations_invite' do
|
403
|
+
it 'is expected to respond to a delete_organizations_invite method' do
|
404
|
+
expect(@instance).to respond_to(:delete_organizations_invite)
|
405
|
+
end
|
406
|
+
|
407
|
+
it 'is expected to respond to a remove_organizations_invite method' do
|
408
|
+
expect(@instance).to respond_to(:remove_organizations_invite)
|
409
|
+
end
|
410
|
+
|
411
|
+
it 'is expected to delete /api/v2/organizations/org_id/invitations/invite_id' do
|
412
|
+
expect(@instance).to receive(:delete).with(
|
413
|
+
'/api/v2/organizations/org_id/invitations/invite_id'
|
414
|
+
)
|
415
|
+
@instance.delete_organizations_invite('org_id', 'invite_id')
|
416
|
+
end
|
417
|
+
|
418
|
+
it 'is expected to raise an exception when the organization id is empty' do
|
419
|
+
expect { @instance.delete_organizations_invite(nil, nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
420
|
+
end
|
421
|
+
|
422
|
+
it 'is expected to raise an exception when the invitation id is empty' do
|
423
|
+
expect { @instance.delete_organizations_invite('org_id', nil) }.to raise_error 'Must supply a valid invitation id'
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
context '.get_organizations_members' do
|
428
|
+
it 'is expected to respond to a get_organizations_members method' do
|
429
|
+
expect(@instance).to respond_to(:get_organizations_members)
|
430
|
+
end
|
431
|
+
|
432
|
+
it 'is expected to raise an exception when the org ID is empty' do
|
433
|
+
expect { @instance.get_organizations_members(nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
434
|
+
end
|
435
|
+
|
436
|
+
it 'is expected to get invitations for an org' do
|
437
|
+
expect(@instance).to receive(:get).with(
|
438
|
+
'/api/v2/organizations/org_id/members'
|
439
|
+
)
|
440
|
+
expect { @instance.get_organizations_members('org_id') }.not_to raise_error
|
441
|
+
end
|
442
|
+
|
443
|
+
it 'is expected to get members for an org' do
|
444
|
+
expect(@instance).to receive(:get).with(
|
445
|
+
'/api/v2/organizations/org_id/members'
|
446
|
+
)
|
447
|
+
expect do
|
448
|
+
@instance.get_organizations_members('org_id')
|
449
|
+
end.not_to raise_error
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
context '.create_organizations_members' do
|
454
|
+
it 'is expected to respond to a create_organizations_members method' do
|
455
|
+
expect(@instance).to respond_to(:create_organizations_members)
|
456
|
+
end
|
457
|
+
|
458
|
+
it 'is expected to respond to a add_organizations_members method' do
|
459
|
+
expect(@instance).to respond_to(:add_organizations_members)
|
460
|
+
end
|
461
|
+
|
462
|
+
it 'is expected to post /api/v2/organizations/org_id/members' do
|
463
|
+
expect(@instance).to receive(:post).with(
|
464
|
+
'/api/v2/organizations/org_id/members',
|
465
|
+
{
|
466
|
+
members: ['123', '456']
|
467
|
+
}
|
468
|
+
)
|
469
|
+
@instance.create_organizations_members('org_id', ['123', '456'])
|
470
|
+
end
|
471
|
+
|
472
|
+
it 'is expected to raise an exception when the organization id is empty' do
|
473
|
+
expect { @instance.create_organizations_members(nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
context '.delete_organizations_members' do
|
478
|
+
it 'is expected to respond to a delete_organizations_members method' do
|
479
|
+
expect(@instance).to respond_to(:delete_organizations_members)
|
480
|
+
end
|
481
|
+
|
482
|
+
it 'is expected to respond to a remove_organizations_members method' do
|
483
|
+
expect(@instance).to respond_to(:remove_organizations_members)
|
484
|
+
end
|
485
|
+
|
486
|
+
it 'is expected to delete /api/v2/organizations/org_id/members' do
|
487
|
+
expect(@instance).to receive(:delete).with(
|
488
|
+
'/api/v2/organizations/org_id/members', {
|
489
|
+
members: ['123', '456']
|
490
|
+
}
|
491
|
+
)
|
492
|
+
@instance.delete_organizations_members('org_id', ['123', '456'])
|
493
|
+
end
|
494
|
+
|
495
|
+
it 'is expected to raise an exception when the organization id is empty' do
|
496
|
+
expect { @instance.delete_organizations_members(nil, nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
497
|
+
end
|
498
|
+
|
499
|
+
it 'is expected to raise an exception when the invitation id is empty' do
|
500
|
+
expect { @instance.delete_organizations_members('org_id', []) }.to raise_error 'Must supply an array of member ids'
|
501
|
+
end
|
502
|
+
end
|
503
|
+
|
504
|
+
context '.get_organizations_member_roles' do
|
505
|
+
it 'is expected to respond to a get_organizations_member_roles method' do
|
506
|
+
expect(@instance).to respond_to(:get_organizations_member_roles)
|
507
|
+
end
|
508
|
+
|
509
|
+
it 'is expected to raise an exception when the org ID is empty' do
|
510
|
+
expect { @instance.get_organizations_member_roles(nil, nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
511
|
+
end
|
512
|
+
|
513
|
+
it 'is expected to raise an exception when the org ID is empty' do
|
514
|
+
expect { @instance.get_organizations_member_roles('org_id', nil) }.to raise_exception(Auth0::InvalidParameter)
|
515
|
+
end
|
516
|
+
|
517
|
+
it 'is expected to get roles for a member in an org' do
|
518
|
+
expect(@instance).to receive(:get).with(
|
519
|
+
'/api/v2/organizations/org_id/members/user_id/roles'
|
520
|
+
)
|
521
|
+
expect { @instance.get_organizations_member_roles('org_id', 'user_id') }.not_to raise_error
|
522
|
+
end
|
523
|
+
|
524
|
+
it 'is expected to get members for an org' do
|
525
|
+
expect(@instance).to receive(:get).with(
|
526
|
+
'/api/v2/organizations/org_id/members/user_id/roles'
|
527
|
+
)
|
528
|
+
expect do
|
529
|
+
@instance.get_organizations_member_roles('org_id', 'user_id')
|
530
|
+
end.not_to raise_error
|
531
|
+
end
|
532
|
+
end
|
533
|
+
|
534
|
+
context '.create_organizations_member_roles' do
|
535
|
+
it 'is expected to respond to a create_organizations_member_roles method' do
|
536
|
+
expect(@instance).to respond_to(:create_organizations_member_roles)
|
537
|
+
end
|
538
|
+
|
539
|
+
it 'is expected to respond to a add_organizations_member_roles method' do
|
540
|
+
expect(@instance).to respond_to(:add_organizations_member_roles)
|
541
|
+
end
|
542
|
+
|
543
|
+
it 'is expected to post /api/v2/organizations/org_id/members/user_id/roles' do
|
544
|
+
expect(@instance).to receive(:post).with(
|
545
|
+
'/api/v2/organizations/org_id/members/user_id/roles',
|
546
|
+
{
|
547
|
+
roles: ['123', '456']
|
548
|
+
}
|
549
|
+
)
|
550
|
+
@instance.create_organizations_member_roles('org_id', 'user_id', ['123', '456'])
|
551
|
+
end
|
552
|
+
|
553
|
+
it 'is expected to raise an exception when the organization id is empty' do
|
554
|
+
expect { @instance.create_organizations_member_roles(nil, nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
555
|
+
end
|
556
|
+
end
|
557
|
+
|
558
|
+
context '.delete_organizations_member_roles' do
|
559
|
+
it 'is expected to respond to a delete_organizations_member_roles method' do
|
560
|
+
expect(@instance).to respond_to(:delete_organizations_member_roles)
|
561
|
+
end
|
562
|
+
|
563
|
+
it 'is expected to respond to a remove_organizations_member_roles method' do
|
564
|
+
expect(@instance).to respond_to(:remove_organizations_member_roles)
|
565
|
+
end
|
566
|
+
|
567
|
+
it 'is expected to delete /api/v2/organizations/org_id/members/user_id/roles' do
|
568
|
+
expect(@instance).to receive(:delete).with(
|
569
|
+
'/api/v2/organizations/org_id/members/user_id/roles', {
|
570
|
+
roles: ['123', '456']
|
571
|
+
}
|
572
|
+
)
|
573
|
+
@instance.delete_organizations_member_roles('org_id', 'user_id', ['123', '456'])
|
574
|
+
end
|
575
|
+
|
576
|
+
it 'is expected to raise an exception when the organization id is empty' do
|
577
|
+
expect { @instance.delete_organizations_member_roles(nil, nil) }.to raise_exception(Auth0::MissingOrganizationId)
|
578
|
+
end
|
579
|
+
|
580
|
+
it 'is expected to raise an exception when the invitation id is empty' do
|
581
|
+
expect { @instance.delete_organizations_member_roles('org_id', nil, nil) }.to raise_error 'Must supply a valid user id'
|
582
|
+
end
|
583
|
+
|
584
|
+
it 'is expected to raise an exception when the invitation id is empty' do
|
585
|
+
expect { @instance.delete_organizations_member_roles('org_id', 'user_id') }.to raise_error 'Must supply an array of role ids'
|
586
|
+
end
|
587
|
+
end
|
588
|
+
end
|