auth0 4.6.0 → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/DEPLOYMENT.md +2 -1
  4. data/lib/auth0/api/v2/jobs.rb +43 -10
  5. data/lib/auth0/api/v2/resource_servers.rb +25 -0
  6. data/lib/auth0/api/v2/tickets.rb +26 -6
  7. data/lib/auth0/mixins/httpproxy.rb +8 -1
  8. data/lib/auth0/version.rb +1 -1
  9. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_export_users_and_get_job/should_create_an_export_users_job_successfully.yml +61 -0
  10. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_export_users_and_get_job/should_get_the_export_users_job.yml +117 -0
  11. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_import_users_and_get_job/should_create_an_import_users_job_successfully.yml +60 -0
  12. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_import_users_and_get_job/should_get_the_import_users_job.yml +116 -0
  13. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_send_verification_email_and_get_job/should_create_a_new_verification_email_job.yml +119 -0
  14. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_send_verification_email_and_get_job/should_get_the_completed_verification_email.yml +175 -0
  15. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_send_verification_email_and_get_job/should_reject_an_invalid_client_id.yml +109 -0
  16. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/delete_imported_user.yml +110 -0
  17. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/search_for_connection_id.yml +59 -0
  18. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_delete_resource_server/should_delete_the_test_server_without_an_error.yml +8 -8
  19. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_patch_resource_server/should_update_the_resource_server_with_the_correct_attributes.yml +61 -0
  20. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_server/should_get_the_test_server.yml +9 -14
  21. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_servers/should_get_the_test_server.yml +59 -0
  22. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_servers/should_return_at_least_1_result.yml +59 -0
  23. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_servers/should_return_the_first_page_of_one_result.yml +64 -0
  24. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/create_test_server.yml +7 -12
  25. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/delete_test_server.yml +8 -8
  26. data/spec/integration/lib/auth0/api/v2/api_email_spec.rb +2 -2
  27. data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +101 -60
  28. data/spec/integration/lib/auth0/api/v2/api_resource_servers_spec.rb +38 -0
  29. data/spec/lib/auth0/api/v2/jobs_spec.rb +48 -5
  30. data/spec/lib/auth0/api/v2/resource_servers_spec.rb +23 -0
  31. data/spec/lib/auth0/api/v2/tickets_spec.rb +10 -4
  32. data/spec/spec_helper.rb +1 -1
  33. metadata +35 -10
