auth0 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -1
- data/.rubocop_todo.yml +0 -2
- data/.travis.yml +4 -2
- data/CHANGELOG.md +40 -38
- data/DEPLOYMENT.md +5 -0
- data/Gemfile +1 -1
- data/README.md +20 -2
- data/Rakefile +1 -1
- data/auth0.gemspec +4 -3
- data/doc_config/templates/default/layout/html/footer.erb +1 -1
- data/examples/ruby-api/.gitignore +86 -0
- data/examples/ruby-api/Gemfile +8 -0
- data/examples/ruby-api/README.md +24 -0
- data/examples/ruby-api/config.ru +2 -0
- data/examples/ruby-api/main.rb +33 -0
- data/examples/ruby-on-rails-api/.gitignore +18 -0
- data/examples/ruby-on-rails-api/Gemfile +48 -0
- data/examples/ruby-on-rails-api/README.md +27 -0
- data/examples/ruby-on-rails-api/Rakefile +6 -0
- data/examples/ruby-on-rails-api/app/assets/images/.keep +0 -0
- data/examples/ruby-on-rails-api/app/assets/javascripts/application.js +16 -0
- data/examples/ruby-on-rails-api/app/assets/stylesheets/application.css +15 -0
- data/examples/ruby-on-rails-api/app/controllers/application_controller.rb +8 -0
- data/examples/ruby-on-rails-api/app/controllers/concerns/.keep +0 -0
- data/examples/ruby-on-rails-api/app/controllers/ping_controller.rb +6 -0
- data/examples/ruby-on-rails-api/app/controllers/secured_ping_controller.rb +11 -0
- data/examples/ruby-on-rails-api/app/helpers/application_helper.rb +3 -0
- data/examples/ruby-on-rails-api/app/mailers/.keep +0 -0
- data/examples/ruby-on-rails-api/app/models/.keep +0 -0
- data/examples/ruby-on-rails-api/app/models/concerns/.keep +0 -0
- data/examples/ruby-on-rails-api/app/views/layouts/application.html.erb +14 -0
- data/examples/ruby-on-rails-api/bin/bundle +3 -0
- data/examples/ruby-on-rails-api/bin/rails +4 -0
- data/examples/ruby-on-rails-api/bin/rake +4 -0
- data/examples/ruby-on-rails-api/bin/setup +29 -0
- data/examples/ruby-on-rails-api/config.ru +4 -0
- data/examples/ruby-on-rails-api/config/application.rb +23 -0
- data/examples/ruby-on-rails-api/config/boot.rb +4 -0
- data/examples/ruby-on-rails-api/config/database.yml +27 -0
- data/examples/ruby-on-rails-api/config/environment.rb +5 -0
- data/examples/ruby-on-rails-api/config/environments/development.rb +37 -0
- data/examples/ruby-on-rails-api/config/environments/production.rb +83 -0
- data/examples/ruby-on-rails-api/config/environments/test.rb +41 -0
- data/examples/ruby-on-rails-api/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/ruby-on-rails-api/config/initializers/cookies_serializer.rb +3 -0
- data/examples/ruby-on-rails-api/config/initializers/dotenv.rb +4 -0
- data/examples/ruby-on-rails-api/config/initializers/filter_parameter_logging.rb +4 -0
- data/examples/ruby-on-rails-api/config/initializers/inflections.rb +16 -0
- data/examples/ruby-on-rails-api/config/initializers/knock.rb +53 -0
- data/examples/ruby-on-rails-api/config/initializers/mime_types.rb +4 -0
- data/examples/ruby-on-rails-api/config/initializers/session_store.rb +3 -0
- data/examples/ruby-on-rails-api/config/initializers/wrap_parameters.rb +14 -0
- data/examples/ruby-on-rails-api/config/locales/en.yml +23 -0
- data/examples/ruby-on-rails-api/config/routes.rb +58 -0
- data/examples/ruby-on-rails-api/config/secrets.yml +28 -0
- data/examples/ruby-on-rails-api/db/schema.rb +15 -0
- data/examples/ruby-on-rails-api/db/seeds.rb +7 -0
- data/examples/ruby-on-rails-api/lib/assets/.keep +0 -0
- data/examples/ruby-on-rails-api/lib/tasks/.keep +0 -0
- data/examples/ruby-on-rails-api/log/.keep +0 -0
- data/examples/ruby-on-rails-api/public/404.html +67 -0
- data/examples/ruby-on-rails-api/public/422.html +67 -0
- data/examples/ruby-on-rails-api/public/500.html +66 -0
- data/examples/ruby-on-rails-api/public/favicon.ico +0 -0
- data/examples/ruby-on-rails-api/public/robots.txt +5 -0
- data/examples/ruby-on-rails-api/test/controllers/.keep +0 -0
- data/examples/ruby-on-rails-api/test/fixtures/.keep +0 -0
- data/examples/ruby-on-rails-api/test/helpers/.keep +0 -0
- data/examples/ruby-on-rails-api/test/integration/.keep +0 -0
- data/examples/ruby-on-rails-api/test/mailers/.keep +0 -0
- data/examples/ruby-on-rails-api/test/models/.keep +0 -0
- data/examples/ruby-on-rails-api/test/ping_controller_test.rb +8 -0
- data/examples/ruby-on-rails-api/test/secured_ping_controller_test.rb +26 -0
- data/examples/ruby-on-rails-api/test/test_helper.rb +16 -0
- data/lib/auth0/api/authentication_endpoints.rb +59 -30
- data/lib/auth0/api/v1/clients.rb +1 -1
- data/lib/auth0/api/v1/connections.rb +4 -3
- data/lib/auth0/api/v1/logs.rb +1 -1
- data/lib/auth0/api/v1/rules.rb +1 -1
- data/lib/auth0/api/v1/users.rb +5 -5
- data/lib/auth0/api/v2.rb +10 -0
- data/lib/auth0/api/v2/blacklists.rb +1 -1
- data/lib/auth0/api/v2/client_grants.rb +57 -0
- data/lib/auth0/api/v2/clients.rb +14 -14
- data/lib/auth0/api/v2/connections.rb +19 -20
- data/lib/auth0/api/v2/device_credentials.rb +76 -0
- data/lib/auth0/api/v2/emails.rb +5 -7
- data/lib/auth0/api/v2/jobs.rb +15 -12
- data/lib/auth0/api/v2/logs.rb +65 -0
- data/lib/auth0/api/v2/resource_servers.rb +61 -0
- data/lib/auth0/api/v2/rules.rb +21 -20
- data/lib/auth0/api/v2/stats.rb +2 -2
- data/lib/auth0/api/v2/tenants.rb +6 -4
- data/lib/auth0/api/v2/tickets.rb +13 -14
- data/lib/auth0/api/v2/user_blocks.rb +62 -0
- data/lib/auth0/api/v2/users.rb +63 -32
- data/lib/auth0/client.rb +0 -2
- data/lib/auth0/mixins.rb +4 -3
- data/lib/auth0/mixins/httpproxy.rb +55 -0
- data/lib/auth0/mixins/initializer.rb +27 -10
- data/lib/auth0/version.rb +1 -1
- data/spec/integration/lib/auth0/api/api_authentication_spec.rb +118 -0
- data/spec/integration/lib/auth0/api/v2/api_blacklist_spec.rb +1 -1
- data/spec/integration/lib/auth0/api/v2/api_client_grants_spec.rb +53 -0
- data/spec/integration/lib/auth0/api/v2/api_clients_spec.rb +5 -2
- data/spec/integration/lib/auth0/api/v2/api_connections_spec.rb +8 -5
- data/spec/integration/lib/auth0/api/v2/api_device_credentials_spec.rb +67 -0
- data/spec/integration/lib/auth0/api/v2/api_email_spec.rb +15 -8
- data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +11 -9
- data/spec/integration/lib/auth0/api/v2/api_logs_spec.rb +69 -0
- data/spec/integration/lib/auth0/api/v2/api_resource_servers_spec.rb +47 -0
- data/spec/integration/lib/auth0/api/v2/api_rules_spec.rb +2 -1
- data/spec/integration/lib/auth0/api/v2/api_tickets_spec.rb +2 -2
- data/spec/integration/lib/auth0/api/v2/api_user_blocks_spec.rb +73 -0
- data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +32 -5
- data/spec/integration/lib/auth0/auth0_client_spec.rb +14 -11
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +116 -56
- data/spec/lib/auth0/api/v1/connections_spec.rb +2 -4
- data/spec/lib/auth0/api/v1/rules_spec.rb +2 -1
- data/spec/lib/auth0/api/v1/users_spec.rb +17 -9
- data/spec/lib/auth0/api/v2/client_grants_spec.rb +44 -0
- data/spec/lib/auth0/api/v2/connections_spec.rb +2 -1
- data/spec/lib/auth0/api/v2/device_credentials_spec.rb +73 -0
- data/spec/lib/auth0/api/v2/jobs_spec.rb +3 -2
- data/spec/lib/auth0/api/v2/logs_spec.rb +48 -0
- data/spec/lib/auth0/api/v2/resource_servers_spec.rb +63 -0
- data/spec/lib/auth0/api/v2/rules_spec.rb +8 -4
- data/spec/lib/auth0/api/v2/tenants_spec.rb +2 -1
- data/spec/lib/auth0/api/v2/tickets_spec.rb +4 -7
- data/spec/lib/auth0/api/v2/user_blocks_spec.rb +52 -0
- data/spec/lib/auth0/api/v2/users_spec.rb +39 -6
- data/spec/lib/auth0/client_spec.rb +8 -5
- data/spec/lib/auth0/mixins/httpproxy_spec.rb +225 -0
- data/spec/lib/auth0/mixins/initializer_spec.rb +1 -1
- data/spec/spec_helper_full.rb +12 -3
- data/spec/spec_helper_unit.rb +2 -2
- data/spec/support/credentials.rb +6 -4
- data/spec/support/dummy_class.rb +2 -1
- data/spec/support/dummy_class_for_proxy.rb +2 -2
- data/spec/support/dummy_class_for_restclient.rb +2 -0
- metadata +117 -9
- data/lib/auth0/mixins/httparty_proxy.rb +0 -38
- data/spec/lib/auth0/mixins/httparty_proxy_spec.rb +0 -148
@@ -40,8 +40,7 @@ describe Auth0::Api::V1::Connections do
|
|
40
40
|
options: {
|
41
41
|
tenant_domain: 'google.com',
|
42
42
|
domain_aliases: 'test.google.com,auth0.com'
|
43
|
-
}
|
44
|
-
}
|
43
|
+
} }
|
45
44
|
expect(@instance).to receive(:post).with('/api/connections', params)
|
46
45
|
expect do
|
47
46
|
@instance.create_connection(
|
@@ -59,8 +58,7 @@ describe Auth0::Api::V1::Connections do
|
|
59
58
|
params = { status: false,
|
60
59
|
options: {
|
61
60
|
tenant_domain: 'google.com'
|
62
|
-
}
|
63
|
-
}
|
61
|
+
} }
|
64
62
|
expect(@instance).to receive(:put).with('/api/connections/TestName', params)
|
65
63
|
expect { @instance.update_connection('TestName', 'google.com', false) }.not_to raise_error
|
66
64
|
end
|
@@ -20,7 +20,8 @@ describe Auth0::Api::V1::Rules do
|
|
20
20
|
it 'is expected to call post /api/rules' do
|
21
21
|
expect(@instance).to receive(:post).with(
|
22
22
|
'/api/rules',
|
23
|
-
name: 'test', script: 'script', order: 'order', status: 'status'
|
23
|
+
name: 'test', script: 'script', order: 'order', status: 'status'
|
24
|
+
)
|
24
25
|
expect { @instance.create_rule('test', 'script', 'order', 'status') }.not_to raise_error
|
25
26
|
end
|
26
27
|
end
|
@@ -89,7 +89,7 @@ describe Auth0::Api::V1::Users do
|
|
89
89
|
@instance.client_users('test_client_id')
|
90
90
|
end
|
91
91
|
it 'is expected to call /api/client//users if no client_id passed' do
|
92
|
-
expect(@instance).to receive(:get).with(
|
92
|
+
expect(@instance).to receive(:get).with("/api/clients/#{@instance.client_id}/users")
|
93
93
|
expect { @instance.client_users }.not_to raise_error
|
94
94
|
end
|
95
95
|
end
|
@@ -101,7 +101,8 @@ describe Auth0::Api::V1::Users do
|
|
101
101
|
'/api/users',
|
102
102
|
email: 'test@test.com',
|
103
103
|
password: 'password',
|
104
|
-
connection: 'conn'
|
104
|
+
connection: 'conn'
|
105
|
+
)
|
105
106
|
@instance.create_user('test@test.com', 'password', 'conn')
|
106
107
|
end
|
107
108
|
end
|
@@ -120,7 +121,8 @@ describe Auth0::Api::V1::Users do
|
|
120
121
|
password = SecureRandom.hex
|
121
122
|
expect(@instance).to receive(:post).with(
|
122
123
|
'/api/users/USERID/change_password_ticket',
|
123
|
-
'newPassword' => password, 'resultUrl' => nil
|
124
|
+
'newPassword' => password, 'resultUrl' => nil
|
125
|
+
)
|
124
126
|
@instance.change_password_ticket 'USERID', password
|
125
127
|
end
|
126
128
|
end
|
@@ -130,14 +132,16 @@ describe Auth0::Api::V1::Users do
|
|
130
132
|
it 'is expected to call post to /api/users/userId/verification_ticket if resulturl is set' do
|
131
133
|
expect(@instance).to receive(:post).with(
|
132
134
|
'/api/users/auth0|tdasfasdfasdfa/verification_ticket',
|
133
|
-
'resultUrl' => 'google.com'
|
135
|
+
'resultUrl' => 'google.com'
|
136
|
+
)
|
134
137
|
@instance.verification_ticket('auth0|tdasfasdfasdfa', 'google.com')
|
135
138
|
end
|
136
139
|
it 'is expected to call post to /api/users/userId/verification_ticket
|
137
140
|
if result url is empty' do
|
138
141
|
expect(@instance).to receive(:post).with(
|
139
142
|
'/api/users/auth0|tdasfasdfasdfa/verification_ticket',
|
140
|
-
'resultUrl' => nil
|
143
|
+
'resultUrl' => nil
|
144
|
+
)
|
141
145
|
@instance.verification_ticket('auth0|tdasfasdfasdfa')
|
142
146
|
end
|
143
147
|
end
|
@@ -147,7 +151,8 @@ describe Auth0::Api::V1::Users do
|
|
147
151
|
it 'is expected to call post to /api/users/userId/public_key' do
|
148
152
|
expect(@instance).to receive(:post).with(
|
149
153
|
'/api/users/auth0|tdasfasdfasdfa/public_key',
|
150
|
-
device: 'device22', public_key: 'SuperSecurePK'
|
154
|
+
device: 'device22', public_key: 'SuperSecurePK'
|
155
|
+
)
|
151
156
|
@instance.create_public_key('auth0|tdasfasdfasdfa', 'device22', 'SuperSecurePK')
|
152
157
|
end
|
153
158
|
end
|
@@ -174,7 +179,8 @@ describe Auth0::Api::V1::Users do
|
|
174
179
|
expect(@instance).to receive(:put).with(
|
175
180
|
'/api/users/auth0|tdasfasdfasdfa/password',
|
176
181
|
password: 'password',
|
177
|
-
verify: true
|
182
|
+
verify: true
|
183
|
+
)
|
178
184
|
@instance.update_user_password('auth0|tdasfasdfasdfa', 'password')
|
179
185
|
end
|
180
186
|
end
|
@@ -187,9 +193,11 @@ describe Auth0::Api::V1::Users do
|
|
187
193
|
email: 'email@email.com',
|
188
194
|
password: 'password',
|
189
195
|
connection: 'Con',
|
190
|
-
verify: true
|
196
|
+
verify: true
|
197
|
+
)
|
191
198
|
@instance.update_user_password_using_email(
|
192
|
-
'email@email.com', 'password', 'Con'
|
199
|
+
'email@email.com', 'password', 'Con'
|
200
|
+
)
|
193
201
|
end
|
194
202
|
end
|
195
203
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Auth0::Api::V2::ClientGrants do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::ClientGrants)
|
6
|
+
@instance = dummy_instance
|
7
|
+
end
|
8
|
+
context '.client_grants' do
|
9
|
+
it { expect(@instance).to respond_to(:client_grants) }
|
10
|
+
it { expect(@instance).to respond_to(:get_all_client_grants) }
|
11
|
+
it 'is expected to send get request to /api/v2/client_grants/' do
|
12
|
+
expect(@instance).to receive(:get).with('/api/v2/client-grants')
|
13
|
+
expect { @instance.client_grants }.not_to raise_error
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context '.create_client_grant' do
|
18
|
+
it { expect(@instance).to respond_to(:create_client_grant) }
|
19
|
+
it 'is expected to send post to /api/v2/client-grants' do
|
20
|
+
expect(@instance).to receive(:post).with('/api/v2/client-grants', opt: 'test body')
|
21
|
+
expect { @instance.create_client_grant(opt: 'test body') }.not_to raise_error
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context '.delete_client_grant' do
|
26
|
+
it { expect(@instance).to respond_to(:delete_client_grant) }
|
27
|
+
it 'is expected to send delete to /api/v2/client-grants/1' do
|
28
|
+
expect(@instance).to receive(:delete).with('/api/v2/client-grants/1')
|
29
|
+
expect { @instance.delete_client_grant('1') }.not_to raise_error
|
30
|
+
end
|
31
|
+
it { expect { @instance.delete_client_grant('') }.to raise_error 'Must specify a client grant id' }
|
32
|
+
end
|
33
|
+
|
34
|
+
context '.patch_client_grant' do
|
35
|
+
it { expect(@instance).to respond_to(:patch_client_grant) }
|
36
|
+
it { expect(@instance).to respond_to(:update_client_grant) }
|
37
|
+
it 'is expected to send patch to /api/v2/client-grants/1' do
|
38
|
+
expect(@instance).to receive(:patch).with('/api/v2/client-grants/1', 'test body')
|
39
|
+
expect { @instance.patch_client_grant('1', 'test body') }.not_to raise_error
|
40
|
+
end
|
41
|
+
it { expect { @instance.patch_client_grant('', nil) }.to raise_error 'Must specify a client grant id' }
|
42
|
+
it { expect { @instance.patch_client_grant('some', nil) }.to raise_error 'Must specify a valid body' }
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Auth0::Api::V2::DeviceCredentials do
|
3
|
+
attr_reader :client_id
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
dummy_instance = DummyClass.new
|
7
|
+
dummy_instance.extend(Auth0::Api::V2::DeviceCredentials)
|
8
|
+
@instance = dummy_instance
|
9
|
+
@client_id = Faker::Lorem.word
|
10
|
+
end
|
11
|
+
context '.device_credentials' do
|
12
|
+
it { expect(@instance).to respond_to(:device_credentials) }
|
13
|
+
it { expect(@instance).to respond_to(:list_device_credentials) }
|
14
|
+
it 'is expected to send get request to /api/v2/device-credentials' do
|
15
|
+
expect(@instance).to receive(:get).with(
|
16
|
+
'/api/v2/device-credentials',
|
17
|
+
fields: nil,
|
18
|
+
include_fields: nil,
|
19
|
+
user_id: nil,
|
20
|
+
client_id: client_id,
|
21
|
+
type: nil
|
22
|
+
)
|
23
|
+
expect { @instance.device_credentials(client_id) }.not_to raise_error
|
24
|
+
end
|
25
|
+
it 'is expect to raise an error when type is not one of \'public_key\', \'refresh_token\'' do
|
26
|
+
expect { @instance.device_credentials(client_id, type: 'invalid_type') }.to raise_error(
|
27
|
+
'Type must be one of \'public_key\', \'refresh_token\''
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context '.create_device_credential' do
|
33
|
+
it { expect(@instance).to respond_to(:create_device_credential) }
|
34
|
+
it { expect(@instance).to respond_to(:create_device_public_key) }
|
35
|
+
it 'is expected to send post to /api/v2/device-credentials' do
|
36
|
+
expect(@instance).to receive(:post).with(
|
37
|
+
'/api/v2/device-credentials',
|
38
|
+
device_name: 'device_name',
|
39
|
+
value: 'value',
|
40
|
+
device_id: 'device_id',
|
41
|
+
client_id: 'client_id',
|
42
|
+
type: 'public_key'
|
43
|
+
)
|
44
|
+
expect { @instance.create_device_credential('device_name', 'value', 'device_id', 'client_id') }
|
45
|
+
.not_to raise_error
|
46
|
+
end
|
47
|
+
it do
|
48
|
+
expect { @instance.create_device_credential(nil, 'value', 'device_id', 'client_id') }
|
49
|
+
.to raise_error('Must supply a valid device_name')
|
50
|
+
end
|
51
|
+
it do
|
52
|
+
expect { @instance.create_device_credential('device_name', nil, 'device_id', 'client_id') }
|
53
|
+
.to raise_error('Must supply a valid value')
|
54
|
+
end
|
55
|
+
it do
|
56
|
+
expect { @instance.create_device_credential('device_name', 'value', nil, 'client_id') }
|
57
|
+
.to raise_error('Must supply a valid device_id')
|
58
|
+
end
|
59
|
+
it do
|
60
|
+
expect { @instance.create_device_credential('device_name', 'value', 'device_id', nil) }
|
61
|
+
.to raise_error('Must supply a valid client_id')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context '.delete_device_credential' do
|
66
|
+
it { expect(@instance).to respond_to(:delete_device_credential) }
|
67
|
+
it 'is expected to send delete to /api/v2/device-credentials/1' do
|
68
|
+
expect(@instance).to receive(:delete).with('/api/v2/device-credentials/1')
|
69
|
+
expect { @instance.delete_device_credential('1') }.not_to raise_error
|
70
|
+
end
|
71
|
+
it { expect { @instance.delete_device_credential('') }.to raise_error 'Must supply a valid id' }
|
72
|
+
end
|
73
|
+
end
|
@@ -17,7 +17,8 @@ describe Auth0::Api::V2::Jobs do
|
|
17
17
|
it { expect(@instance).to respond_to(:import_users) }
|
18
18
|
it 'expect client to send post to /api/v2/jobs/users-imports' do
|
19
19
|
expect(@instance).to receive(:post_file).with(
|
20
|
-
'/api/v2/jobs/users-imports', users: 'file', connection_id: 'connnection_id'
|
20
|
+
'/api/v2/jobs/users-imports', users: 'file', connection_id: 'connnection_id'
|
21
|
+
)
|
21
22
|
expect { @instance.import_users('file', 'connnection_id') }.not_to raise_error
|
22
23
|
end
|
23
24
|
it { expect { @instance.import_users('', 'connnection_id') }.to raise_error('Must specify a valid file') }
|
@@ -28,7 +29,7 @@ describe Auth0::Api::V2::Jobs do
|
|
28
29
|
it { expect(@instance).to respond_to(:send_verification_email) }
|
29
30
|
it 'expect client to send post to /api/v2/jobs/verification-email' do
|
30
31
|
expect(@instance).to receive(:post).with('/api/v2/jobs/verification-email', user_id: 'user_id')
|
31
|
-
expect { @instance.send_verification_email(
|
32
|
+
expect { @instance.send_verification_email('user_id') }.not_to raise_error
|
32
33
|
end
|
33
34
|
it { expect { @instance.send_verification_email('') }.to raise_error('Must specify a user id') }
|
34
35
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Auth0::Api::V2::Logs do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::Logs)
|
6
|
+
@instance = dummy_instance
|
7
|
+
end
|
8
|
+
|
9
|
+
context '.logs' do
|
10
|
+
it { expect(@instance).to respond_to(:logs) }
|
11
|
+
it { expect(@instance).to respond_to(:get_logs) }
|
12
|
+
it 'is expected to call /api/v2/logs' do
|
13
|
+
expect(@instance).to receive(:get).with(
|
14
|
+
'/api/v2/logs',
|
15
|
+
q: nil,
|
16
|
+
page: nil,
|
17
|
+
per_page: nil,
|
18
|
+
sort: nil,
|
19
|
+
fields: nil,
|
20
|
+
include_fields: nil,
|
21
|
+
include_totals: nil,
|
22
|
+
from: nil,
|
23
|
+
take: nil
|
24
|
+
)
|
25
|
+
expect { @instance.logs }.not_to raise_error
|
26
|
+
end
|
27
|
+
it 'is expect to rise an error when take is higher than 100' do
|
28
|
+
expect { @instance.logs(take: rand(101..2000)) }.to raise_error(
|
29
|
+
'The total amount of entries to retrieve should be less than 100'
|
30
|
+
)
|
31
|
+
end
|
32
|
+
it 'is expect to rise an error when per_page is higher than 100' do
|
33
|
+
expect { @instance.logs(per_page: rand(101..2000)) }.to raise_error(
|
34
|
+
'The total amount of entries per page should be less than 100'
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context '.log' do
|
40
|
+
it { expect(@instance).to respond_to(:log) }
|
41
|
+
it { expect(@instance).to respond_to(:get_logs_by_id) }
|
42
|
+
it 'is expected to call get request to /api/v2/logs/LOG_ID' do
|
43
|
+
expect(@instance).to receive(:get).with('/api/v2/logs/LOG_ID')
|
44
|
+
expect { @instance.log('LOG_ID') }.not_to raise_error
|
45
|
+
end
|
46
|
+
it { expect { @instance.log(nil) }.to raise_error('Must supply a valid log_id') }
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Auth0::Api::V2::ResourceServers do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::ResourceServers)
|
6
|
+
dummy_instance.extend(Auth0::Mixins::Initializer)
|
7
|
+
@instance = dummy_instance
|
8
|
+
end
|
9
|
+
|
10
|
+
context '.resource_server' do
|
11
|
+
it { expect(@instance).to respond_to(:resource_server) }
|
12
|
+
it 'is expected to call get /api/v2/resource-servers/test' do
|
13
|
+
expect(@instance).to receive(:get).with('/api/v2/resource-servers/test')
|
14
|
+
expect { @instance.resource_server('test') }.not_to raise_error
|
15
|
+
end
|
16
|
+
it 'expect to raise an error when calling with empty resource server id' do
|
17
|
+
expect { @instance.resource_server(nil) }.to raise_error 'Must supply a valid resource server id'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context '.create_resource_server' do
|
22
|
+
it { expect(@instance).to respond_to(:create_resource_server) }
|
23
|
+
it 'is expected to call post /api/v2/resource-servers' do
|
24
|
+
expect(@instance).to receive(:post).with(
|
25
|
+
'/api/v2/resource-servers',
|
26
|
+
identifier: 'test',
|
27
|
+
name: 'name',
|
28
|
+
signing_alg: 'signing_alg',
|
29
|
+
signing_secret: 'signing_secret',
|
30
|
+
token_lifetime: 'token_lifetime',
|
31
|
+
scopes: 'scopes'
|
32
|
+
)
|
33
|
+
|
34
|
+
@instance.create_resource_server('test', name: 'name',
|
35
|
+
signing_alg: 'signing_alg',
|
36
|
+
signing_secret: 'signing_secret',
|
37
|
+
token_lifetime: 'token_lifetime',
|
38
|
+
scopes: 'scopes')
|
39
|
+
end
|
40
|
+
it 'expect to raise an error when calling with empty identifier' do
|
41
|
+
expect { @instance.create_resource_server(nil) }.to raise_error 'Must supply a valid resource server id'
|
42
|
+
end
|
43
|
+
it 'expect to raise an error when name contains < or > characters' do
|
44
|
+
expect { @instance.create_resource_server('test', name: '<') }.to raise_error(
|
45
|
+
'Name must contain at least one character. Does not allow "<" or ">"'
|
46
|
+
)
|
47
|
+
expect { @instance.create_resource_server('test', name: '>') }.to raise_error(
|
48
|
+
'Name must contain at least one character. Does not allow "<" or ">"'
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context '.delete_resource_server' do
|
54
|
+
it { expect(@instance).to respond_to(:delete_resource_server) }
|
55
|
+
it 'is expected to call delete /api/v2/resource-server/test' do
|
56
|
+
expect(@instance).to receive(:delete).with('/api/v2/resource-servers/test')
|
57
|
+
expect { @instance.delete_resource_server('test') }.not_to raise_error
|
58
|
+
end
|
59
|
+
it 'expect to raise an error when calling with empty resource server identifier' do
|
60
|
+
expect { @instance.delete_resource_server(nil) }.to raise_error 'Must supply a valid resource server id'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -11,7 +11,8 @@ describe Auth0::Api::V2::Rules do
|
|
11
11
|
it { expect(@instance).to respond_to(:rules) }
|
12
12
|
it 'is expected to call get /api/v2/rules' do
|
13
13
|
expect(@instance).to receive(:get).with(
|
14
|
-
'/api/v2/rules', enabled: nil, fields: nil, include_fields: nil, stage: nil
|
14
|
+
'/api/v2/rules', enabled: nil, fields: nil, include_fields: nil, stage: nil
|
15
|
+
)
|
15
16
|
expect { @instance.rules }.not_to raise_error
|
16
17
|
end
|
17
18
|
end
|
@@ -20,7 +21,8 @@ describe Auth0::Api::V2::Rules do
|
|
20
21
|
it { expect(@instance).to respond_to(:rule) }
|
21
22
|
it 'is expected to call get /api/v2/rules/test' do
|
22
23
|
expect(@instance).to receive(:get).with(
|
23
|
-
'/api/v2/rules/test', fields: nil, include_fields: nil
|
24
|
+
'/api/v2/rules/test', fields: nil, include_fields: nil
|
25
|
+
)
|
24
26
|
expect { @instance.rule('test') }.not_to raise_error
|
25
27
|
end
|
26
28
|
it 'expect to raise an error when calling with empty rule id' do
|
@@ -33,7 +35,8 @@ describe Auth0::Api::V2::Rules do
|
|
33
35
|
it 'is expected to call post /api/v2/rules' do
|
34
36
|
expect(@instance).to receive(:post).with(
|
35
37
|
'/api/v2/rules',
|
36
|
-
name: 'test', script: 'script', order: 'order', enabled: false, stage: 'login_success'
|
38
|
+
name: 'test', script: 'script', order: 'order', enabled: false, stage: 'login_success'
|
39
|
+
)
|
37
40
|
expect { @instance.create_rule('test', 'script', 'order', false) }.not_to raise_error
|
38
41
|
end
|
39
42
|
it 'expect to raise an error when calling with empty name' do
|
@@ -47,7 +50,8 @@ describe Auth0::Api::V2::Rules do
|
|
47
50
|
it { expect(@instance).to respond_to(:update_rule) }
|
48
51
|
it 'is expected to call put /api/v2/rules/test' do
|
49
52
|
expect(@instance).to receive(:patch).with(
|
50
|
-
'/api/v2/rules/test', script: 'script', order: 'order', enabled: true, stage: 'some_stage'
|
53
|
+
'/api/v2/rules/test', script: 'script', order: 'order', enabled: true, stage: 'some_stage'
|
54
|
+
)
|
51
55
|
expect do
|
52
56
|
@instance.update_rule('test', script: 'script', order: 'order', enabled: true, stage: 'some_stage')
|
53
57
|
end.not_to raise_error
|
@@ -19,7 +19,8 @@ describe Auth0::Api::V2::Tenants do
|
|
19
19
|
end
|
20
20
|
it 'expect client to rasie error when calling with empty body' do
|
21
21
|
expect { @instance.update_tenant_settings(nil) }.to raise_error(
|
22
|
-
'Must supply a valid body to update tenant settings'
|
22
|
+
'Must supply a valid body to update tenant settings'
|
23
|
+
)
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
@@ -12,20 +12,17 @@ describe Auth0::Api::V2::Tickets do
|
|
12
12
|
end
|
13
13
|
it 'expect client to rasie error when calling with empty body' do
|
14
14
|
expect { @instance.post_email_verification(nil) }.to raise_error(
|
15
|
-
'Must supply a valid user id to post an email verification'
|
15
|
+
'Must supply a valid user id to post an email verification'
|
16
|
+
)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
context '.post_password_change' do
|
19
20
|
it { expect(@instance).to respond_to(:post_password_change) }
|
20
21
|
it 'expect client to send post to /api/v2/tickets/password-change with body' do
|
21
22
|
expect(@instance).to receive(:post).with('/api/v2/tickets/password-change', user_id: nil, result_url: nil,
|
22
|
-
new_password:
|
23
|
+
new_password: nil,
|
23
24
|
connection_id: nil, email: nil)
|
24
|
-
expect { @instance.post_password_change
|
25
|
-
end
|
26
|
-
it 'expect client to rasie error when calling with empty body' do
|
27
|
-
expect { @instance.post_password_change(nil) }.to raise_error(
|
28
|
-
'Must supply a valid new password to post a password-change')
|
25
|
+
expect { @instance.post_password_change }.not_to raise_error
|
29
26
|
end
|
30
27
|
end
|
31
28
|
end
|