auth0 3.6.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.rubocop.yml +7 -0
  4. data/.rubocop_todo.yml +7 -0
  5. data/.travis.yml +12 -7
  6. data/CHANGELOG.md +10 -0
  7. data/Gemfile +4 -2
  8. data/Guardfile +13 -10
  9. data/LICENSE +2 -2
  10. data/README.md +9 -11
  11. data/Rakefile +33 -7
  12. data/auth0.gemspec +12 -12
  13. data/deploy_documentation.sh +29 -0
  14. data/doc_config/templates/default/fulldoc/html/css/full_list.css +79 -0
  15. data/doc_config/templates/default/fulldoc/html/css/style.css +546 -0
  16. data/doc_config/templates/default/layout/html/breadcrumb.erb +11 -0
  17. data/doc_config/templates/default/layout/html/footer.erb +115 -0
  18. data/doc_config/templates/default/layout/html/headers.erb +17 -0
  19. data/doc_config/templates/default/layout/html/layout.erb +27 -0
  20. data/lib/auth0.rb +5 -5
  21. data/lib/auth0/api/authentication_endpoints.rb +264 -46
  22. data/lib/auth0/api/v1.rb +5 -5
  23. data/lib/auth0/api/v1/clients.rb +7 -7
  24. data/lib/auth0/api/v1/connections.rb +9 -10
  25. data/lib/auth0/api/v1/logs.rb +9 -16
  26. data/lib/auth0/api/v1/rules.rb +5 -5
  27. data/lib/auth0/api/v1/users.rb +28 -27
  28. data/lib/auth0/api/v2.rb +17 -9
  29. data/lib/auth0/api/v2/blacklists.rb +30 -9
  30. data/lib/auth0/api/v2/clients.rb +60 -19
  31. data/lib/auth0/api/v2/connections.rb +63 -10
  32. data/lib/auth0/api/v2/emails.rb +58 -0
  33. data/lib/auth0/api/v2/jobs.rb +44 -7
  34. data/lib/auth0/api/v2/rules.rb +104 -0
  35. data/lib/auth0/api/v2/stats.rb +22 -5
  36. data/lib/auth0/api/v2/tenants.rb +39 -0
  37. data/lib/auth0/api/v2/tickets.rb +58 -0
  38. data/lib/auth0/api/v2/users.rb +128 -39
  39. data/lib/auth0/client.rb +8 -6
  40. data/lib/auth0/exception.rb +29 -23
  41. data/lib/auth0/mixins.rb +12 -10
  42. data/lib/auth0/mixins/httparty_proxy.rb +13 -10
  43. data/lib/auth0/mixins/initializer.rb +25 -27
  44. data/lib/auth0/version.rb +2 -2
  45. data/spec/integration/lib/auth0/api/v1/api_clients_spec.rb +2 -4
  46. data/spec/integration/lib/auth0/api/v1/api_users_spec.rb +25 -32
  47. data/spec/integration/lib/auth0/api/v2/api_blacklist_spec.rb +14 -0
  48. data/spec/integration/lib/auth0/api/v2/api_clients_spec.rb +61 -6
  49. data/spec/integration/lib/auth0/api/v2/api_connections_spec.rb +68 -42
  50. data/spec/integration/lib/auth0/api/v2/api_email_spec.rb +71 -0
  51. data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +69 -0
  52. data/spec/integration/lib/auth0/api/v2/api_rules_spec.rb +83 -0
  53. data/spec/integration/lib/auth0/api/v2/api_stats_spec.rb +16 -0
  54. data/spec/integration/lib/auth0/api/v2/api_tenants_spec.rb +37 -0
  55. data/spec/integration/lib/auth0/api/v2/api_tickets_spec.rb +33 -0
  56. data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +88 -36
  57. data/spec/integration/lib/auth0/auth0_client_spec.rb +43 -35
  58. data/spec/lib/auth0/api/authentication_endpoints_spec.rb +253 -47
  59. data/spec/lib/auth0/api/v1/clients_spec.rb +37 -38
  60. data/spec/lib/auth0/api/v1/connections_spec.rb +44 -38
  61. data/spec/lib/auth0/api/v1/logs_spec.rb +24 -24
  62. data/spec/lib/auth0/api/v1/rules_spec.rb +23 -22
  63. data/spec/lib/auth0/api/v1/users_spec.rb +153 -130
  64. data/spec/lib/auth0/api/v2/blacklists_spec.rb +12 -11
  65. data/spec/lib/auth0/api/v2/clients_spec.rb +38 -33
  66. data/spec/lib/auth0/api/v2/connections_spec.rb +59 -34
  67. data/spec/lib/auth0/api/v2/emails_spec.rb +47 -0
  68. data/spec/lib/auth0/api/v2/jobs_spec.rb +24 -10
  69. data/spec/lib/auth0/api/v2/rules_spec.rb +69 -0
  70. data/spec/lib/auth0/api/v2/stats_spec.rb +11 -11
  71. data/spec/lib/auth0/api/v2/tenants_spec.rb +25 -0
  72. data/spec/lib/auth0/api/v2/tickets_spec.rb +31 -0
  73. data/spec/lib/auth0/api/v2/users_spec.rb +101 -39
  74. data/spec/lib/auth0/client_spec.rb +46 -58
  75. data/spec/lib/auth0/mixins/httparty_proxy_spec.rb +98 -69
  76. data/spec/lib/auth0/mixins/initializer_spec.rb +2 -2
  77. data/spec/spec_helper.rb +2 -2
  78. data/spec/spec_helper_full.rb +16 -15
  79. data/spec/spec_helper_unit.rb +5 -5
  80. data/spec/support/credentials.rb +9 -3
  81. data/spec/support/dummy_class.rb +7 -1
  82. data/spec/support/dummy_class_for_proxy.rb +2 -2
  83. data/spec/support/import_users.json +13 -0
  84. data/spec/support/stub_response.rb +1 -2
  85. metadata +78 -41
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ describe Auth0::Api::V2::Tenants do
3
+ before :all do
4
+ @instance = DummyClass.new.extend(Auth0::Api::V2::Tenants)
5
+ end
6
+
7
+ context '.get_tenant_settings' do
8
+ it { expect(@instance).to respond_to(:get_tenant_settings) }
9
+ it 'expect client to send post to /api/v2/tenants/settings with fields' do
10
+ expect(@instance).to receive(:get).with('/api/v2/tenants/settings', fields: 'field', include_fields: true)
11
+ expect { @instance.get_tenant_settings(fields: 'field') }.not_to raise_error
12
+ end
13
+ end
14
+ context '.update_tenant_settings' do
15
+ it { expect(@instance).to respond_to(:update_tenant_settings) }
16
+ it 'expect client to send post to /api/v2/tenants/settings with body' do
17
+ expect(@instance).to receive(:patch).with('/api/v2/tenants/settings', 'test body')
18
+ expect { @instance.update_tenant_settings('test body') }.not_to raise_error
19
+ end
20
+ it 'expect client to rasie error when calling with empty body' do
21
+ expect { @instance.update_tenant_settings(nil) }.to raise_error(
22
+ 'Must supply a valid body to update tenant settings')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+ describe Auth0::Api::V2::Tickets do
3
+ before :all do
4
+ @instance = DummyClass.new.extend(Auth0::Api::V2::Tickets)
5
+ end
6
+
7
+ context '.post_email_verification' do
8
+ it { expect(@instance).to respond_to(:post_email_verification) }
9
+ it 'expect client to send post to /api/v2/tickets/email-verification with body' do
10
+ expect(@instance).to receive(:post).with('/api/v2/tickets/email-verification', user_id: 'user_id', result_url: nil)
11
+ expect { @instance.post_email_verification('user_id') }.not_to raise_error
12
+ end
13
+ it 'expect client to rasie error when calling with empty body' do
14
+ expect { @instance.post_email_verification(nil) }.to raise_error(
15
+ 'Must supply a valid user id to post an email verification')
16
+ end
17
+ end
18
+ context '.post_password_change' do
19
+ it { expect(@instance).to respond_to(:post_password_change) }
20
+ it 'expect client to send post to /api/v2/tickets/password-change with body' do
21
+ expect(@instance).to receive(:post).with('/api/v2/tickets/password-change', user_id: nil, result_url: nil,
22
+ new_password: 'new_pass',
23
+ connection_id: nil, email: nil)
24
+ expect { @instance.post_password_change('new_pass') }.not_to raise_error
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')
29
+ end
30
+ end
31
+ end
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
  describe Auth0::Api::V2::Users do