@@ -0,0 +1,64 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://auth0-sdk-tests.auth0.com/api/v2/resource-servers?page=0&per_page=1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - "*/*"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ User-Agent:
15
+ - rest-client/2.0.2 (darwin17.7.0 x86_64) ruby/2.5.1p57
16
+ Content-Type:
17
+ - application/json
18
+ Auth0-Client:
19
+ - eyJuYW1lIjoicnVieS1hdXRoMCIsInZlcnNpb24iOiI0LjYuMCIsImVudiI6eyJydWJ5IjoiMi41LjEifX0=
20
+ Authorization:
21
+ - Bearer API_TOKEN
22
+ Host:
23
+ - auth0-sdk-tests.auth0.com
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Date:
30
+ - Wed, 27 Feb 2019 20:44:26 GMT
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ Transfer-Encoding:
34
+ - chunked
35
+ Connection:
36
+ - keep-alive
37
+ Link:
38
+ - <http://auth0-sdk-tests.auth0.com/api/v2/resource-servers?page=0&per_page=1>;
39
+ rel="first", <http://auth0-sdk-tests.auth0.com/api/v2/resource-servers?page=1&per_page=1>;
40
+ rel="next", <http://auth0-sdk-tests.auth0.com/api/v2/resource-servers?page=2&per_page=1>;
41
+ rel="last"
42
+ X-Ratelimit-Limit:
43
+ - '10'
44
+ X-Ratelimit-Remaining:
45
+ - '8'
46
+ X-Ratelimit-Reset:
47
+ - '1551300268'
48
+ Vary:
49
+ - origin,accept-encoding
50
+ Cache-Control:
51
+ - private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
52
+ Content-Encoding:
53
+ - gzip
54
+ Strict-Transport-Security:
55
+ - max-age=15724800
56
+ X-Robots-Tag:
57
+ - noindex, nofollow, nosnippet, noarchive
58
+ body:
59
+ encoding: ASCII-8BIT
60
+ string: !binary |-
61
+ H4sIAAAAAAAAA5WYwW7bOBCGX4XQOa2dbJy0vqVJURTdAEGTnoqCoCXK4ZoWBZFyEBR996WoYSxTHFG9tZ75P838GlJkfv7ORJGtsxW7uGIfVh/ONx//uWar4nx1eb5cXn7MzrKK7bnNuGnN85Lcs4pt+Z5Xhtw8fLVRUdh/i1LwxuY8G1Pr9WLButx3uti9M1wb/d79/32u9gtWi8XhYmGFTEr1QlVZSlFxyvKca52tSyY1P8v0TtQ0V5W2cFqqhh54Yx/CNpLTUjTa0Jo15pXmUtiMo86oHa+oFCU3oqv6/PrqcrlchgGHfOGbbH190UW12Fai2lImt7aL748Xqytboc5VzS375++s4DpvRG2EqroEzgpy6x5NvjSsK+AsOzDZdj41Nrju66LbPvjnLCTc2izDUUbuwknKHZd8glK4cJLyoy6mamldOElxnvzQvBl50bof0eeGGngepoKeQxX0iqnA71AFPmOqY0/kpq7JPTfM1saiDVJW13TvM6a7xWjD1lO8oQ8Yb2hKijd0COMN7foLHnkS+Y7HBrwjUQNRxP9bWOLRFZacZ3SSk+sJXUnJ9Yyu5ESP5Bt/xXaSXRdKrd1Af7pyEcLpHhIQTncQhHC6lwWE050MIfQeqKrieffL2INBCPcgqvceTBK8B1GC92CS4D2IErwHkwTnwXeuVdvknDzy5hDZShuIUw1x1I0JElgygwW+TLDAnBkscGiCBTbNYDmv7vhBWI7luhOI/f6HbhUug+aDDNSvSRo4NosHnk3ywLVZPPBtkgfOzeL1c9ZKPh4u9yM+UYHGjxGi8rMTqPzAICo/JYHKjwaiOvbUrcBSbOO9dQdKF5zuMcIY9jpBGfYcoQx7n6C4bj7vmZDkoVEHe8BuwnZ4F6W1j6L9oBRoKMmBjlAOtJTkwHtFOfCCk5xPkuU7KbQhT92BfujuxofWpg8hzj4aNj5NaPcjonjilT302h3LGHtJGGmNC9vtCsLo28A58DrSJFfPv2pchFR4/uOz4LIY9ww/o29rrIPXhCthXsZKGBRc6Sq9qdSeyVe725n+S0k+SZXvRqWzPo9u+ihaxwweFJYk+nfYiO02+j01PoJN0VjZj09C507Q8Vtm6mIYl0LH0ze5Ly1rCsEqUrLcKHsl6PertmEuKywEsilk4/6F3LGPM1inFfKqUVLuY5eEN9YwB7UrQfS+zWPCGjomEbjnkFI1b48ar60IPnVD6u9sX+8eiAk3xbf7KRVFTdGNEYqtmdYvqilI/szznd2CyH9qE1n/Ps9+xSCR2kTUWB0HE1YVhElJhDXFn/oihs9+mjMjb7VRe1LY5SyqYGzHFwuXTCEZn4y5UH9XSGFvAcBJxV8CeuTikMK5xt23kxi+r6UVjVrtP63HMD6xKOfkIz1FgrWOk06OH1Mk19l9K43odwPS/RWyO9zmzntSKylyMe52XzL6FkML/DswFJ1Au4rtyo2cr9XkmTfU+DMvooLJDFX+jImooPFQ5c+3verXWSY01a/avpnMfp9a/ufX/33mRNkoFgAA
62
+ http_version:
63
+ recorded_at: Wed, 27 Feb 2019 20:44:28 GMT
64
+ recorded_with: VCR 4.0.0
@@ -12,13 +12,13 @@ http_interactions:
12
12
  Accept-Encoding:
