auth0 2.1.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.bundle/config +2 -0
  3. data/.gitignore +5 -2
  4. data/.rspec +3 -0
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +68 -0
  7. data/auth0.gemspec +11 -10
  8. data/doc/Auth0/AccessDenied.html +142 -0
  9. data/doc/Auth0/Api/AuthenticationEndpoints.html +592 -0
  10. data/doc/Auth0/Api/V1/Clients.html +440 -0
  11. data/doc/Auth0/Api/V1/Connections.html +506 -0
  12. data/doc/Auth0/Api/V1/Logs.html +366 -0
  13. data/doc/Auth0/Api/V1/Rules.html +439 -0
  14. data/doc/Auth0/Api/V1/Users.html +1617 -0
  15. data/doc/Auth0/Api/V1.html +188 -0
  16. data/doc/Auth0/Api/V2/Blacklists.html +268 -0
  17. data/doc/Auth0/Api/V2/Clients.html +477 -0
  18. data/doc/Auth0/Api/V2/Jobs.html +277 -0
  19. data/doc/Auth0/Api/V2/Router.html +109 -0
  20. data/doc/Auth0/Api/V2/Stats.html +268 -0
  21. data/doc/Auth0/Api/V2/Users.html +652 -0
  22. data/doc/Auth0/Api/V2.html +193 -0
  23. data/doc/Auth0/Api.html +128 -0
  24. data/doc/Auth0/BadRequest.html +142 -0
  25. data/doc/Auth0/Client.html +164 -0
  26. data/doc/Auth0/Exception.html +140 -0
  27. data/doc/Auth0/InvalidParameter.html +142 -0
  28. data/doc/Auth0/Mixins/HTTPartyProxy.html +121 -0
  29. data/doc/Auth0/Mixins/Initializer.html +312 -0
  30. data/doc/Auth0/Mixins.html +153 -0
  31. data/doc/Auth0/NotFound.html +143 -0
  32. data/doc/Auth0/ServerError.html +142 -0
  33. data/doc/Auth0/Unauthorized.html +143 -0
  34. data/doc/Auth0/Unsupported.html +142 -0
  35. data/doc/Auth0/UserIdIsBlank.html +143 -0
  36. data/doc/Auth0.html +153 -0
  37. data/doc/Auth0Client.html +163 -0
  38. data/doc/_index.html +418 -0
  39. data/doc/class_list.html +58 -0
  40. data/doc/css/common.css +1 -0
  41. data/doc/css/full_list.css +57 -0
  42. data/doc/css/style.css +339 -0
  43. data/doc/file.README.html +103 -0
  44. data/doc/file_list.html +60 -0
  45. data/doc/frames.html +26 -0
  46. data/doc/index.html +103 -0
  47. data/doc/js/app.js +219 -0
  48. data/doc/js/full_list.js +181 -0
  49. data/doc/js/jquery.js +4 -0
  50. data/doc/method_list.html +435 -0
  51. data/doc/top-level-namespace.html +114 -0
  52. data/lib/auth0/api/authentication_endpoints.rb +71 -0
  53. data/lib/auth0/api/v1/clients.rb +48 -0
  54. data/lib/auth0/api/v1/connections.rb +51 -0
  55. data/lib/auth0/api/v1/logs.rb +41 -0
  56. data/lib/auth0/api/v1/rules.rb +44 -0
  57. data/lib/auth0/api/v1/users.rb +163 -0
  58. data/lib/auth0/api/v1.rb +19 -0
  59. data/lib/auth0/api/v2/blacklists.rb +24 -0
  60. data/lib/auth0/api/v2/clients.rb +41 -0
  61. data/lib/auth0/api/v2/jobs.rb +20 -0
  62. data/lib/auth0/api/v2/stats.rb +24 -0
  63. data/lib/auth0/api/v2/users.rb +67 -0
  64. data/lib/auth0/api/v2.rb +17 -0
  65. data/lib/auth0/client.rb +5 -48
  66. data/lib/auth0/exception.rb +22 -0
  67. data/lib/auth0/mixins/httparty_proxy.rb +35 -0
  68. data/lib/auth0/mixins/initializer.rb +34 -0
  69. data/lib/auth0/mixins.rb +12 -0
  70. data/lib/auth0/version.rb +3 -2
  71. data/lib/auth0.rb +6 -1
  72. data/lib/auth0_client.rb +3 -0
  73. data/spec/lib/auth0/api/authentication_endpoints_spec.rb +56 -0
  74. data/spec/lib/auth0/api/v1/clients_spec.rb +62 -0
  75. data/spec/lib/auth0/api/v1/connections_spec.rb +62 -0
  76. data/spec/lib/auth0/api/v1/logs_spec.rb +46 -0
  77. data/spec/lib/auth0/api/v1/rules_spec.rb +40 -0
  78. data/spec/lib/auth0/api/v1/users_spec.rb +217 -0
  79. data/spec/lib/auth0/api/v2/blacklists_spec.rb +24 -0
  80. data/spec/lib/auth0/api/v2/clients_spec.rb +54 -0
  81. data/spec/lib/auth0/api/v2/jobs_spec.rb +21 -0
  82. data/spec/lib/auth0/api/v2/stats_spec.rb +22 -0
  83. data/spec/lib/auth0/api/v2/users_spec.rb +72 -0
  84. data/spec/lib/auth0/client_spec.rb +47 -0
  85. data/spec/lib/auth0/mixins/httparty_proxy_spec.rb +119 -0
  86. data/spec/lib/auth0_client_spec.rb +8 -0
  87. data/spec/spec_helper.rb +8 -7
  88. data/spec/support/dummy_class.rb +7 -0
  89. data/spec/support/dummy_class_for_proxy.rb +4 -0
  90. data/spec/support/stub_response.rb +2 -0
  91. metadata +159 -28
  92. data/lib/omniauth/strategies/auth0.rb +0 -62
  93. data/spec/omniauth/strategies/auth0_spec.rb +0 -149