3
3
  before :all do
4
4
  dummy_instance = DummyClass.new
@@ -6,67 +6,129 @@ describe Auth0::Api::V2::Users do
6
6
  @instance = dummy_instance
7
7
  end
8
8
 
9
- context ".users" do
10
- it {expect(@instance).to respond_to(:users)}
11
- it {expect(@instance).to respond_to(:get_users)}
12
- it "is expected to call /api/v2/users" do
13
- expect(@instance).to receive(:get).with("/api/v2/users",{:per_page=>nil, :page=>nil, :include_totals=>nil, :sort=>nil, :connection=>nil, :fields=>nil, :q=>nil})
14
- expect{@instance.users}.not_to raise_error
9
+ context '.users' do
10
+ it { expect(@instance).to respond_to(:users) }
11
+ it { expect(@instance).to respond_to(:get_users) }
12
+ it 'is expected to call /api/v2/users' do
13
+ expect(@instance).to receive(:get).with(
14
+ '/api/v2/users',
15
+ per_page: nil,
16
+ page: nil,
17
+ include_totals: nil,
18
+ sort: nil,
19
+ connection: nil,
20
+ fields: nil,
21
+ include_fields: nil,
22
+ q: nil)
23
+ expect { @instance.users }.not_to raise_error
15
24
  end
16
25
  end
17
26
 
18
- context ".user" do
19
- it {expect(@instance).to respond_to(:user)}
20
- it "is expected to call get request to /api/v2/users/USER_ID" do
21
- expect(@instance).to receive(:get).with("/api/v2/users/USER_ID", {fields: nil})
22
- expect{@instance.user("USER_ID")}.not_to raise_error
27
+ context '.user' do
28
+ it { expect(@instance).to respond_to(:user) }
29
+ it 'is expected to call get request to /api/v2/users/USER_ID' do
30
+ expect(@instance).to receive(:get).with('/api/v2/users/USER_ID', fields: nil, include_fields: true)
31
+ expect { @instance.user('USER_ID') }.not_to raise_error
23
32
  end
33
+ it { expect { @instance.user('') }.to raise_error 'Must supply a valid user_id' }
24
34
  end
25
35
 
26
-
27
- context ".create_user" do
28
- it {expect(@instance).to respond_to(:create_user)}
29
- it "is expected to call post to /api/v2/users" do
30
- expect(@instance).to receive(:post).with("/api/v2/users", {email: "test@test.com", password: "password", connection: "conn", name:"name"})
31
- @instance.create_user("name", {email:"test@test.com",password: "password", connection: "conn"})
36
+ context '.create_user' do
37
+ it { expect(@instance).to respond_to(:create_user) }
38
+ it 'is expected to call post to /api/v2/users' do
39
+ expect(@instance).to receive(:post).with(
40
+ '/api/v2/users',
41
+ email: 'test@test.com',
42
+ password: 'password',
43
+ connection: 'conn',
44
+ name: 'name')
45
+ @instance.create_user(
46
+ 'name',
47
+ email: 'test@test.com',
48
+ password: 'password',
49
+ connection: 'conn')
32
50
  end
33
51
  end
34
52
 
35
- context ".delete_users" do
36
- it {expect(@instance).to respond_to :delete_users}
37
- it "is expected to call delete to /api/v2/users" do
38
- expect(@instance).to receive(:delete).with("/api/v2/users")
53
+ context '.delete_users' do
54
+ it { expect(@instance).to respond_to :delete_users }
55
+ it 'is expected to call delete to /api/v2/users' do
56
+ expect(@instance).to receive(:delete).with('/api/v2/users')
39
57
  @instance.delete_users
40
58
  end
41
59
  end
42
60
 
43
- context ".delete_user" do
44
- it {expect(@instance).to respond_to(:delete_user)}
45
- it "is expected to call delete to /api/v2/users/userId" do
46
- expect(@instance).to receive(:delete).with("/api/v2/users/userId")
47
- @instance.delete_user("userId")
61
+ context '.delete_user' do
62
+ it { expect(@instance).to respond_to(:delete_user) }
63
+ it 'is expected to call delete to /api/v2/users/userId' do
64
+ expect(@instance).to receive(:delete).with('/api/v2/users/userId')
65
+ @instance.delete_user('userId')
48
66
  end
49
67
 
50
- it "is expected not to call delete to /api/v2/users if user_id is blank" do
68
+ it 'is expected not to call delete to /api/v2/users if user_id is blank' do
51
69
  expect(@instance).not_to receive(:delete)