13
13
  - gzip, deflate
14
14
  User-Agent:
15
- - Ruby/2.3.1
15
+ - rest-client/2.0.2 (darwin17.7.0 x86_64) ruby/2.5.1p57
16
16
  Content-Type:
17
17
  - application/json
18
18
  Auth0-Client:
19
- - eyJuYW1lIjoicnVieS1hdXRoMCIsInZlcnNpb24iOiI0LjUuMCJ9
19
+ - eyJuYW1lIjoicnVieS1hdXRoMCIsInZlcnNpb24iOiI0LjYuMCIsImVudiI6eyJydWJ5IjoiMi41LjEifX0=
20
20
  Authorization:
21
- - Bearer eyJ0eXAiOiJKV1QiLCJhbGc.eyJpc3MiOiJodHRwczovL2F1dGgwLXNkay10ZXN0cy5hdXRoMC5jb20vIiwic3ViIjoiQjRvUEhsMDA3VmExR0JkWlhpU0hhRUNVcVZXa2Q5WGtAY2xpZW50cyIsIm.PxfZjVd4wTb_bFbSTENdTmbj13CDQaPK352w3UNL3i3DnWcVJa6qSiA0hCr_tSU_uC34mHkK52O8tFVeZjxCYSeM9yOZUcKVya5N0I7G90X
21
+ - Bearer API_TOKEN
22
22
  Content-Length:
23
23
  - '176'
24
24
  Host:
@@ -29,7 +29,7 @@ http_interactions:
29
29
  message: Created
30
30
  headers:
31
31
  Date:
32
- - Fri, 05 Oct 2018 19:59:20 GMT
32
+ - Wed, 27 Feb 2019 20:44:25 GMT
33
33
  Content-Type:
34
34
  - application/json; charset=utf-8
35
35
  Transfer-Encoding:
@@ -41,7 +41,7 @@ http_interactions:
41
41
  X-Ratelimit-Remaining:
42
42
  - '9'
43
43
  X-Ratelimit-Reset:
44
- - '1538769562'
44
+ - '1551300266'
45
45
  Vary:
46
46
  - origin,accept-encoding
47
47
  Cache-Control:
@@ -55,12 +55,7 @@ http_interactions:
55
55
  body:
56
56
  encoding: ASCII-8BIT
57
57
  string: !binary |-
58
- H4sIAAAAAAAAA12Py07DMBBF/8VrIA+S5rGrEELdoIpWAlaW7YyTIa4d2UOr
59
- gvh3pmwqsZyZc0fnfgscRC9qrRtTdm07WKVVtTJVo7quaMWN8OoATOwh0Q7i
60
- EeJt/NRn4pGPOIAntAiRkYloSX2WuWCUm0KiuwuVqQWzY5ExnXD06EeZwEQg
61
- Tnxsh2LI9696bJbnDrfmbaB3etxsntZz/TUdHpBTyrlwksFahx6kMgZSEr1V
62
- LgG/nHGRJvjEHtKGKFmQfZR2IC3GRHJRkc7SOGTimqMwg5cOLRBe+hXlfVWv
63
- /u//Pp5Ai74p8/xaQLmR7V92Zb0SP7/OQVooQwEAAA==
58
+ H4sIAAAAAAAAA12PTU/DMAyG/0vOQNusH6y3CSG0C5rYJOAUpYnTmmVJlZhNA/Hf8bhM4mj7ea3n/RZoRS8a07Wu1ctO1mDKRSdtVd7rWoobEfQBmNhBpi2kI6Tb9DmciUc+ooVA6BASIxPRnPui8NFoP8VMdxeq0DMWx6pgOuMYMIwqg0lAnPjY2MqWu9dh7ObnJW7Mm6V3elyvn1b75ms6PCCntPfxpKJzHgMobQzkLHqnfQZ+ucdZmRgyeygXk2JB9tGDB+UwZVKzTnRWxiMT1xzFPQTl0QHhpV8lF3XT/t//fTzBIPpOluW1gPYj279sZdOKn19q2ZhOQwEAAA==
64
59
  http_version:
65
- recorded_at: Fri, 05 Oct 2018 19:59:20 GMT
60
+ recorded_at: Wed, 27 Feb 2019 20:44:27 GMT
66
61
  recorded_with: VCR 4.0.0
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: delete
5
- uri: https://auth0-sdk-tests.auth0.com/api/v2/resource-servers/5bb7c2988dfaba46c47a9918
5
+ uri: https://auth0-sdk-tests.auth0.com/api/v2/resource-servers/5c76f6a9724ec0372d108a42
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -12,13 +12,13 @@ http_interactions:
12
12
  Accept-Encoding:
13
13
  - gzip, deflate
14
14
  User-Agent:
15
- - Ruby/2.3.1
15
+ - rest-client/2.0.2 (darwin17.7.0 x86_64) ruby/2.5.1p57
16
16
  Content-Type:
17
17
  - application/json
18
18
  Auth0-Client:
19
- - eyJuYW1lIjoicnVieS1hdXRoMCIsInZlcnNpb24iOiI0LjUuMCJ9
19
+ - eyJuYW1lIjoicnVieS1hdXRoMCIsInZlcnNpb24iOiI0LjYuMCIsImVudiI6eyJydWJ5IjoiMi41LjEifX0=
20
20
  Authorization:
21
- - Bearer eyJ0eXAiOiJKV1QiLCJhbGc.eyJpc3MiOiJodHRwczovL2F1dGgwLXNkay10ZXN0cy5hdXRoMC5jb20vIiwic3ViIjoiQjRvUEhsMDA3VmExR0JkWlhpU0hhRUNVcVZXa2Q5WGtAY2xpZW50cyIsIm.PxfZjVd4wTb_bFbSTENdTmbj13CDQaPK352w3UNL3i3DnWcVJa6qSiA0hCr_tSU_uC34mHkK52O8tFVeZjxCYSeM9yOZUcKVya5N0I7G90X
21
+ - Bearer API_TOKEN
22
22
  Host:
23
23
  - auth0-sdk-tests.auth0.com
24
24
  response:
@@ -27,7 +27,7 @@ http_interactions:
27
27
  message: No Content
28
28
  headers:
29
29
  Date:
30
- - Fri, 05 Oct 2018 19:59:23 GMT
30
+ - Wed, 27 Feb 2019 20:44:27 GMT
31
31
  Content-Type:
32
32
  - application/json; charset=utf-8
33
33
  Connection:
@@ -35,9 +35,9 @@ http_interactions:
35
35
  X-Ratelimit-Limit:
36
36
  - '10'
37
37
  X-Ratelimit-Remaining:
38
- - '9'
38
+ - '6'
39
39
  X-Ratelimit-Reset:
40
- - '1538769565'
40
+ - '1551300270'
41
41
  Vary:
42
42
  - origin,accept-encoding
43
43
  Cache-Control:
@@ -50,5 +50,5 @@ http_interactions:
50
50
  encoding: UTF-8
51
51
  string: ''
52
52
  http_version:
53
- recorded_at: Fri, 05 Oct 2018 19:59:23 GMT
53
+ recorded_at: Wed, 27 Feb 2019 20:44:30 GMT
54
54
  recorded_with: VCR 4.0.0
@@ -40,7 +40,7 @@ describe Auth0::Api::V2::Emails do
40
40
  it 'should configure a new email provider' do
41
41
  begin
42
42
  expect(
43
- client.configure_provider(body).deep_symbolize_keys
43
+ JSON.parse(JSON[client.configure_provider(body)], symbolize_names: true)
44
44
  ).to include(body)
45
45
  rescue Auth0::Unsupported
46
46
  puts 'Email provider is already configured'
@@ -100,7 +100,7 @@ describe Auth0::Api::V2::Emails do
100
100
 
101
101
  it 'should update the existing email provider' do
102
102
  expect(
103
- client.update_provider(update_body).deep_symbolize_keys
103
+ JSON.parse(JSON[client.update_provider(update_body)], symbolize_names: true)
104
104
  ).to include(update_body)
105
105
  end
106
106
  end
@@ -1,71 +1,112 @@
1
1
  require 'spec_helper'
2
2
  describe Auth0::Api::V2::Jobs do
3
- skip "Jobs examples are skipped to avoid Job's creation" do
4
- let(:client) { Auth0Client.new(v2_creds) }
5
- let(:username) { Faker::Internet.user_name }
6
- let(:email) { "#{entity_suffix}#{Faker::Internet.safe_email(username)}" }
3
+ UP_AUTH = Auth0::Api::AuthenticationEndpoints::UP_AUTH
7
4
 
8
- describe '.import_users and .get_job' do
9
- let(:file_content) do
10
- [{
11
- 'email' => email,
12
- 'email_verified' => false,
13
- 'app_metadata' => {
14
- 'roles' => ['admin'],
15
- 'plan' => 'premium'
16
- },
17
- 'user_metadata' => {
18
- 'theme' => 'light'
19
- }
20
- }]
21
- end
22
- let(:users_file) do
23
- File.new('temp.json', 'w+') { |f| f.write(file_content) }
24
- end
25
- let(:connection_id) do
26
- client.connections
27
- .find do |connection|
28
- connection['name'].include?(Auth0::Api::AuthenticationEndpoints::UP_AUTH)
29
- end['id']
30
- end
31
- let(:imported_users) { client.import_users(users_file, connection_id) }
32
- it do
33
- expect(imported_users).to include(
34
- 'connection' => Auth0::Api::AuthenticationEndpoints::UP_AUTH,
35
- 'status' => 'pending',
36
- 'type' => 'users_import'
37
- )
38
- end
39
- let(:import_job_id) { imported_users['id'] }
40
- it do
41
- expect(client.get_job(import_job_id)).to include(
42
- 'connection' => Auth0::Api::AuthenticationEndpoints::UP_AUTH, 'type' => 'users_import', 'id' => import_job_id
43
- )
44
- end
5
+ let(:client) { Auth0Client.new(v2_creds) }
6
+ let(:username) { Faker::Internet.user_name }
7
+ let(:email) { "#{entity_suffix}#{Faker::Internet.safe_email(username)}" }
8
+ let(:connection_id) do
9
+ VCR.use_cassette('Auth0_Api_V2_Jobs/search_for_connection_id') do
10
+ client.connections.find do |connection|
11
+ connection['name'].include?(UP_AUTH)
12
+ end['id']
45
13
  end
14
+ end
15
+
16
+ describe '.import_users and .get_job', vcr: true do
17
+ let(:file_name) { 'spec/fixtures/api-jobs-spec-import-users.json' }
18
+ let(:file_content) do
19
+ [{
20
+ email: email,
21
+ email_verified: false,
22
+ app_metadata: { roles: ['admin'] },
23
+ user_metadata: { theme: 'light' }
24
+ }].to_json
25
+ end
26
+ let(:import_file) do
27
+ File.open(file_name, 'w+') { |f| f.write(file_content) }
28
+ File.new(file_name, 'rb')
29
+ end
30
+ let(:imported_users) { client.import_users(import_file, connection_id) }
31
+ let(:import_job_id) { imported_users['id'] }
32
+
33
+ it 'should create an import users job successfully' do
34
+ expect(imported_users).to include(
35
+ 'connection' => UP_AUTH,
36
+ 'type' => 'users_import'
37
+ )
38
+ end
39
+
40
+ it 'should get the import users job' do
41
+ expect(client.get_job(import_job_id)).to include(
42
+ 'connection' => UP_AUTH,
43
+ 'type' => 'users_import',
44
+ 'id' => import_job_id
45
+ )
46
+ end
47
+
48
+ after do
49
+ File.delete(file_name)
50
+ end
51
+ end
52
+
53
+ describe '.export_users and .get_job', vcr: true do
54
+ let(:exported_users) { client.export_users(connection_id: connection_id) }
55
+ let(:export_job_id) { exported_users['id'] }
46
56
 