@@ -1,149 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe OmniAuth::Strategies::Auth0 do
4
- let(:app){ Rack::Builder.new do |b|
5
- b.use Rack::Session::Cookie, {:secret => "abc123"}
6
- b.run lambda{|env| [200, {}, ['Not Found']]}
7
- end.to_app }
8
-
9
- before :each do
10
- OmniAuth.config.test_mode = true
11
- @request = double('Request')
12
- @request.stub(:params) { {} }
13
- @request.stub(:cookies) { {} }
14
- @request.stub(:env) { {} }
15
-
16
- @session = double('Session')
17
- @session.stub(:delete).with('omniauth.state').and_return('state')
18
- end
19
-
20
- after do
21
- OmniAuth.config.test_mode = false
22
- end
23
-
24
- subject do
25
- OmniAuth::Strategies::Auth0.new(app,
26
- "client_id", "client_secret", "tenny.auth0.com:3000").tap do |strategy|
27
- strategy.stub(:request) { @request }
28
- end
29
- end
30
-
31
- context "initiation" do
32
- it "uses the correct site" do
33
- subject.options.client_options.site.
34
- should == "https://tenny.auth0.com:3000"
35
- end
36
-
37
- it "uses the correct authorize_url" do
38
- subject.options.client_options.authorize_url.
39
- should == "https://tenny.auth0.com:3000/authorize"
40
- end
41
-
42
- it "uses the correct token_url" do
43
- subject.options.client_options.token_url.
44
- should == "https://tenny.auth0.com:3000/oauth/token"
45
- end
46
- end
47
-
48
- context "request phase" do
49
- before(:each){ get '/auth/auth0' }
50
-
51
- it "authenticate" do
52
- expect(last_response.status).to eq(200)
53
- end
54
-
55
- it "authorize params" do
56
- subject.stub(:request) { double('Request', {:params => {
57
- "connection" => "google-oauth2", "redirect_uri" => "redirect_uri" }, :env => {}}) }
58
- subject.authorize_params.include?("connection").should == true
59
- subject.authorize_params.include?("state").should == true
60
- subject.authorize_params.include?("redirect_uri").should == true
61
- end
62
- end
63
-
64
- describe "callback phase" do
65
- before :each do
66
- @raw_info = {
67
- "_id" => "165dabb5140ee2cc66b5137912ccd760",
68
- "email" => "user@mail.com",
69
- "family_name" => "LastName",
70
- "gender" => "male",
71
- "given_name" => "FirstName",
72
- "identities" => [
73
- {
74
- "access_token" => "ya29.AHES6ZRPK1Skc_rtB30Em_5RkZlKez3FkktcmJ_0RX5fIkCbkOCrXA",
75
- "provider" => "google-oauth2",
76
- "user_id" => "102835921788417079450",
77
- "connection" => "google-oauth2",
78
- "isSocial" => true
79
- }
80
- ],
81
- "locale" => "en",
82
- "name" => "FirstName LastName",
83
- "nickname" => "nick",
84
- "picture" => "pic",
85
- "user_id" => "google-oauth2|102835921788417079450"
86
- }
87
- subject.stub(:raw_info) { @raw_info }
88
- end
89
-
90
- context "info" do
91
- it 'returns the uid (required)' do
92
- subject.uid.should eq('google-oauth2|102835921788417079450')
93
- end
94
-
95
- it 'returns the name (required)' do
96
- subject.info[:name].should eq('FirstName LastName')
97
- end
98
-
99
- it 'returns the email' do
100
- subject.info[:email].should eq('user@mail.com')
101
- end
102
-
103
- it 'returns the nickname' do
104
- subject.info[:nickname].should eq('nick')
105
- end
106
-
107
- it 'returns the last name' do
108
- subject.info[:last_name].should eq('LastName')
109
- end
110
-
111
- it 'returns the first name' do
112
- subject.info[:first_name].should eq('FirstName')
113
- end
114
-
115
- it 'returns the location' do
116
- subject.info[:location].should eq('en')
117
- end
118
-
119
- it 'returns the image' do
120
- subject.info[:image].should eq('pic')
121
- end
122
- end
123
-
124
- context "get token" do
125
- before :each do
126
- @access_token = double('OAuth2::AccessToken')
127
- @access_token.stub(:token)
128
- @access_token.stub(:expires?)
129
- @access_token.stub(:expires_at)
130
- @access_token.stub(:refresh_token)
131
- subject.stub(:access_token) { @access_token }
132
- end
133
-
134
- it 'returns a Hash' do
135
- subject.credentials.should be_a(Hash)
136
- end
137
-
138
- it 'returns the token' do
139
- @access_token.stub(:token) {
140
- {
141
- :access_token => "OTqSFa9zrh0VRGAZHH4QPJISCoynRwSy9FocUazuaU950EVcISsJo3pST11iTCiI",
142
- :token_type => "bearer"
143
- } }
144
- subject.credentials['token'][:access_token].should eq('OTqSFa9zrh0VRGAZHH4QPJISCoynRwSy9FocUazuaU950EVcISsJo3pST11iTCiI')
145
- subject.credentials['token'][:token_type].should eq('bearer')
146
- end
147
- end
148
- end
149
- end