52
- expect{@instance.delete_user("")}.to raise_exception(Auth0::MissingUserId)
70
+ expect { @instance.delete_user('') }.to raise_exception(
71
+ Auth0::MissingUserId)
72
+ end
73
+ end
74
+
75
+ context '.delete_user_provider' do
76
+ it { expect(@instance).to respond_to(:delete_user_provider) }
77
+ it 'is expected to call delete to /api/v2/users/userId/multifactor/provider' do
78
+ expect(@instance).to receive(:delete).with('/api/v2/users/userId/multifactor/provider')
79
+ @instance.delete_user_provider('userId', 'provider')
80
+ end
81
+ end
82
+
83
+ context '.patch_user' do
84
+ it { expect(@instance).to respond_to(:patch_user) }
85
+ it 'is expected to call patch to /api/v2/users/userID' do
86
+ expect(@instance).to receive(:patch).with(
87
+ '/api/v2/users/UserID',
88
+ email: 'test@test.com',
89
+ password: 'password',
90
+ connection: 'conn',
91
+ name: 'name')
92
+ @instance.patch_user(
93
+ 'UserID',
94
+ email: 'test@test.com',
95
+ password: 'password',
96
+ connection: 'conn',
97
+ name: 'name')
53
98
  end
99
+ it { expect { @instance.patch_user('', 'body') }.to raise_error 'Must supply a valid user_id' }
100
+ it { expect { @instance.patch_user('UserId', '') }.to raise_error 'Must supply a valid body' }
54
101
  end
55
102
 
56
- context ".delete_user_provider" do
57
- it {expect(@instance).to respond_to(:delete_user_provider)}
58
- it "is expected to call delete to /api/v2/users/userId/multifactor/provider" do
59
- expect(@instance).to receive(:delete).with("/api/v2/users/userId/multifactor/provider")
60
- @instance.delete_user_provider("userId", "provider")
103
+ context '.link_user_account' do
104
+ it { expect(@instance).to respond_to(:link_user_account) }
105
+ it 'is expected to call post to /api/v2/users/UserId/identities' do
106
+ expect(@instance).to receive(:post).with('/api/v2/users/UserID/identities', body: 'json body')
107
+ @instance.link_user_account('UserID', body: 'json body')
61
108
  end
109
+ it { expect { @instance.link_user_account('', 'body') }.to raise_error 'Must supply a valid user_id' }
110
+ it { expect { @instance.link_user_account('UserId', '') }.to raise_error 'Must supply a valid body' }
62
111
  end
63
112
 
64
- context ".patch_user" do
65
- it {expect(@instance).to respond_to(:patch_user)}
66
- it "is expected to call patch to /api/v2/users/userID" do
67
- expect(@instance).to receive(:patch).with("/api/v2/users/UserID", {email: "test@test.com", password: "password", connection: "conn", name:"name"})
68
- @instance.patch_user("UserID", {email:"test@test.com",password: "password", connection: "conn", name:"name"})
113
+ context '.unlink_users_account' do
114
+ it { expect(@instance).to respond_to(:unlink_users_account) }
115
+ it 'is expected to call delete to /api/v2/users/UserId/identities' do
116
+ expect(@instance).to receive(:delete).with('/api/v2/users/UserID/identities/provider_name/Secondary_User_ID')
117
+ @instance.unlink_users_account('UserID', 'provider_name', 'Secondary_User_ID')
118
+ end
119
+ it { expect { @instance.unlink_users_account('', 'pro', 'SUserID') }.to raise_error 'Must supply a valid user_id' }
120
+ it { expect { @instance.unlink_users_account('UID', nil, 'SUID') }.to raise_error 'Must supply a valid provider' }
121
+ it do
122
+ expect { @instance.unlink_users_account('UID', 'pro', nil) }.to raise_error 'Must supply a valid secondary user_id'
69
123
  end
70
124
  end
71
125
 
126
+ context '.delete_user_provider' do
127
+ it { expect(@instance).to respond_to(:delete_user_provider) }
128
+ it 'is expected to call delete to /api/v2/users/User_ID/multifactor/provider_name' do
129
+ expect(@instance).to receive(:delete).with('/api/v2/users/User_ID/multifactor/provider_name')
130
+ @instance.delete_user_provider('User_ID', 'provider_name')
131
+ end
132
+ it { expect { @instance.delete_user_provider(nil, 'test') }.to raise_error 'Must supply a valid user_id' }
133
+ end
72
134
  end
@@ -1,8 +1,7 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Auth0::Client do
4
-
5
- shared_examples_for "v1 API client" do
4
+ shared_examples_for 'v1 API client' do
6
5
  it { should be_a Auth0::Api::V1 }
7
6
  it { should be_a Auth0::Api::V1::Users }
8
7
  it { should be_a Auth0::Api::V1::Connections }
@@ -17,7 +16,7 @@ describe Auth0::Client do
17
16
  it { should_not be_a Auth0::Api::V2::Blacklists }
18
17
  end
19
18
 
20
- shared_examples_for "v2 API client" do
19
+ shared_examples_for 'v2 API client' do
21
20
  it { should be_a Auth0::Api::V2 }
22
21
  it { should be_a Auth0::Api::V2::Clients }
23
22
  it { should be_a Auth0::Api::V2::Users }
@@ -32,84 +31,73 @@ describe Auth0::Client do
32
31
  it { should_not be_a Auth0::Api::V1::Logs }
33
32
  end
34
33
 
35
- shared_examples_for "authentication API client" do
34
+ shared_examples_for 'authentication API client' do
36
35
  it { should be_a Auth0::Api::AuthenticationEndpoints }
37
36
  end
38
37
 
39
- let(:domain) { "samples.auth0.com" }
40
- let(:client_id) { "client_id" }
41
- let(:client_secret) { "client_secret" }
42
- let(:jwt) { "Header.Payload.Signature" }
43
- let(:access_token) { "token" }
44
-
45
- describe "V1 client" do
38
+ let(:domain) { 'samples.auth0.com' }
39
+ let(:client_id) { 'client_id' }
40
+ let(:client_secret) { 'client_secret' }
41
+ let(:jwt) { 'Header.Payload.Signature' }
42
+ let(:access_token) { 'token' }
46
43
 
44
+ describe 'V1 client' do
47
45
  before :each do
48
- allow_any_instance_of(Auth0::Api::AuthenticationEndpoints).to receive(:obtain_access_token).and_return "token"
46
+ allow_any_instance_of(Auth0::Api::AuthenticationEndpoints).to receive(:obtain_access_token).and_return 'token'
49
47
  end
50
48
 
51
- context "with namespace" do
52
-
53
- let(:subject) { Auth0::Client.new(client_id: "client_id", client_secret: "client_secret", namespace: "samples.auth0.com") }
54
-
55
- it_should_behave_like "v1 API client"
56
- it_should_behave_like "authentication API client"
49
+ context 'with namespace' do
50
+ let(:subject) do
51
+ Auth0::Client.new(client_id: 'client_id', client_secret: 'client_secret', namespace: 'samples.auth0.com')
52
+ end
57
53
 
54
+ it_should_behave_like 'v1 API client'
55
+ it_should_behave_like 'authentication API client'
58
56
  end
59
57
 
60
- context "with domain" do
61
-
62
- let(:subject) { Auth0::Client.new(client_id: "client_id", client_secret: "client_secret", domain: "samples.auth0.com") }
63
-
64
- it_should_behave_like "v1 API client"
65
- it_should_behave_like "authentication API client"
58
+ context 'with domain' do
59
+ let(:subject) do
60
+ Auth0::Client.new(client_id: 'client_id', client_secret: 'client_secret', domain: 'samples.auth0.com')
61
+ end
66
62
 
63
+ it_should_behave_like 'v1 API client'
64
+ it_should_behave_like 'authentication API client'
67
65
  end
68
66
 
69
- context "with version" do
70
-
71
- let(:subject) { Auth0::Client.new(client_id: "client_id", client_secret: "client_secret", domain: "samples.auth0.com", api_version: 1) }
72
-
73
- it_should_behave_like "v1 API client"
74
- it_should_behave_like "authentication API client"
75
-
67
+ context 'with version' do
68
+ let(:subject) do
69
+ Auth0::Client.new(
70
+ client_id: 'client_id',
71
+ client_secret: 'client_secret',
72
+ domain: 'samples.auth0.com',
73
+ api_version: 1)
74
+ end
75
+ it_should_behave_like 'v1 API client'
76
+ it_should_behave_like 'authentication API client'
76
77
  end
77
-
78
78
  end
79
79
 
80
- describe "V2 client" do
81
-
80
+ describe 'V2 client' do
82
81
  before :each do
83
82
  expect_any_instance_of(Auth0::Api::AuthenticationEndpoints).not_to receive(:obtain_access_token)
84
83
  end
85
84
 
86
- context "with namespace" do
87
-
88
- let(:subject) { Auth0::Client.new(protocols: "v2", access_token: "access_token", namespace: "samples.auth0.com") }
89
-
90
- it_should_behave_like "v2 API client"
91
- it_should_behave_like "authentication API client"
92
-
85
+ context 'with namespace' do
86
+ let(:subject) { Auth0::Client.new(protocols: 'v2', access_token: 'access_token', namespace: 'samples.auth0.com') }
87
+ it_should_behave_like 'v2 API client'
88
+ it_should_behave_like 'authentication API client'
93
89
  end
