auth0-ruby 0.9

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 (73) hide show
  1. checksums.yaml +7 -0
  2. data/.bundle/config +2 -0
  3. data/.gitignore +8 -0
  4. data/.rspec +2 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +68 -0
  7. data/README.md +27 -0
  8. data/Rakefile +9 -0
  9. data/auth0.gemspec +29 -0
  10. data/doc/Auth0.html +153 -0
  11. data/doc/Auth0/Api.html +128 -0
  12. data/doc/Auth0/Api/AuthenticationEndpoints.html +596 -0
  13. data/doc/Auth0/Api/V1.html +192 -0
  14. data/doc/Auth0/Api/V1/Clients.html +440 -0
  15. data/doc/Auth0/Api/V1/Connections.html +506 -0
  16. data/doc/Auth0/Api/V1/Logs.html +366 -0
  17. data/doc/Auth0/Api/V1/Rules.html +439 -0
  18. data/doc/Auth0/Api/V1/Users.html +1617 -0
  19. data/doc/Auth0/BadRequest.html +142 -0
  20. data/doc/Auth0/Client.html +236 -0
  21. data/doc/Auth0/Exception.html +140 -0
  22. data/doc/Auth0/Mixins.html +225 -0
  23. data/doc/Auth0/Mixins/HTTPartyProxy.html +121 -0
  24. data/doc/Auth0/Mixins/Initializer.html +298 -0
  25. data/doc/Auth0/NotFound.html +143 -0
  26. data/doc/Auth0/ServerError.html +142 -0
  27. data/doc/Auth0/Unauthorized.html +143 -0
  28. data/doc/Auth0/Unsupported.html +142 -0
  29. data/doc/Auth0/UserIdIsBlank.html +143 -0
  30. data/doc/Auth0Client.html +235 -0
  31. data/doc/_index.html +347 -0
  32. data/doc/class_list.html +58 -0
  33. data/doc/css/common.css +1 -0
  34. data/doc/css/full_list.css +57 -0
  35. data/doc/css/style.css +339 -0
  36. data/doc/file.README.html +103 -0
  37. data/doc/file_list.html +60 -0
  38. data/doc/frames.html +26 -0
  39. data/doc/index.html +103 -0
  40. data/doc/js/app.js +219 -0
  41. data/doc/js/full_list.js +181 -0
  42. data/doc/js/jquery.js +4 -0
  43. data/doc/method_list.html +327 -0
  44. data/doc/top-level-namespace.html +114 -0
  45. data/lib/auth0.rb +8 -0
  46. data/lib/auth0/api/authentication_endpoints.rb +71 -0
  47. data/lib/auth0/api/v1.rb +19 -0
  48. data/lib/auth0/api/v1/clients.rb +48 -0
  49. data/lib/auth0/api/v1/connections.rb +51 -0
  50. data/lib/auth0/api/v1/logs.rb +41 -0
  51. data/lib/auth0/api/v1/rules.rb +44 -0
  52. data/lib/auth0/api/v1/users.rb +163 -0
  53. data/lib/auth0/client.rb +7 -0
  54. data/lib/auth0/exception.rb +18 -0
  55. data/lib/auth0/mixins.rb +13 -0
  56. data/lib/auth0/mixins/httparty_proxy.rb +29 -0
  57. data/lib/auth0/mixins/initializer.rb +25 -0
  58. data/lib/auth0/version.rb +4 -0
  59. data/lib/auth0_client.rb +3 -0
  60. data/spec/lib/auth0/api/authentication_endpoints_spec.rb +56 -0
  61. data/spec/lib/auth0/api/v1/clients_spec.rb +62 -0
  62. data/spec/lib/auth0/api/v1/connections_spec.rb +62 -0
  63. data/spec/lib/auth0/api/v1/logs_spec.rb +46 -0
  64. data/spec/lib/auth0/api/v1/rules_spec.rb +40 -0
  65. data/spec/lib/auth0/api/v1/users_spec.rb +215 -0
  66. data/spec/lib/auth0/client_spec.rb +19 -0
  67. data/spec/lib/auth0/mixins/httparty_proxy_spec.rb +60 -0
  68. data/spec/lib/auth0_client_spec.rb +8 -0
  69. data/spec/spec_helper.rb +18 -0
  70. data/spec/support/dummy_class.rb +7 -0
  71. data/spec/support/dummy_class_for_proxy.rb +4 -0
  72. data/spec/support/stub_response.rb +2 -0
  73. metadata +253 -0
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+ describe Auth0::Client do
3
+ context "modules to be included" do
4
+ let(:subject){Auth0::Client.new({})}
5
+ before :each do
6
+ allow_any_instance_of(Auth0::Client).to receive(:obtain_access_token)
7
+ end
8
+ it {expect(subject).to be_a HTTParty}
9
+ it {expect(subject).to be_a Auth0::Mixins}
10
+ it {expect(subject).to be_a Auth0::Mixins::Initializer}
11
+ it {expect(subject).to be_a Auth0::Api::V1}
12
+ it {expect(subject).to be_a Auth0::Api::V1::Users}
13
+ it {expect(subject).to be_a Auth0::Api::V1::Connections}
14
+ it {expect(subject).to be_a Auth0::Api::V1::Clients}
15
+ it {expect(subject).to be_a Auth0::Api::V1::Rules}
16
+ it {expect(subject).to be_a Auth0::Api::V1::Logs}
17
+ it {expect(subject).to be_a Auth0::Api::AuthenticationEndpoints}
18
+ end
19
+ end
@@ -0,0 +1,60 @@
1
+ require "spec_helper"
2
+ describe Auth0::Mixins::HTTPartyProxy do
3
+ before :all do
4
+ dummy_instance = DummyClassForProxy.new
5
+ dummy_instance.extend(Auth0::Mixins::HTTPartyProxy)
6
+ @instance = dummy_instance
7
+ end
8
+ %i(get post put patch delete).each do |http_method|
9
+ context ".#{http_method}" do
10
+ it {expect(@instance).to respond_to(http_method.to_sym)}
11
+ it "should call send http #{http_method} method to path defined through HTTParty" do
12
+ allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :body => "{}")
13
+ expect(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("{}", true, 200))
14
+ expect{@instance.send(http_method,"/test")}.not_to raise_error
15
+ end
16
+
17
+ it "should not raise exception if data returned not in json format(should be fixed in v2)" do
18
+ allow(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("Some random text here", true, 200))
19
+ expect{@instance.send(http_method,"/test")}.not_to raise_error
20
+ expect(@instance.send(http_method,"/test")).to eql "Some random text here"
21
+ end
22
+
23
+ it "should raise Auth0::Unauthorized on send http #{http_method} method to path defined through HTTParty when 401 status received" do
24
+ allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :body => "{}")
25
+ expect(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("{}", false, 401))
26
+ expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::Unauthorized)
27
+ end
28
+
29
+ it "should raise Auth0::NotFound on send http #{http_method} method to path defined through HTTParty when 404 status received" do
30
+ allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :body => "{}")
31
+ expect(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("{}", false, 404))
32
+ expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::NotFound)
33
+ end
34
+
35
+ it "should raise Auth0::Unsupported on send http #{http_method} method to path defined through HTTParty when 418 or other unknown status received" do
36
+ allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :body => "{}")
37
+ expect(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("{}", false, 418))
38
+ expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::Unsupported)
39
+ end
40
+
41
+ it "should raise Auth0::BadRequest on send http #{http_method} method to path defined through HTTParty when 400 or other unknown status received" do
42
+ allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :body => "{}")
43
+ expect(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("{}", false, 400))
44
+ expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::BadRequest)
45
+ end
46
+
47
+ it "should raise Auth0::ServerError on send http #{http_method} method to path defined through HTTParty when 500 received" do
48
+ allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/test", :body => "{}")
49
+ expect(DummyClassForProxy).to receive(http_method).with("/test", :body => "{}").and_return(StubResponse.new("{}", false, 500))
50
+ expect{@instance.send(http_method,"/test")}.to raise_error(Auth0::ServerError)
51
+ end
52
+
53
+ it "should escape path with URI.escape" do
54
+ allow(DummyClassForProxy).to receive(http_method).with("http://login.auth0.com/te%20st", :body => "{}")
55
+ expect(DummyClassForProxy).to receive(http_method).with("/te%20st", :body => "{}").and_return(StubResponse.new("{}", true, 200))
56
+ expect{@instance.send(http_method,"/te st")}.not_to raise_error
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+ describe Auth0Client do
3
+ let(:subject){Auth0Client.new({})}
4
+ before :each do
5
+ allow_any_instance_of(Auth0Client).to receive(:obtain_access_token)
6
+ end
7
+ it {expect(subject).to be_a Auth0::Client}
8
+ end
@@ -0,0 +1,18 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ add_filter "/spec/"
6
+ end
7
+ require 'rspec'
8
+ require 'rack/test'
9
+ require 'webmock/rspec'
10
+ require 'byebug'
11
+ require 'auth0'
12
+ Dir[("./lib/**/*.rb")].each { |f| require f }
13
+ Dir[("./spec/support/**/*.rb")].each { |f| require f }
14
+ RSpec.configure do |config|
15
+ config.include WebMock::API
16
+ config.include Rack::Test::Methods
17
+ config.fail_fast = true
18
+ end
@@ -0,0 +1,7 @@
1
+ class DummyClass
2
+ %i(get post put patch delete).each do |method|
3
+ define_method(method) do |path, body={}|
4
+ true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ class DummyClassForProxy
2
+ include HTTParty
3
+ base_uri "http://auth0.com"
4
+ end
@@ -0,0 +1,2 @@
1
+ class StubResponse<Struct.new(:body, :success?, :code)
2
+ end
metadata ADDED
@@ -0,0 +1,253 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: auth0-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.9'
5
+ platform: ruby
6
+ authors:
7
+ - Auth0
8
+ - Ezequiel Morito
9
+ - Jose Romaniello
10
+ - Petroe Ivan
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2015-02-02 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: httparty
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '0.13'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.13'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ~>
35
+ - !ruby/object:Gem::Version
36
+ version: 3.1.0
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: 3.1.0
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 3.1.0
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: 3.1.0
50
+ - !ruby/object:Gem::Dependency
51
+ name: rack-test
52
+ requirement: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ - !ruby/object:Gem::Dependency
65
+ name: simplecov
66
+ requirement: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: webmock
80
+ requirement: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ - !ruby/object:Gem::Dependency
93
+ name: byebug
94
+ requirement: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ - !ruby/object:Gem::Dependency
107
+ name: faker
108
+ requirement: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ - !ruby/object:Gem::Dependency
121
+ name: yard
122
+ requirement: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ type: :development
128
+ prerelease: false
129
+ version_requirements: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ description: Ruby client library for the Auth0 platform. This is fork of https://github.com/auth0/ruby-auth0,
135
+ but while auth0 is not hurring to merge prs, I've decided to make my own gem with
136
+ blackjack and hookers. But I really recommend you to switch to ruby-auth0 gem after
137
+ pr-9 will be merged.
138
+ email:
139
+ - petroei@gmail.com
140
+ executables: []
141
+ extensions: []
142
+ extra_rdoc_files: []
143
+ files:
144
+ - .bundle/config
145
+ - .gitignore
146
+ - .rspec
147
+ - Gemfile
148
+ - Gemfile.lock
149
+ - README.md
150
+ - Rakefile
151
+ - auth0.gemspec
152
+ - doc/Auth0.html
153
+ - doc/Auth0/Api.html
154
+ - doc/Auth0/Api/AuthenticationEndpoints.html
155
+ - doc/Auth0/Api/V1.html
156
+ - doc/Auth0/Api/V1/Clients.html
157
+ - doc/Auth0/Api/V1/Connections.html
158
+ - doc/Auth0/Api/V1/Logs.html
159
+ - doc/Auth0/Api/V1/Rules.html
160
+ - doc/Auth0/Api/V1/Users.html
161
+ - doc/Auth0/BadRequest.html
162
+ - doc/Auth0/Client.html
163
+ - doc/Auth0/Exception.html
164
+ - doc/Auth0/Mixins.html
165
+ - doc/Auth0/Mixins/HTTPartyProxy.html
166
+ - doc/Auth0/Mixins/Initializer.html
167
+ - doc/Auth0/NotFound.html
168
+ - doc/Auth0/ServerError.html
169
+ - doc/Auth0/Unauthorized.html
170
+ - doc/Auth0/Unsupported.html
171
+ - doc/Auth0/UserIdIsBlank.html
172
+ - doc/Auth0Client.html
173
+ - doc/_index.html
174
+ - doc/class_list.html
175
+ - doc/css/common.css
176
+ - doc/css/full_list.css
177
+ - doc/css/style.css
178
+ - doc/file.README.html
179
+ - doc/file_list.html
180
+ - doc/frames.html
181
+ - doc/index.html
182
+ - doc/js/app.js
183
+ - doc/js/full_list.js
184
+ - doc/js/jquery.js
185
+ - doc/method_list.html
186
+ - doc/top-level-namespace.html
187
+ - lib/auth0.rb
188
+ - lib/auth0/api/authentication_endpoints.rb
189
+ - lib/auth0/api/v1.rb
190
+ - lib/auth0/api/v1/clients.rb
191
+ - lib/auth0/api/v1/connections.rb
192
+ - lib/auth0/api/v1/logs.rb
193
+ - lib/auth0/api/v1/rules.rb
194
+ - lib/auth0/api/v1/users.rb
195
+ - lib/auth0/client.rb
196
+ - lib/auth0/exception.rb
197
+ - lib/auth0/mixins.rb
198
+ - lib/auth0/mixins/httparty_proxy.rb
199
+ - lib/auth0/mixins/initializer.rb
200
+ - lib/auth0/version.rb
201
+ - lib/auth0_client.rb
202
+ - spec/lib/auth0/api/authentication_endpoints_spec.rb
203
+ - spec/lib/auth0/api/v1/clients_spec.rb
204
+ - spec/lib/auth0/api/v1/connections_spec.rb
205
+ - spec/lib/auth0/api/v1/logs_spec.rb
206
+ - spec/lib/auth0/api/v1/rules_spec.rb
207
+ - spec/lib/auth0/api/v1/users_spec.rb
208
+ - spec/lib/auth0/client_spec.rb
209
+ - spec/lib/auth0/mixins/httparty_proxy_spec.rb
210
+ - spec/lib/auth0_client_spec.rb
211
+ - spec/spec_helper.rb
212
+ - spec/support/dummy_class.rb
213
+ - spec/support/dummy_class_for_proxy.rb
214
+ - spec/support/stub_response.rb
215
+ homepage: https://github.com/offtop/ruby-auth0
216
+ licenses:
217
+ - MIT
218
+ metadata: {}
219
+ post_install_message:
220
+ rdoc_options: []
221
+ require_paths:
222
+ - lib
223
+ required_ruby_version: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - '>='
226
+ - !ruby/object:Gem::Version
227
+ version: '0'
228
+ required_rubygems_version: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - '>='
231
+ - !ruby/object:Gem::Version
232
+ version: '0'
233
+ requirements: []
234
+ rubyforge_project:
235
+ rubygems_version: 2.4.4
236
+ signing_key:
237
+ specification_version: 4
238
+ summary: Ruby client library for the Auth0 platform.
239
+ test_files:
240
+ - spec/lib/auth0/api/authentication_endpoints_spec.rb
241
+ - spec/lib/auth0/api/v1/clients_spec.rb
242
+ - spec/lib/auth0/api/v1/connections_spec.rb
243
+ - spec/lib/auth0/api/v1/logs_spec.rb
244
+ - spec/lib/auth0/api/v1/rules_spec.rb
245
+ - spec/lib/auth0/api/v1/users_spec.rb
246
+ - spec/lib/auth0/client_spec.rb
247
+ - spec/lib/auth0/mixins/httparty_proxy_spec.rb
248
+ - spec/lib/auth0_client_spec.rb
249
+ - spec/spec_helper.rb
250
+ - spec/support/dummy_class.rb
251
+ - spec/support/dummy_class_for_proxy.rb
252
+ - spec/support/stub_response.rb
253
+ has_rdoc: