auth0 5.6.0 → 5.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +2 -1
  3. data/.gitignore +0 -1
  4. data/.shiprc +7 -0
  5. data/CHANGELOG.md +92 -31
  6. data/Gemfile.lock +233 -0
  7. data/README.md +1 -1
  8. data/lib/auth0/api/authentication_endpoints.rb +1 -1
  9. data/lib/auth0/api/v2/attack_protection.rb +79 -0
  10. data/lib/auth0/api/v2/device_credentials.rb +8 -3
  11. data/lib/auth0/api/v2/grants.rb +2 -2
  12. data/lib/auth0/api/v2/organizations.rb +1 -1
  13. data/lib/auth0/api/v2.rb +2 -0
  14. data/lib/auth0/mixins/validation.rb +4 -4
  15. data/lib/auth0/version.rb +1 -1
  16. data/spec/lib/auth0/api/v2/actions_spec.rb +13 -13
  17. data/spec/lib/auth0/api/v2/attack_protection_spec.rb +132 -0
  18. data/spec/lib/auth0/api/v2/blacklists_spec.rb +2 -2
  19. data/spec/lib/auth0/api/v2/branding_spec.rb +4 -3
  20. data/spec/lib/auth0/api/v2/client_grants_spec.rb +8 -8
  21. data/spec/lib/auth0/api/v2/clients_spec.rb +12 -12
  22. data/spec/lib/auth0/api/v2/connections_spec.rb +10 -10
  23. data/spec/lib/auth0/api/v2/device_credentials_spec.rb +39 -10
  24. data/spec/lib/auth0/api/v2/emails_spec.rb +2 -2
  25. data/spec/lib/auth0/api/v2/grants_spec.rb +11 -11
  26. data/spec/lib/auth0/api/v2/jobs_spec.rb +18 -17
  27. data/spec/lib/auth0/api/v2/log_streams_spec.rb +3 -3
  28. data/spec/lib/auth0/api/v2/logs_spec.rb +2 -2
  29. data/spec/lib/auth0/api/v2/organizations_spec.rb +13 -13
  30. data/spec/lib/auth0/api/v2/resource_servers_spec.rb +5 -5
  31. data/spec/lib/auth0/api/v2/roles_spec.rb +22 -22
  32. data/spec/lib/auth0/api/v2/rules_spec.rb +7 -7
  33. data/spec/lib/auth0/api/v2/stats_spec.rb +1 -1
  34. data/spec/lib/auth0/api/v2/tenants_spec.rb +1 -1
  35. data/spec/lib/auth0/api/v2/tickets_spec.rb +14 -14
  36. data/spec/lib/auth0/api/v2/user_blocks_spec.rb +2 -2
  37. data/spec/lib/auth0/api/v2/users_by_email_spec.rb +2 -2
  38. data/spec/lib/auth0/api/v2/users_spec.rb +23 -23
  39. data/spec/lib/auth0/mixins/validation_spec.rb +16 -2
  40. metadata +8 -3