94
90
 
95
- context "with domain" do
96
-
97
- let(:subject) { Auth0::Client.new(protocols: "v2", access_token: "access_token", domain: "samples.auth0.com") }
98
-
99
- it_should_behave_like "v2 API client"
100
- it_should_behave_like "authentication API client"
101
-
91
+ context 'with domain' do
92
+ let(:subject) { Auth0::Client.new(protocols: 'v2', access_token: 'access_token', domain: 'samples.auth0.com') }
93
+ it_should_behave_like 'v2 API client'
94
+ it_should_behave_like 'authentication API client'
102
95
  end
103
96
 
104
- context "with version" do
105
-
106
- let(:subject) { Auth0::Client.new(api_version: 2, access_token: "access_token", domain: "samples.auth0.com") }
107
-
108
- it_should_behave_like "v2 API client"
109
- it_should_behave_like "authentication API client"
110
-
97
+ context 'with version' do
98
+ let(:subject) { Auth0::Client.new(api_version: 2, access_token: 'access_token', domain: 'samples.auth0.com') }
99
+ it_should_behave_like 'v2 API client'
100
+ it_should_behave_like 'authentication API client'
111
101
  end
112
-
113
102
  end
114
-
115
103
  end
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
  describe Auth0::Mixins::HTTPartyProxy do
3
3
  before :all do
4
4
  dummy_instance = DummyClassForProxy.new
@@ -8,111 +8,140 @@ describe Auth0::Mixins::HTTPartyProxy do
8
8
 
9
9
  %i(get).each do |http_method|
10
10
  context ".#{http_method}" do
11
- it {expect(@instance).to respond_to(http_method.to_sym)}
11
+ it { expect(@instance).to respond_to(http_method.to_sym) }
12
12
  it "should call send http #{http_method} method to path defined through HTTParty" do
13
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :query => {})
14
- expect(DummyClassForProxy).to receive(http_method).with("/test", :query => {}).and_return(StubResponse.new({}, true, 200))
15
- expect{@instance.send(http_method,"/test")}.not_to raise_error
13
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', query: {})
14
+ expect(DummyClassForProxy).to receive(http_method).with('/test', query: {})
15
+ .and_return(StubResponse.new({}, true, 200))
16
+ expect { @instance.send(http_method, '/test') }.not_to raise_error
16
17
  end
17
18
 
18
- it "should not raise exception if data returned not in json format(should be fixed in v2)" do
19
- allow(DummyClassForProxy).to receive(http_method).with("/test", :query => {}).and_return(StubResponse.new("Some random text here", true, 200))
20
- expect{@instance.send(http_method,"/test")}.not_to raise_error
21
- expect(@instance.send(http_method,"/test")).to eql "Some random text here"
19
+ it 'should not raise exception if data returned not in json format (should be fixed in v2)' do
20
+ allow(DummyClassForProxy).to receive(http_method).with('/test', query: {})
21
+ .and_return(StubResponse.new('Some random text here', true, 200))
22
+ expect { @instance.send(http_method, '/test') }.not_to raise_error
23
+ expect(@instance.send(http_method, '/test')).to eql('Some random text here')
22
24
  end
23
25
 
24
- it "should raise Auth0::Unauthorized on send http #{http_method} method to path defined through HTTParty when 401 status received" do
25
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :query => {})
26
- expect(DummyClassForProxy).to receive(http_method).with("/test", :query => {}).and_return(StubResponse.new({}, false, 401))
27
- expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::Unauthorized)
26
+ it "should raise Auth0::Unauthorized on send http #{http_method}
27
+ method to path defined through HTTParty when 401 status received" do
28
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', query: {})
29
+ expect(DummyClassForProxy).to receive(http_method).with('/test', query: {})
30
+ .and_return(StubResponse.new({}, false, 401))
31
+ expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::Unauthorized)
28
32
  end
29
33
 
30
- it "should raise Auth0::NotFound on send http #{http_method} method to path defined through HTTParty when 404 status received" do
31
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :query => {})
32
- expect(DummyClassForProxy).to receive(http_method).with("/test", :query => {}).and_return(StubResponse.new({}, false, 404))
33
- expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::NotFound)
34
+ it "should raise Auth0::NotFound on send http #{http_method} method
35
+ to path defined through HTTParty when 404 status received" do
36
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', query: {})
37
+ expect(DummyClassForProxy).to receive(http_method).with('/test', query: {})
38
+ .and_return(StubResponse.new({}, false, 404))
39
+ expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::NotFound)
34
40
  end