47
- describe '.send_verification_email and .get_job' do
48
- let(:user) do
49
- client.create_user(username, 'email' => email,
50
- 'password' => Faker::Internet.password,
51
- 'email_verified' => false,
52
- 'connection' => Auth0::Api::AuthenticationEndpoints::UP_AUTH,
53
- 'app_metadata' => {})
54
- end
55
- let(:email_verification_job) { client.send_verification_email(user['user_id']) }
56
- it { expect(email_verification_job).to include('status' => 'pending', 'type' => 'verification_email') }
57
- let(:email_job_id) { email_verification_job['id'] }
58
- it do
59
- expect(client.get_job(email_job_id)).to include(
60
- 'status' => 'completed', 'type' => 'verification_email', 'id' => email_job_id
61
- )
62
- end
57
+ it 'should create an export users job successfully' do
58
+ expect(exported_users).to include(
59
+ 'connection' => UP_AUTH,
60
+ 'type' => 'users_export'
61
+ )
63
62
  end
64
63
 
65
- after(:all) do
64
+ it 'should get the export users job' do
65
+ expect(client.get_job(export_job_id)).to include(
66
+ 'connection' => UP_AUTH,
67
+ 'type' => 'users_export',
68
+ 'id' => export_job_id
69
+ )
70
+ end
71
+ end
72
+
73
+ describe '.send_verification_email and .get_job', vcr: true do
74
+ let(:user) do
75
+ client.create_user(
76
+ username,
77
+ 'email' => email,
78
+ 'password' => Faker::Internet.password,
79
+ 'connection' => UP_AUTH
80
+ )
81
+ end
82
+ let(:email_verification_job) { client.send_verification_email(user['user_id']) }
83
+ let(:email_job_id) { email_verification_job['id'] }
84
+
85
+ it 'should create a new verification_email job' do
86
+ expect(
87
+ email_verification_job
88
+ ).to include('status' => 'pending', 'type' => 'verification_email')
89
+ end
90
+
91
+ it 'should get the completed verification_email' do
92
+ expect(client.get_job(email_job_id)).to include(
93
+ 'type' => 'verification_email',
94
+ 'id' => email_job_id
95
+ )
96
+ end
97
+
98
+ it 'should reject an invalid client_id' do
99
+ expect do
100
+ client.send_verification_email(user['user_id'], Random.new(32).to_s)
101
+ end.to raise_error Auth0::BadRequest
102
+ end
103
+ end
104
+
105
+ after(:all) do
106
+ VCR.use_cassette('Auth0_Api_V2_Jobs/delete_imported_user') do
66
107
  new_client = Auth0Client.new(v2_creds)
67
- delete_user_id = new_client.get_users(q: 'email:@example.com').first['user_id']
68
- new_client.delete_user(delete_user_id)
108
+ delete_user = new_client.get_users(q: "email:#{entity_suffix}*").first
109
+ new_client.delete_user(delete_user['user_id']) unless delete_user.nil?
69
110
  end
70
111
  end
71
112
  end
@@ -22,6 +22,28 @@ describe Auth0::Api::V2::ResourceServers do
22
22
  end
23
23
  end
24
24
 
25
+ describe '.resource_servers', vcr: true do
26
+ let(:resource_servers) do
27
+ client.resource_servers
28
+ end
29
+
30
+ it 'should return at least 1 result' do
31
+ expect(resource_servers.size).to be > 0
32
+ end
33
+
34
+ it 'should get the test server' do
35
+ expect(resource_servers).to include(test_server)
36
+ end
37
+
38
+ it 'should return the first page of one result' do
39
+ results = client.resource_servers(
40
+ page: 0,
41
+ per_page: 1
42
+ )
43
+ expect(results.first).to equal(results.last)
44
+ end
45
+ end
46
+
25
47
  describe '.create_resource_server', vcr: true do