data/Gemfile.lock ADDED
@@ -0,0 +1,233 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ auth0 (5.8.0)
5
+ addressable (~> 2.8)
6
+ jwt (~> 2.2)
7
+ rest-client (~> 2.1)
8
+ retryable (~> 3.0)
9
+ zache (~> 0.12)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ actionpack (7.0.2.3)
15
+ actionview (= 7.0.2.3)
16
+ activesupport (= 7.0.2.3)
17
+ rack (~> 2.0, >= 2.2.0)
18
+ rack-test (>= 0.6.3)
19
+ rails-dom-testing (~> 2.0)
20
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
21
+ actionview (7.0.2.3)
22
+ activesupport (= 7.0.2.3)
23
+ builder (~> 3.1)
24
+ erubi (~> 1.4)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
27
+ activesupport (7.0.2.3)
28
+ concurrent-ruby (~> 1.0, >= 1.0.2)
29
+ i18n (>= 1.6, < 2)
30
+ minitest (>= 5.1)
31
+ tzinfo (~> 2.0)
32
+ addressable (2.8.0)
33
+ public_suffix (>= 2.0.2, < 5.0)
34
+ ast (2.4.2)
35
+ builder (3.2.4)
36
+ codecov (0.6.0)
37
+ simplecov (>= 0.15, < 0.22)
38
+ coderay (1.1.3)
39
+ concurrent-ruby (1.1.10)
40
+ coveralls (0.7.1)
41
+ multi_json (~> 1.3)
42
+ rest-client
43
+ simplecov (>= 0.7)
44
+ term-ansicolor
45
+ thor
46
+ crack (0.4.5)
47
+ rexml
48
+ crass (1.0.6)
49
+ diff-lcs (1.5.0)
50
+ docile (1.4.0)
51
+ domain_name (0.5.20190701)
52
+ unf (>= 0.0.5, < 1.0.0)
53
+ dotenv (2.7.6)
54
+ dotenv-rails (2.7.6)
55
+ dotenv (= 2.7.6)
56
+ railties (>= 3.2)
57
+ erubi (1.10.0)
58
+ faker (2.20.0)
59
+ i18n (>= 1.8.11, < 2)
60
+ ffi (1.15.5)
61
+ formatador (1.1.0)
62
+ fuubar (2.5.1)
63
+ rspec-core (~> 3.0)
64
+ ruby-progressbar (~> 1.4)
65
+ gem-release (0.7.4)
66
+ guard (2.17.0)
67
+ formatador (>= 0.2.4)
68
+ listen (>= 2.7, < 4.0)
69
+ lumberjack (>= 1.0.12, < 2.0)
70
+ nenv (~> 0.1)
71
+ notiffany (~> 0.0)
72
+ pry (>= 0.9.12)
73
+ shellany (~> 0.0)
74
+ thor (>= 0.18.1)
75
+ guard-compat (1.2.1)
76
+ guard-rspec (4.7.3)
77
+ guard (~> 2.1)
78
+ guard-compat (~> 1.1)
79
+ rspec (>= 2.99.0, < 4.0)
80
+ hashdiff (1.0.1)
81
+ http-accept (1.7.0)
82
+ http-cookie (1.0.4)
83
+ domain_name (~> 0.5)
84
+ i18n (1.10.0)
85
+ concurrent-ruby (~> 1.0)
86
+ jwt (2.3.0)
87
+ listen (3.7.1)
88
+ rb-fsevent (~> 0.10, >= 0.10.3)
89
+ rb-inotify (~> 0.9, >= 0.9.10)
90
+ loofah (2.15.0)
91
+ crass (~> 1.0.2)
92
+ nokogiri (>= 1.5.9)
93
+ lumberjack (1.2.8)
94
+ method_source (0.9.2)
95
+ mime-types (3.4.1)
96
+ mime-types-data (~> 3.2015)
97
+ mime-types-data (3.2022.0105)
98
+ mini_portile2 (2.8.0)
99
+ minitest (5.15.0)
100
+ multi_json (1.15.0)
101
+ nenv (0.3.0)
102
+ netrc (0.11.0)
103
+ nokogiri (1.13.3)
104
+ mini_portile2 (~> 2.8.0)
105
+ racc (~> 1.4)
106
+ notiffany (0.1.3)
107
+ nenv (~> 0.1)
108
+ shellany (~> 0.0)
109
+ parallel (1.22.0)
110
+ parser (3.1.1.0)
111
+ ast (~> 2.4.1)
112
+ pry (0.12.2)
113
+ coderay (~> 1.1.0)
114
+ method_source (~> 0.9.0)
115
+ pry-nav (0.3.0)
116
+ pry (>= 0.9.10, < 0.13.0)
117
+ public_suffix (4.0.6)
118
+ racc (1.6.0)
119
+ rack (2.2.3)
120
+ rack-test (0.8.3)
121
+ rack (>= 1.0, < 3)
122
+ rails-dom-testing (2.0.3)
123
+ activesupport (>= 4.2.0)
124
+ nokogiri (>= 1.6)
125
+ rails-html-sanitizer (1.4.2)
126
+ loofah (~> 2.3)
127
+ railties (7.0.2.3)
128
+ actionpack (= 7.0.2.3)
129
+ activesupport (= 7.0.2.3)
130
+ method_source
131
+ rake (>= 12.2)
132
+ thor (~> 1.0)
133
+ zeitwerk (~> 2.5)
134
+ rainbow (3.1.1)
135
+ rake (13.0.6)
136
+ rb-fsevent (0.11.1)
137
+ rb-inotify (0.10.1)
138
+ ffi (~> 1.0)
139
+ regexp_parser (2.2.1)
140
+ rest-client (2.1.0)
141
+ http-accept (>= 1.7.0, < 2.0)
142
+ http-cookie (>= 1.0.2, < 2.0)
143
+ mime-types (>= 1.16, < 4.0)
144
+ netrc (~> 0.8)
145
+ retryable (3.0.5)
146
+ rexml (3.2.5)
147
+ rspec (3.11.0)
148
+ rspec-core (~> 3.11.0)
149
+ rspec-expectations (~> 3.11.0)
150
+ rspec-mocks (~> 3.11.0)
151
+ rspec-core (3.11.0)
152
+ rspec-support (~> 3.11.0)
153
+ rspec-expectations (3.11.0)
154
+ diff-lcs (>= 1.2.0, < 2.0)
155
+ rspec-support (~> 3.11.0)
156
+ rspec-mocks (3.11.0)
157
+ diff-lcs (>= 1.2.0, < 2.0)
158
+ rspec-support (~> 3.11.0)
159
+ rspec-support (3.11.0)
160
+ rubocop (1.26.1)
161
+ parallel (~> 1.10)
162
+ parser (>= 3.1.0.0)
163
+ rainbow (>= 2.2.2, < 4.0)
164
+ regexp_parser (>= 1.8, < 3.0)
165
+ rexml
166
+ rubocop-ast (>= 1.16.0, < 2.0)
167
+ ruby-progressbar (~> 1.7)
168
+ unicode-display_width (>= 1.4.0, < 3.0)
169
+ rubocop-ast (1.16.0)
170
+ parser (>= 3.1.1.0)
171
+ rubocop-rails (2.14.2)
172
+ activesupport (>= 4.2.0)
173
+ rack (>= 1.1)
174
+ rubocop (>= 1.7.0, < 2.0)
175
+ ruby-progressbar (1.11.0)
176
+ shellany (0.0.1)
177
+ simplecov (0.21.2)
178
+ docile (~> 1.1)
179
+ simplecov-html (~> 0.11)
180
+ simplecov_json_formatter (~> 0.1)
181
+ simplecov-html (0.12.3)
182
+ simplecov_json_formatter (0.1.4)
183
+ sync (0.5.0)
184
+ term-ansicolor (1.7.1)
185
+ tins (~> 1.0)
186
+ terminal-notifier-guard (1.7.0)
187
+ thor (1.2.1)
188
+ timecop (0.9.5)
189
+ tins (1.31.0)
190
+ sync
191
+ tzinfo (2.0.4)
192
+ concurrent-ruby (~> 1.0)
193
+ unf (0.1.4)
194
+ unf_ext
195
+ unf_ext (0.0.8.1)
196
+ unicode-display_width (2.1.0)
197
+ vcr (6.1.0)
198
+ webmock (3.14.0)
199
+ addressable (>= 2.8.0)
200
+ crack (>= 0.3.2)
201
+ hashdiff (>= 0.4.0, < 2.0.0)
202
+ zache (0.12.0)
203
+ zeitwerk (2.5.4)
204
+
205
+ PLATFORMS
206
+ ruby
207
+
208
+ DEPENDENCIES
209
+ auth0!
210
+ bundler
211
+ codecov
212
+ coveralls
213
+ dotenv-rails (~> 2.0)
214
+ faker (~> 2.0)
215
+ fuubar (~> 2.0)
216
+ gem-release (~> 0.7)
217
+ guard-rspec (~> 4.5)
218
+ pry (~> 0.10)
219
+ pry-nav (~> 0.2)
220
+ rack (~> 2.1)
221
+ rack-test (~> 0.6)
222
+ rake (~> 13.0)
223
+ rspec (~> 3.5)
224
+ rubocop
225
+ rubocop-rails
226
+ simplecov
227
+ terminal-notifier-guard
228
+ timecop
229
+ vcr
230
+ webmock
231
+
232
+ BUNDLED WITH
233
+ 1.17.2
data/README.md CHANGED
@@ -45,7 +45,7 @@ end
45
45
  ... and a Controller to handle that route:
46
46
 
47
47
  ```ruby
48
- # app/controllers/all_users_controllers.rb
48
+ # app/controllers/all_users_controller.rb
49
49
  require 'auth0'
50
50
 
51
51
  class AllUsersController < ApplicationController
@@ -152,7 +152,7 @@ module Auth0
152
152
  # @param password [string] User's new password. This is only available
153
153
  # on legacy tenants with change password v1 flow enabled
154
154
  # @param connection_name [string] Database connection name
155
- # @deprecated Use {#password_reset} instead.
155
+ # @deprecated Use {#reset_password} instead.
156
156
  def change_password(email, password, connection_name = UP_AUTH)
157
157
  raise Auth0::InvalidParameter, 'Must supply a valid email' if email.to_s.empty?
158
158
 
@@ -0,0 +1,79 @@
1
+ module Auth0
2
+ module Api
3
+ module V2
4
+ # Methods to use the attack-protection endpoints
5
+ module AttackProtection
6
+ attr_reader :attack_protection_path
7
+
8
+ # Get breached password detection settings
9
+ # @see https://auth0.com/docs/api/management/v2#!/Attack_Protection/get_breached_password_detection
10
+ # @return [json] The configuration for breached password detection
11
+ def breached_password_detection
12
+ get(breached_password_settings_path)
13
+ end
14
+ alias get_breached_password_detection_settings breached_password_detection
15
+
16
+ # Update breached password detection settings
17
+ # @see https://auth0.com/docs/api/management/v2#!/Attack_Protection/patch_breached_password_detection
18
+ # @param body [hash] See https://auth0.com/docs/api/management/v2#!/Attack_Protection/patch_breached_password_detection for available options
19
+ # @return [json] The configuration for breached password detection
20
+ def patch_breached_password_detection(body)
21
+ patch(breached_password_settings_path, body)
22
+ end
23
+
24
+ # Get brute force protection settings.
25
+ # @see https://auth0.com/docs/api/management/v2#!/Attack_Protection/get_brute_force_protection
26
+ # @return [json] The configuration for brute force protection
27
+ def brute_force_protection
28
+ get(brute_force_protection_settings_path)
29
+ end
30
+ alias get_brute_force_protection_settings brute_force_protection
31
+
32
+ # Update brute force protection settings.
33
+ # @see https://auth0.com/docs/api/management/v2#!/Attack_Protection/patch_brute_force_protection
34
+ # @param body [hash] See https://auth0.com/docs/api/management/v2#!/Attack_Protection/patch_brute_force_protection for available options
35
+ # @return [json] The configuration for brute force protection
36
+ def patch_brute_force_protection(body)
37
+ patch(brute_force_protection_settings_path, body)
38
+ end
39
+ alias update_brute_force_protection_settings patch_brute_force_protection
40
+
41
+ # Get suspicious IP throttling settings
42
+ # @see https://auth0.com/docs/api/management/v2#!/Attack_Protection/get_suspicious_ip_throttling
43
+ # @return The configuration for suspicious IP throttling
44
+ def suspicious_ip_throttling
45
+ get(suspicious_ip_throttling_settings_path)
46
+ end
47
+ alias get_suspicious_ip_throttling_settings suspicious_ip_throttling
48
+
49
+ # Update suspicious IP throttling settings
50
+ # @see https://auth0.com/docs/api/management/v2#!/Attack_Protection/patch_suspicious_ip_throttling
51
+ # @param body [hash] See https://auth0.com/docs/api/management/v2#!/Attack_Protection/patch_suspicious_ip_throttling for available options
52
+ # @return The configuration for suspicious IP throttling
53
+ def patch_suspicious_ip_throttling(body)
54
+ patch(suspicious_ip_throttling_settings_path, body)
55
+ end
56
+ alias update_suspicious_ip_throttling_settings patch_suspicious_ip_throttling
57
+
58
+ private
59
+
60
+ def attack_protection_path
61
+ @attack_protection_path ||= '/api/v2/attack-protection'
62
+ end
63
+ alias update_breached_password_detection_settings patch_breached_password_detection
64
+
65
+ def breached_password_settings_path
66
+ "#{attack_protection_path}/breached-password-detection"
67
+ end
68
+
69
+ def brute_force_protection_settings_path
70
+ "#{attack_protection_path}/brute-force-protection"
71
+ end
72
+
73
+ def suspicious_ip_throttling_settings_path
74
+ "#{attack_protection_path}/suspicious-ip-throttling"
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -13,18 +13,23 @@ module Auth0
13
13
  # * :include_fields [boolean] True if the fields specified are to be included in the result, false otherwise.
14
14
  # * :user_id [string] The user_id of the devices to retrieve.
15
15
  # * :type [string] Type of credentials to retrieve. Must be 'public_key', 'refresh_token' or 'rotating_refresh_token'
16
+ # * :page [integer] The page number. Zero based
17
+ # * :per_page [integer] The amount of entries per page
18
+ # * :include_totals [boolean] Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
16
19
  #
17
20
  # @return [json] Returns the list of existing devices for the specified client_id.
18
21
  # rubocop:disable Metrics/AbcSize
19
- def device_credentials(client_id, options = {})
22
+ def device_credentials(client_id = nil, options = {})
20
23
  request_params = {
21
24
  fields: options.fetch(:fields, nil),
22
25
  include_fields: options.fetch(:include_fields, nil),
23
26
  user_id: options.fetch(:user_id, nil),
24
27
  client_id: client_id,
25
- type: options.fetch(:type, nil)
28
+ type: options.fetch(:type, nil),
29
+ page: options.fetch(:page, nil),
30
+ per_page: options.fetch(:per_page, nil),
31
+ include_totals: options.fetch(:include_totals, nil)
26
32
  }
27
- raise Auth0::InvalidParameter, 'Must supply a valid client_id' if client_id.to_s.empty?
28
33
  if !request_params[:type].nil? && !%w(public_key refresh_token rotating_refresh_token).include?(request_params[:type])
29
34
  raise Auth0::InvalidParameter, 'Type must be one of \'public_key\', \'refresh_token\', \'rotating_refresh_token\''
30
35
  end
@@ -33,8 +33,8 @@ module Auth0
33
33
  def delete_grant(id, user_id)
34
34
  raise Auth0::InvalidParameter, 'Must specify a grant id as id' if id.to_s.empty?
35
35
  raise Auth0::InvalidParameter, 'Must specify a user id' if user_id.to_s.empty?
36
- path = "#{grants_path}/#{id}?user_id=#{user_id}"
37
- delete(path)
36
+ path = "#{grants_path}/#{id}"
37
+ delete(path, user_id: user_id)
38
38
  end
39
39
 
40
40
  private
@@ -320,7 +320,7 @@ module Auth0
320
320
  body = {}
321
321
  body[:roles] = roles
322
322
 
323
- delete(path, body)
323
+ delete_with_body(path, body)
324
324
  end
325
325
  alias remove_organizations_member_roles delete_organizations_member_roles
326
326
 
data/lib/auth0/api/v2.rb CHANGED
@@ -23,6 +23,7 @@ require 'auth0/api/v2/logs'
23
23
  require 'auth0/api/v2/log_streams'
24
24
  require 'auth0/api/v2/resource_servers'
25
25
  require 'auth0/api/v2/guardian'
26
+ require 'auth0/api/v2/attack_protection'
26
27
 
27
28
  module Auth0
28
29
  module Api
@@ -53,6 +54,7 @@ module Auth0
53
54
  include Auth0::Api::V2::ResourceServers
54
55
  include Auth0::Api::V2::Tenants
55
56
  include Auth0::Api::V2::Tickets
57
+ include Auth0::Api::V2::AttackProtection
56
58
  end
57
59
  end
58
60
  end
@@ -286,7 +286,7 @@ module Auth0
286
286
 
287
287
  # Clear the JWK set cache.
288
288
  def remove_jwks
289
- @@cache.remove(:jwks)
289
+ @@cache.remove_by { true }
290
290
  end
291
291
  end
292
292
 
@@ -311,13 +311,13 @@ module Auth0
311
311
  result = fetch_jwks if force
312
312
 
313
313
  if result
314
- @@cache.put(:jwks, result, lifetime: @lifetime)
314
+ @@cache.put(@jwks_url, result, lifetime: @lifetime)
315
315
  return result
316
316
  end
317
317
 
318
- previous_value = @@cache.last(:jwks)
318
+ previous_value = @@cache.last(@jwks_url)
319
319
 
320
- @@cache.get(:jwks, lifetime: @lifetime, dirty: true) do
320
+ @@cache.get(@jwks_url, lifetime: @lifetime, dirty: true) do
321
321
  new_value = fetch_jwks
322
322
 
323
323
  raise Auth0::InvalidIdToken, 'Could not fetch the JWK set' unless new_value || previous_value
data/lib/auth0/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # current version of gem
2
2
  module Auth0
3
- VERSION = '5.6.0'.freeze
3
+ VERSION = '5.8.0'.freeze
4
4
  end
@@ -17,14 +17,14 @@ describe Auth0::Api::V2::Actions do
17
17
 
18
18
  it 'is expected to get /api/v2/actions with custom parameters' do
19
19
  expect(@instance).to receive(:get).with(
20
- '/api/v2/actions/actions',
20
+ '/api/v2/actions/actions', {
21
21
  trigger_id: 'post-login',
22
22
  action_name: 'loginHandler',
23
23
  deployed: true,
24
24
  per_page: 10,
25
25
  page: 1,
26
26
  installed: true
27
- )
27
+ })
28
28
  expect do
29
29
  @instance.actions(
30
30
  'post-login',
@@ -71,9 +71,9 @@ describe Auth0::Api::V2::Actions do
71
71
 
72
72
  it 'is expected to post to /api/v2/actions' do
73
73
  expect(@instance).to receive(:post).with(
74
- '/api/v2/actions',
74
+ '/api/v2/actions', {
75
75
  name: 'test_org'
76
- )
76
+ })
77
77
  expect do
78
78
  @instance.create_action(
79
79
  name: 'test_org'
@@ -141,10 +141,10 @@ describe Auth0::Api::V2::Actions do
141
141
 
142
142
  it 'is expected to call get request to /api/v2/actions/actions/{id}/versions' do
143
143
  expect(@instance).to receive(:get).with(
144
- '/api/v2/actions/actions/123/versions',
144
+ '/api/v2/actions/actions/123/versions', {
145
145
  per_page: nil,
146
146
  page: nil
147
- )
147
+ })
148
148
  expect { @instance.actions_versions('123') }.not_to raise_error
149
149
  end
150
150
 
@@ -154,10 +154,10 @@ describe Auth0::Api::V2::Actions do
154
154
 
155
155
  it 'is expected to get /api/v2/actions/actions/{id}/versions with custom parameters' do
156
156
  expect(@instance).to receive(:get).with(
157
- '/api/v2/actions/actions/123/versions',
157
+ '/api/v2/actions/actions/123/versions', {
158
158
  per_page: 10,
159
159
  page: 1
160
- )
160
+ })
161
161
  expect do
162
162
  @instance.actions_versions(
163
163
  '123',
@@ -176,10 +176,10 @@ describe Auth0::Api::V2::Actions do
176
176
 
177
177
  it 'is expected to call get request to /api/v2/actions/triggers/{id}/bindings' do
178
178
  expect(@instance).to receive(:get).with(
179
- '/api/v2/actions/triggers/123/bindings',
179
+ '/api/v2/actions/triggers/123/bindings', {
180
180
  per_page: nil,
181
181
  page: nil
182
- )
182
+ })
183
183
  expect { @instance.trigger_bindings('123') }.not_to raise_error
184
184
  end
185
185
 
@@ -189,10 +189,10 @@ describe Auth0::Api::V2::Actions do
189
189
 
190
190
  it 'is expected to get /api/v2/actions/triggers/{id}/bindings with custom parameters' do
191
191
  expect(@instance).to receive(:get).with(
192
- '/api/v2/actions/triggers/123/bindings',
192
+ '/api/v2/actions/triggers/123/bindings', {
193
193
  per_page: 10,
194
194
  page: 1
195
- )
195
+ })
196
196
  expect do
197
197
  @instance.trigger_bindings(
198
198
  '123',
@@ -278,7 +278,7 @@ describe Auth0::Api::V2::Actions do
278
278
  it 'is expected to post to /api/v2/actions/{id}/test' do
279
279
  expect(@instance).to receive(:post).with(
280
280
  '/api/v2/actions/actions/123/test',
281
- name: 'test_org'
281
+ { name: 'test_org' }
282
282
  )
283
283
  expect do
284
284
  @instance.test_action(
@@ -0,0 +1,132 @@
1
+ require 'spec_helper'
2
+
3
+ describe Auth0::Api::V2::AttackProtection do
4
+ before :all do
5
+ dummy_instance = DummyClass.new
6
+ dummy_instance.extend(Auth0::Api::V2::AttackProtection)
7
+ @instance = dummy_instance
8
+ end
9
+
10
+ context '.get breached-password-detection' do
11
+ it 'responds to a breached_password_detection method' do
12
+ expect(@instance).to respond_to(:breached_password_detection)
13
+ end
14
+
15
+ it 'responds to get_breached_password_detection_settings' do
16
+ expect(@instance).to respond_to(:get_breached_password_detection_settings)
17
+ end
18
+
19
+ it 'is expected to get /api/v2/attack-protection/breached-password' do
20
+ expect(@instance).to receive(:get).with(
21
+ '/api/v2/attack-protection/breached-password-detection'
22
+ )
23
+
24
+ expect { @instance.breached_password_detection }.not_to raise_error
25
+ end
26
+ end
27
+
28
+ context '.patch breached-password-detection' do
29
+ it 'responds to a patch_breached_password_detection method' do
30
+ expect(@instance).to respond_to(:patch_breached_password_detection)
31
+ end
32
+
33
+ it 'responds to a update_breached_password_detection_settings method' do
34
+ expect(@instance).to respond_to(:update_breached_password_detection_settings)
35
+ end
36
+
37
+ it 'is expected to patch /api/v2/attack-protection/breached-password-detection' do
38
+ expect(@instance).to receive(:patch).with(
39
+ '/api/v2/attack-protection/breached-password-detection',
40
+ {
41
+ enabled: true
42
+ }
43
+ )
44
+
45
+ @instance.patch_breached_password_detection({
46
+ enabled: true
47
+ })
48
+ end
49
+ end
50
+
51
+ context '.get brute_force_protection' do
52
+ it 'responds to brute_force_protection' do
53
+ expect(@instance).to respond_to(:brute_force_protection)
54
+ end
55
+
56
+ it 'responds to get_brute_force_protection_settings' do
57
+ expect(@instance).to respond_to(:get_brute_force_protection_settings)
58
+ end
59
+
60
+ it 'is expected to get /api/v2/attack-protection/brute-force-protection' do
61
+ expect(@instance).to receive(:get).with(
62
+ '/api/v2/attack-protection/brute-force-protection'
63
+ )
64
+
65
+ expect { @instance.brute_force_protection }.not_to raise_error
66
+ end
67
+ end
68
+
69
+ context '.patch brute-force-protection' do
70
+ it 'responds to patch_brute-force-protection' do
71
+ expect(@instance).to respond_to(:patch_brute_force_protection)
72
+ end
73
+
74
+ it 'responds to update_brute_force_protection_settings' do
75
+ expect(@instance).to respond_to(:update_brute_force_protection_settings)
76
+ end
77
+
78
+ it 'is expected to respond to patch /api/v2/attack-protection/brute-force-protection' do
79
+ expect(@instance).to receive(:patch).with(
80
+ '/api/v2/attack-protection/brute-force-protection',
81
+ {
82
+ enabled: true
83
+ }
84
+ )
85
+
86
+ @instance.patch_brute_force_protection({
87
+ enabled: true
88
+ })
89
+ end
90
+ end
91
+
92
+ context '.get suspicious-ip-throttling' do
93
+ it 'responds to suspicious_ip_throttling' do
94
+ expect(@instance).to respond_to(:suspicious_ip_throttling)
95
+ end
96
+
97
+ it 'responds to get_suspicious_ip_throttling_settings' do
98
+ expect(@instance).to respond_to(:get_suspicious_ip_throttling_settings)
99
+ end
100
+
101
+ it 'is expected to get /api/v2/attack-protection/suspicious-ip-throttling' do
102
+ expect(@instance).to receive(:get).with(
103
+ '/api/v2/attack-protection/suspicious-ip-throttling'
104
+ )
105
+
106
+ expect { @instance.suspicious_ip_throttling }.not_to raise_error
107
+ end
108
+ end
109
+
110
+ context '.patch suspicious-ip-throttling' do
111
+ it 'responds to patch_suspicious_ip_throttling' do
112
+ expect(@instance).to respond_to(:patch_suspicious_ip_throttling)
113
+ end
114
+
115
+ it 'responds to update_suspicious_ip_throttling_settings' do
116
+ expect(@instance).to respond_to(:update_suspicious_ip_throttling_settings)
117
+ end
118
+
119
+ it 'is expected to patch /api/v2/attack-protection/suspicious-ip-throttling' do
120
+ expect(@instance).to receive(:patch).with(
121
+ '/api/v2/attack-protection/suspicious-ip-throttling',
122
+ {
123
+ enabled: true
124
+ }
125
+ )
126
+
127
+ @instance.patch_suspicious_ip_throttling({
128
+ enabled: true
129
+ })
130
+ end
131
+ end
132
+ end
@@ -9,7 +9,7 @@ describe Auth0::Api::V2::Blacklists do
9
9
  context '.blacklisted_tokens' do
10
10
  it { expect(@instance).to respond_to(:blacklisted_tokens) }
11
11
  it 'is expected to call /api/v2/blacklists/tokens' do
12
- expect(@instance).to receive(:get).with('/api/v2/blacklists/tokens', aud: nil)
12
+ expect(@instance).to receive(:get).with('/api/v2/blacklists/tokens', { aud: nil })
13
13
  expect { @instance.blacklisted_tokens }.not_to raise_error
14
14
  end
15
15
  end
@@ -17,7 +17,7 @@ describe Auth0::Api::V2::Blacklists do
17
17
  context '.add_token.to_blacklist' do
18
18
  it { expect(@instance).to respond_to(:add_token_to_blacklist) }
19
19
  it 'is expected to call post to /api/v2/blacklists/tokens' do
20
- expect(@instance).to receive(:post).with('/api/v2/blacklists/tokens', aud: 'aud', jti: 'jti')
20
+ expect(@instance).to receive(:post).with('/api/v2/blacklists/tokens', { aud: 'aud', jti: 'jti' })
21
21
  @instance.add_token_to_blacklist('jti', 'aud')
22
22
  end
23
23
  it { expect { @instance.add_token_to_blacklist('', '') }.to raise_error 'Must specify a valid JTI' }