35
41
 
36
- it "should raise Auth0::Unsupported on send http #{http_method} method to path defined through HTTParty when 418 or other unknown status received" do
37
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :query => {})
38
- expect(DummyClassForProxy).to receive(http_method).with("/test", :query => {}).and_return(StubResponse.new({}, false, 418))
39
- expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::Unsupported)
42
+ it "should raise Auth0::Unsupported on send http #{http_method} method
43
+ to path defined through HTTParty when 418 or other unknown status received" do
44
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', query: {})
45
+ expect(DummyClassForProxy).to receive(http_method).with('/test', query: {})
46
+ .and_return(StubResponse.new({}, false, 418))
47
+ expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::Unsupported)
40
48
  end
41
49
 
42
- it "should raise Auth0::BadRequest on send http #{http_method} method to path defined through HTTParty when 400 or other unknown status received" do
43
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :query => {})
44
- expect(DummyClassForProxy).to receive(http_method).with("/test", :query => {}).and_return(StubResponse.new({}, false, 400))
45
- expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::BadRequest)
50
+ it "should raise Auth0::BadRequest on send http #{http_method} method
51
+ to path defined through HTTParty when 400 or other unknown status received" do
52
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', query: {})
53
+ expect(DummyClassForProxy).to receive(http_method).with('/test', query: {})
54
+ .and_return(StubResponse.new({}, false, 400))
55
+ expect { @instance.send(http_method, '/test') }.to raise_error(
56
+ Auth0::BadRequest)
46
57
  end
47
58
 
48
- it "should raise Auth0::AccessDenied on send http #{http_method} method to path defined through HTTParty when 403" do
49
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :query => {})
50
- expect(DummyClassForProxy).to receive(http_method).with("/test", :query => {}).and_return(StubResponse.new({}, false, 403))
51
- expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::AccessDenied)
59
+ it "should raise Auth0::AccessDenied on send http #{http_method} method
60
+ to path defined through HTTParty when 403" do
61
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', query: {})
62
+ expect(DummyClassForProxy).to receive(http_method).with('/test', query: {})
63
+ .and_return(StubResponse.new({}, false, 403))
64
+ expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::AccessDenied)
52
65
  end
53
- it "should raise Auth0::ServerError on send http #{http_method} method to path defined through HTTParty when 500 received" do
54
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :query => {})
55
- expect(DummyClassForProxy).to receive(http_method).with("/test", :query => {}).and_return(StubResponse.new({}, false, 500))
56
- expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::ServerError)
66
+ it "should raise Auth0::ServerError on send http #{http_method} method
67
+ to path defined through HTTParty when 500 received" do
68
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', query: {})
69
+ expect(DummyClassForProxy).to receive(http_method).with('/test', query: {})
70
+ .and_return(StubResponse.new({}, false, 500))
71
+ expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::ServerError)
57
72
  end
58
73
 
59
- it "should escape path with URI.escape" do
60
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/te%20st", :query => {})
61
- expect(DummyClassForProxy).to receive(http_method).with("/te%20st", :query => {}).and_return(StubResponse.new({}, true, 200))
62
- expect{@instance.send(http_method,"/te st")}.not_to raise_error
74
+ it 'should escape path with URI.escape' do
75
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/te%20st', query: {})
76
+ expect(DummyClassForProxy).to receive(http_method).with('/te%20st', query: {})
77
+ .and_return(StubResponse.new({}, true, 200))
78
+ expect { @instance.send(http_method, '/te st') }.not_to raise_error
63
79
  end
64
80
  end
65
81
  end
66
82
 
67
83
  %i(post put patch delete).each do |http_method|
68
84
  context ".#{http_method}" do
69
- it {expect(@instance).to respond_to(http_method.to_sym)}
85
+ it { expect(@instance).to respond_to(http_method.to_sym) }
70
86
  it "should call send http #{http_method} method to path defined through HTTParty" do
71
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :body => "{}")
72
- expect(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("{}", true, 200))
73
- expect{@instance.send(http_method,"/test")}.not_to raise_error
87
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', body: '{}')
88
+ expect(DummyClassForProxy).to receive(http_method).with('/test', body: '{}')
89
+ .and_return(StubResponse.new('{}', true, 200))
90
+ expect { @instance.send(http_method, '/test') }.not_to raise_error
74
91
  end
75
92
 
