auth0 4.16.0 → 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 +29 -8
- data/.github/CODEOWNERS +1 -1
- data/.github/ISSUE_TEMPLATE/config.yml +8 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +39 -0
- data/.github/ISSUE_TEMPLATE/report_a_bug.md +55 -0
- data/.gitignore +1 -1
- data/.yardoc/checksums +22 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/CHANGELOG.md +84 -0
- data/Gemfile +0 -1
- data/README.md +81 -8
- data/Rakefile +0 -22
- data/auth0.gemspec +4 -3
- data/examples/ruby-api/.gitignore +0 -6
- data/lib/auth0/api/authentication_endpoints.rb +22 -226
- 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 +33 -8
- data/lib/auth0/exception.rb +4 -7
- data/lib/auth0/mixins.rb +0 -1
- data/lib/auth0/mixins/access_token_struct.rb +2 -2
- data/lib/auth0/mixins/api_token_struct.rb +2 -2
- data/lib/auth0/mixins/httpproxy.rb +3 -1
- data/lib/auth0/mixins/initializer.rb +4 -8
- data/lib/auth0/mixins/permission_struct.rb +2 -2
- data/lib/auth0/mixins/validation.rb +15 -1
- data/lib/auth0/version.rb +1 -1
- data/spec/integration/lib/auth0/api/api_authentication_spec.rb +1 -1
- data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +1 -1
- data/spec/integration/lib/auth0/api/v2/api_roles_spec.rb +1 -1
- data/spec/integration/lib/auth0/api/v2/api_user_blocks_spec.rb +1 -1
- data/spec/integration/lib/auth0/api/v2/api_users_spec.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/roles_spec.rb +4 -4
- data/spec/lib/auth0/api/v2/tickets_spec.rb +55 -0
- data/spec/lib/auth0/api/v2/users_spec.rb +57 -11
- data/spec/lib/auth0/client_spec.rb +79 -9
- data/spec/lib/auth0/mixins/httpproxy_spec.rb +2 -2
- data/spec/lib/auth0/mixins/validation_spec.rb +32 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/support/credentials.rb +0 -19
- metadata +49 -44
- data/.github/ISSUE_TEMPLATE.md +0 -39
- data/Gemfile.lock +0 -227
- data/deploy_documentation.sh +0 -29
- data/doc_config/templates/default/fulldoc/html/css/full_list.css +0 -79
- data/doc_config/templates/default/fulldoc/html/css/style.css +0 -546
- data/doc_config/templates/default/layout/html/breadcrumb.erb +0 -11
- data/doc_config/templates/default/layout/html/footer.erb +0 -115
- data/doc_config/templates/default/layout/html/headers.erb +0 -17
- data/doc_config/templates/default/layout/html/layout.erb +0 -27
- data/lib/auth0/api/v1.rb +0 -19
- data/lib/auth0/api/v1/clients.rb +0 -58
- data/lib/auth0/api/v1/connections.rb +0 -68
- data/lib/auth0/api/v1/logs.rb +0 -43
- data/lib/auth0/api/v1/rules.rb +0 -57
- data/lib/auth0/api/v1/users.rb +0 -227
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +0 -703
data/lib/auth0/exception.rb
CHANGED
@@ -38,23 +38,20 @@ 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
|
44
46
|
class AccessDenied < Auth0::HTTPError; end
|
45
47
|
# Invalid parameter passed, e.g. empty where ID is required
|
46
48
|
class InvalidParameter < Auth0::Exception; end
|
47
|
-
# Invalid
|
48
|
-
# or JWT for API v2/
|
49
|
+
# Invalid JWT
|
49
50
|
class InvalidCredentials < Auth0::Exception; end
|
50
51
|
# Invalid Auth0 API namespace
|
51
52
|
class InvalidApiNamespace < Auth0::Exception; end
|
52
53
|
# Auth0 API rate-limiting encountered
|
53
|
-
|
54
|
-
# of Auth0::HTTPError directly rather than Auth0::Unsupported.
|
55
|
-
# It's currently under Unsupported to avoid breaking compatibility
|
56
|
-
# with prior gem versions that treated 429 errors as unknown errors.
|
57
|
-
class RateLimitEncountered < Auth0::Unsupported
|
54
|
+
class RateLimitEncountered < Auth0::HTTPError
|
58
55
|
def reset
|
59
56
|
Time.at(headers['X-RateLimit-Reset']).utc
|
60
57
|
end
|
data/lib/auth0/mixins.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ApiToken = Struct.new :access_token, :scope, :expires_in do
|
1
|
+
Auth0::ApiToken = Struct.new :access_token, :scope, :expires_in do
|
2
2
|
|
3
3
|
def token
|
4
4
|
access_token
|
@@ -7,4 +7,4 @@ ApiToken = Struct.new :access_token, :scope, :expires_in do
|
|
7
7
|
def scopes
|
8
8
|
scope.split
|
9
9
|
end
|
10
|
-
end
|
10
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "addressable/uri"
|
2
|
+
|
1
3
|
module Auth0
|
2
4
|
module Mixins
|
3
5
|
# here's the proxy for Rest calls based on rest-client, we're building all request on that gem
|
@@ -8,7 +10,7 @@ module Auth0
|
|
8
10
|
# proxying requests from instance methods to HTTP class methods
|
9
11
|
%i(get post post_file put patch delete delete_with_body).each do |method|
|
10
12
|
define_method(method) do |path, body = {}, extra_headers = {}|
|
11
|
-
safe_path = URI.escape(path)
|
13
|
+
safe_path = Addressable::URI.escape(path)
|
12
14
|
body = body.delete_if { |_, v| v.nil? }
|
13
15
|
result = if method == :get
|
14
16
|
# Mutate the headers property to add parameters.
|
@@ -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
|
|
@@ -40,7 +41,7 @@ module Auth0
|
|
40
41
|
private
|
41
42
|
|
42
43
|
def initialize_api(options)
|
43
|
-
|
44
|
+
initialize_v2(options)
|
44
45
|
raise InvalidCredentials, 'Must supply a valid API token' if @token.nil?
|
45
46
|
if options.fetch(:authorization, nil) == 'Basic'
|
46
47
|
authorization_header_basic(options)
|
@@ -58,13 +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
|
-
|
63
|
-
|
64
|
-
def initialize_v1
|
65
|
-
extend Auth0::Api::V1
|
66
|
-
raise InvalidCredentials, 'Invalid API v1 client_id and client_secret' if @client_id.nil? || @client_secret.nil?
|
67
|
-
@token = obtain_access_token
|
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
|
68
64
|
end
|
69
65
|
|
70
66
|
def api_v2?(options)
|
@@ -1,3 +1,3 @@
|
|
1
|
-
Permission = Struct.new :permission_name, :resource_server_identifier do
|
1
|
+
Auth0::Permission = Struct.new :permission_name, :resource_server_identifier do
|
2
2
|
|
3
|
-
end
|
3
|
+
end
|
@@ -23,7 +23,7 @@ module Auth0
|
|
23
23
|
raise Auth0::InvalidParameter, 'Must supply an array of Permissions' unless permissions.kind_of?(Array)
|
24
24
|
raise Auth0::MissingParameter, 'Must supply an array of Permissions' if permissions.empty?
|
25
25
|
raise Auth0::InvalidParameter, 'All array elements must be Permissions' unless permissions.all? do |permission|
|
26
|
-
permission.kind_of? Permission
|
26
|
+
permission.kind_of? ::Auth0::Permission
|
27
27
|
end
|
28
28
|
permissions.map { |permission| permission.to_h }
|
29
29
|
end
|
@@ -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
@@ -60,7 +60,7 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should return the userinfo' do
|
63
|
-
tokens = @client.
|
63
|
+
tokens = @client.login_with_resource_owner(test_user_email, test_user_pwd)
|
64
64
|
expect(@client.userinfo(tokens['access_token'])).to(
|
65
65
|
include( 'email' => test_user_email )
|
66
66
|
)
|
@@ -4,7 +4,7 @@ describe Auth0::Api::V2::Jobs do
|
|
4
4
|
|
5
5
|
let(:client) { Auth0Client.new(v2_creds) }
|
6
6
|
let(:username) { Faker::Internet.user_name }
|
7
|
-
let(:email) { "#{entity_suffix}#{Faker::Internet.safe_email(username)}" }
|
7
|
+
let(:email) { "#{entity_suffix}#{Faker::Internet.safe_email(name: username)}" }
|
8
8
|
let(:connection_id) do
|
9
9
|
VCR.use_cassette('Auth0_Api_V2_Jobs/search_for_connection_id') do
|
10
10
|
client.connections.find do |connection|
|
@@ -14,7 +14,7 @@ describe Auth0::Api::V2::Roles do
|
|
14
14
|
@test_role_name = "#{entity_suffix}-test-role"
|
15
15
|
|
16
16
|
@test_permission_name = "#{entity_suffix}-test-permission"
|
17
|
-
@test_permission = Permission.new(@test_permission_name, @test_api_name)
|
17
|
+
@test_permission = ::Auth0::Permission.new(@test_permission_name , @test_api_name)
|
18
18
|
|
19
19
|
VCR.use_cassette('Auth0_Api_V2_Roles/create_test_user') do
|
20
20
|
@test_user ||= client.create_user(
|
@@ -6,7 +6,7 @@ describe Auth0::Api::V2::UserBlocks do
|
|
6
6
|
before(:all) do
|
7
7
|
@client = Auth0Client.new(v2_creds)
|
8
8
|
username = Faker::Internet.user_name
|
9
|
-
@email = "#{entity_suffix}#{Faker::Internet.safe_email(username)}"
|
9
|
+
@email = "#{entity_suffix}#{Faker::Internet.safe_email(name: username)}"
|
10
10
|
password = Faker::Internet.password
|
11
11
|
@user = client.create_user(username, 'email' => email,
|
12
12
|
'password' => password,
|
@@ -14,7 +14,7 @@ describe Auth0::Api::V2::Users do
|
|
14
14
|
@test_api_scope = 'test:scope'
|
15
15
|
|
16
16
|
@test_permission_name = "#{entity_suffix}-test-permission-for-users"
|
17
|
-
@test_permission = Permission.new("#{entity_suffix}-test-permission-for-users", @test_api_name)
|
17
|
+
@test_permission = ::Auth0::Permission.new("#{entity_suffix}-test-permission-for-users", @test_api_name)
|
18
18
|
|
19
19
|
VCR.use_cassette('Auth0_Api_V2_Users/create_test_user') do
|
20
20
|
@test_user ||= client.create_user(
|
@@ -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
|