26
48
  it 'should raise an error if the identifier is empty' do
27
49
  expect do
@@ -76,6 +98,21 @@ describe Auth0::Api::V2::ResourceServers do
76
98
  end
77
99
  end
78
100
 
101
+ describe '.patch_resource_server', vcr: true do
102
+ it 'should update the resource server with the correct attributes' do
103
+ expect(
104
+ client.patch_resource_server(
105
+ test_server['id'],
106
+ token_lifetime: 654321,
107
+ )
108
+ ).to(
109
+ include(
110
+ 'token_lifetime' => 654321,
111
+ )
112
+ )
113
+ end
114
+ end
115
+
79
116
  describe '.delete_resource_server', vcr: true do
80
117
  it 'should raise an error if the id is empty' do
81
118
  expect do
@@ -89,4 +126,5 @@ describe Auth0::Api::V2::ResourceServers do
89
126
  end.to_not raise_error
90
127
  end
91
128
  end
129
+
92
130
  end
@@ -24,13 +24,56 @@ describe Auth0::Api::V2::Jobs do
24
24
  it { expect { @instance.import_users('', 'connnection_id') }.to raise_error('Must specify a valid file') }
25
25
  it { expect { @instance.import_users('users', '') }.to raise_error('Must specify a connection_id') }
26
26
  end
27
+ context '.export_users' do
28
+ it { expect(@instance).to respond_to(:export_users) }
29
+ it { expect { @instance.export_users }.not_to raise_error }
30
+ it 'sends post to /api/v2/jobs/users-exports with correct params' do
31
+ expect(@instance).to receive(:post).with(
32
+ '/api/v2/jobs/users-exports',
33
+ fields: [{ name: 'author' }],
34
+ connection_id: 'test-connection',
35
+ format: 'csv',
36
+ limit: 10
37
+ )
38
+ @instance.export_users(
39
+ fields: ['author'],
40
+ connection_id: 'test-connection',
41
+ format: 'csv',
42
+ limit: 10
43
+ )
44
+ end
45
+ end
27
46
 
28
47
  context '.send_verification_email' do
29
- it { expect(@instance).to respond_to(:send_verification_email) }
30
- it 'expect client to send post to /api/v2/jobs/verification-email' do
31
- expect(@instance).to receive(:post).with('/api/v2/jobs/verification-email', user_id: 'user_id')
32
- expect { @instance.send_verification_email('user_id') }.not_to raise_error
48
+ it 'should respond to a send_verification_email method' do
49
+ expect(@instance).to respond_to(:send_verification_email)
50
+ end
51
+
52
+ it 'should post to the jobs email verification endpoint' do
53
+ expect(@instance).to receive(:post).with(
54
+ '/api/v2/jobs/verification-email',
55
+ user_id: 'test_user_id'
56
+ )
57
+ expect do
58
+ @instance.send_verification_email('test_user_id')
59
+ end.not_to raise_error
60
+ end
61
+
62
+ it 'should post to the jobs email verification endpoint with a client_id' do
63
+ expect(@instance).to receive(:post).with(
64
+ '/api/v2/jobs/verification-email',
65
+ user_id: 'test_user_id',
66
+ client_id: 'test_client_id'
67
+ )
68
+ expect do
69
+ @instance.send_verification_email('test_user_id', 'test_client_id')
70
+ end.not_to raise_error
71
+ end
72
+
73
+ it 'should raise an error if the user_id is empty' do
74
+ expect do
75
+ @instance.send_verification_email('')
76
+ end.to raise_error('Must specify a user id')
33
77
  end
34
- it { expect { @instance.send_verification_email('') }.to raise_error('Must specify a user id') }
35
78
  end
36
79
  end