76
- it "should not raise exception if data returned not in json format(should be fixed in v2)" do
77
- allow(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("Some random text here", true, 200))
78
- expect{@instance.send(http_method,"/test")}.not_to raise_error
79
- expect(@instance.send(http_method,"/test")).to eql "Some random text here"
93
+ it 'should not raise exception if data returned not in json format (should be fixed in v2)' do
94
+ allow(DummyClassForProxy).to receive(http_method).with('/test', body: '{}')
95
+ .and_return(StubResponse.new('Some random text here', true, 200))
96
+ expect { @instance.send(http_method, '/test') }.not_to raise_error
97
+ expect(@instance.send(http_method, '/test')).to eql('Some random text here')
80
98
  end
81
99
 
82
- it "should raise Auth0::Unauthorized on send http #{http_method} method to path defined through HTTParty when 401 status received" do
83
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :body => "{}")
84
- expect(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("{}", false, 401))
85
- expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::Unauthorized)
100
+ it "should raise Auth0::Unauthorized on send http #{http_method} method
101
+ to path defined through HTTParty when 401 status received" do
102
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', body: '{}')
103
+ expect(DummyClassForProxy).to receive(http_method).with('/test', body: '{}')
104
+ .and_return(StubResponse.new('{}', false, 401))
105
+ expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::Unauthorized)
86
106
  end
87
107
 
88
- it "should raise Auth0::NotFound on send http #{http_method} method to path defined through HTTParty when 404 status received" do
89
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :body => "{}")
90
- expect(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("{}", false, 404))
91
- expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::NotFound)
108
+ it "should raise Auth0::NotFound on send http #{http_method} method
109
+ to path defined through HTTParty when 404 status received" do
110
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', body: '{}')
111
+ expect(DummyClassForProxy).to receive(http_method).with('/test', body: '{}')
112
+ .and_return(StubResponse.new('{}', false, 404))
113
+ expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::NotFound)
92
114
  end
93
115
 
94
- it "should raise Auth0::Unsupported on send http #{http_method} method to path defined through HTTParty when 418 or other unknown status received" do
95
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :body => "{}")
96
- expect(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("{}", false, 418))
97
- expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::Unsupported)
116
+ it "should raise Auth0::Unsupported on send http #{http_method} method
117
+ to path defined through HTTParty when 418 or other unknown status received" do
118
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', body: '{}')
119
+ expect(DummyClassForProxy).to receive(http_method).with('/test', body: '{}')
120
+ .and_return(StubResponse.new('{}', false, 418))
121
+ expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::Unsupported)
98
122
  end
99
123
 
100
- it "should raise Auth0::BadRequest on send http #{http_method} method to path defined through HTTParty when 400 or other unknown status received" do
101
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :body => "{}")
102
- expect(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("{}", false, 400))
103
- expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::BadRequest)
124
+ it "should raise Auth0::BadRequest on send http #{http_method} method
125
+ to path defined through HTTParty when 400 or other unknown status received" do
126
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', body: '{}')
127
+ expect(DummyClassForProxy).to receive(http_method).with('/test', body: '{}')
128
+ .and_return(StubResponse.new('{}', false, 400))
129
+ expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::BadRequest)
104
130
  end
105
131
 
106
- it "should raise Auth0::ServerError on send http #{http_method} method to path defined through HTTParty when 500 received" do
107
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :body => "{}")
108
- expect(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("{}", false, 500))
109
- expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::ServerError)
132
+ it "should raise Auth0::ServerError on send http #{http_method} method
133
+ to path defined through HTTParty when 500 received" do
134
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/test', body: '{}')
135
+ expect(DummyClassForProxy).to receive(http_method).with('/test', body: '{}')
136
+ .and_return(StubResponse.new('{}', false, 500))
137
+ expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::ServerError)
110
138
  end
111
139
 
112
- it "should escape path with URI.escape" do
113
- allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/te%20st", :body => "{}")
114
- expect(DummyClassForProxy).to receive(http_method).with("/te%20st", :body => "{}").and_return(StubResponse.new("{}", true, 200))
115
- expect{@instance.send(http_method,"/te st")}.not_to raise_error
140
+ it 'should escape path with URI.escape' do
141
+ allow(DummyClassForProxy).to receive(http_method).with('http://login.auth0.com/te%20st', body: '{}')
142
+ expect(DummyClassForProxy).to receive(http_method).with('/te%20st', body: '{}')
143
+ .and_return(StubResponse.new('{}', true, 200))
144
+ expect { @instance.send(http_method, '/te st') }.not_to raise_error
116
145
  end
117
146
  end
118
147
  end