strelka 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/ChangeLog +156 -9
  4. data/History.rdoc +15 -0
  5. data/IDEAS.rdoc +17 -1
  6. data/MILESTONES.rdoc +1 -1
  7. data/Manifest.txt +10 -2
  8. data/Plugins.rdoc +4 -4
  9. data/README.rdoc +3 -3
  10. data/Rakefile +5 -4
  11. data/bin/strelka +19 -10
  12. data/contrib/hoetemplate/data/project/apps/file_name_app +1 -0
  13. data/contrib/hoetemplate/lib/file_name.rb.erb +3 -2
  14. data/examples/apps/hello-world +1 -0
  15. data/examples/apps/ws-chat +69 -0
  16. data/examples/apps/ws-echo +61 -0
  17. data/examples/gen-config.rb +6 -5
  18. data/lib/strelka/app/auth.rb +2 -2
  19. data/lib/strelka/app/errors.rb +1 -1
  20. data/lib/strelka/app/filters.rb +3 -2
  21. data/lib/strelka/app/negotiation.rb +2 -2
  22. data/lib/strelka/app/parameters.rb +1 -2
  23. data/lib/strelka/app/restresources.rb +3 -2
  24. data/lib/strelka/app/routing.rb +1 -1
  25. data/lib/strelka/app/sessions.rb +2 -2
  26. data/lib/strelka/app/templating.rb +7 -3
  27. data/lib/strelka/app.rb +5 -145
  28. data/lib/strelka/behavior/plugin.rb +4 -4
  29. data/lib/strelka/discovery.rb +211 -0
  30. data/lib/strelka/httprequest.rb +1 -0
  31. data/lib/strelka/httpresponse/negotiation.rb +7 -1
  32. data/lib/strelka/mixins.rb +4 -1
  33. data/lib/strelka/paramvalidator.rb +1 -1
  34. data/lib/strelka/plugins.rb +8 -6
  35. data/lib/strelka/websocketserver/routing.rb +116 -0
  36. data/lib/strelka/websocketserver.rb +147 -0
  37. data/lib/strelka.rb +5 -4
  38. data/spec/{lib/constants.rb → constants.rb} +3 -2
  39. data/spec/{lib/helpers.rb → helpers.rb} +15 -14
  40. data/spec/strelka/app/auth_spec.rb +145 -142
  41. data/spec/strelka/app/errors_spec.rb +20 -26
  42. data/spec/strelka/app/filters_spec.rb +67 -54
  43. data/spec/strelka/app/negotiation_spec.rb +8 -14
  44. data/spec/strelka/app/parameters_spec.rb +23 -29
  45. data/spec/strelka/app/restresources_spec.rb +98 -100
  46. data/spec/strelka/app/routing_spec.rb +57 -57
  47. data/spec/strelka/app/sessions_spec.rb +11 -17
  48. data/spec/strelka/app/templating_spec.rb +36 -40
  49. data/spec/strelka/app_spec.rb +48 -147
  50. data/spec/strelka/authprovider/basic_spec.rb +5 -11
  51. data/spec/strelka/authprovider/hostaccess_spec.rb +9 -15
  52. data/spec/strelka/authprovider_spec.rb +3 -9
  53. data/spec/strelka/cookie_spec.rb +32 -38
  54. data/spec/strelka/cookieset_spec.rb +31 -37
  55. data/spec/strelka/discovery_spec.rb +144 -0
  56. data/spec/strelka/exceptions_spec.rb +2 -8
  57. data/spec/strelka/httprequest/acceptparams_spec.rb +74 -83
  58. data/spec/strelka/httprequest/auth_spec.rb +5 -15
  59. data/spec/strelka/httprequest/negotiation_spec.rb +93 -103
  60. data/spec/strelka/httprequest/session_spec.rb +12 -22
  61. data/spec/strelka/httprequest_spec.rb +1 -7
  62. data/spec/strelka/httpresponse/negotiation_spec.rb +84 -76
  63. data/spec/strelka/httpresponse/session_spec.rb +25 -35
  64. data/spec/strelka/httpresponse_spec.rb +20 -26
  65. data/spec/strelka/mixins_spec.rb +66 -61
  66. data/spec/strelka/multipartparser_spec.rb +31 -37
  67. data/spec/strelka/paramvalidator_spec.rb +389 -373
  68. data/spec/strelka/plugins_spec.rb +17 -23
  69. data/spec/strelka/router/default_spec.rb +32 -38
  70. data/spec/strelka/router/exclusive_spec.rb +28 -34
  71. data/spec/strelka/router_spec.rb +2 -8
  72. data/spec/strelka/session/db_spec.rb +17 -15
  73. data/spec/strelka/session/default_spec.rb +22 -28
  74. data/spec/strelka/session_spec.rb +3 -9
  75. data/spec/strelka/websocketserver/routing_spec.rb +119 -0
  76. data/spec/strelka/websocketserver_spec.rb +149 -0
  77. data/spec/strelka_spec.rb +11 -13
  78. data.tar.gz.sig +3 -3
  79. metadata +22 -14
  80. metadata.gz.sig +0 -0
@@ -1,16 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
6
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
7
- }
3
+ require_relative '../../helpers'
8
4
 
9
5
  require 'rspec'
10
6
  require 'rspec/mocks'
11
7
 
12
- require 'spec/lib/helpers'
13
-
14
8
  require 'strelka'
15
9
  require 'strelka/plugins'
16
10
  require 'strelka/app/auth'
@@ -35,7 +29,7 @@ describe Strelka::App::Auth do
35
29
  end
36
30
 
37
31
 
38
- it_should_behave_like( "A Strelka::App Plugin" )
32
+ it_should_behave_like( "A Strelka Plugin" )
39
33
 
40
34
 
41
35
  it "gives including apps a default authprovider" do
@@ -43,8 +37,8 @@ describe Strelka::App::Auth do
43
37
  plugins :auth
44
38
  end
45
39
 
46
- app.auth_provider.should be_a( Class )
47
- app.auth_provider.should < Strelka::AuthProvider
40
+ expect( app.auth_provider ).to be_a( Class )
41
+ expect( app.auth_provider ).to be < Strelka::AuthProvider
48
42
  end
49
43
 
50
44
  it "adds the Auth mixin to the request class" do
@@ -53,7 +47,7 @@ describe Strelka::App::Auth do
53
47
  end
54
48
  app.install_plugins
55
49
 
56
- @request_factory.get( '/api/v1/verify' ).should respond_to( :authenticated? )
50
+ expect( @request_factory.get( '/api/v1/verify' ) ).to respond_to( :authenticated? )
57
51
  end
58
52
 
59
53
 
@@ -92,46 +86,53 @@ describe Strelka::App::Auth do
92
86
  app = @app.new
93
87
  req = @request_factory.get( '/api/v1' )
94
88
 
95
- app.auth_provider.should_receive( :authenticate ).and_return( 'anonymous' )
96
- app.auth_provider.should_receive( :authorize )
89
+ expect( app.auth_provider ).to receive( :authenticate ).and_return( 'anonymous' )
90
+ expect( app.auth_provider ).to receive( :authorize )
97
91
 
98
92
  res = app.handle( req )
99
93
 
100
- res.status.should == HTTP::OK
94
+ expect( res.status ).to eq( HTTP::OK )
101
95
  end
102
96
 
103
97
  it "doesn't have any auth criteria by default" do
104
- @app.should_not have_auth_criteria()
98
+ expect( @app ).to_not have_auth_criteria()
105
99
  end
106
100
 
107
101
  it "sets the authenticated_user attribute of the request to the credentials of the authenticating user" do
108
102
  app = @app.new
109
103
  req = @request_factory.get( '/api/v1' )
110
104
 
111
- app.auth_provider.should_receive( :authenticate ).and_return( 'anonymous' )
112
- app.auth_provider.should_receive( :authorize ).and_return( true )
105
+ expect( app.auth_provider ).to receive( :authenticate ).and_return( 'anonymous' )
106
+ expect( app.auth_provider ).to receive( :authorize ).and_return( true )
113
107
 
114
108
  app.handle( req )
115
- req.authenticated_user.should == 'anonymous'
109
+ expect( req.authenticated_user ).to eq( 'anonymous' )
116
110
  end
117
111
 
118
112
  it "has its configured auth provider inherited by subclasses" do
119
113
  Strelka::App::Auth.configure( :provider => 'basic' )
120
114
  subclass = Class.new( @app )
121
- subclass.auth_provider.should == Strelka::AuthProvider::Basic
115
+ expect( subclass.auth_provider ).to eq( Strelka::AuthProvider::Basic )
122
116
  end
123
117
 
124
118
  it "has its auth config inherited by subclasses" do
125
119
  subclass = Class.new( @app )
126
120
 
127
- subclass.positive_auth_criteria.should == @app.positive_auth_criteria
128
- subclass.positive_auth_criteria.should_not equal( @app.positive_auth_criteria )
129
- subclass.negative_auth_criteria.should == @app.negative_auth_criteria
130
- subclass.negative_auth_criteria.should_not equal( @app.negative_auth_criteria )
131
- subclass.positive_perms_criteria.should == @app.positive_perms_criteria
132
- subclass.positive_perms_criteria.should_not equal( @app.positive_perms_criteria )
133
- subclass.negative_perms_criteria.should == @app.negative_perms_criteria
134
- subclass.negative_perms_criteria.should_not equal( @app.negative_perms_criteria )
121
+ expect( subclass.positive_auth_criteria ).to eq( @app.positive_auth_criteria )
122
+ expect( subclass.positive_auth_criteria ).to_not equal( @app.positive_auth_criteria )
123
+ expect( subclass.negative_auth_criteria ).to eq( @app.negative_auth_criteria )
124
+ expect( subclass.negative_auth_criteria ).to_not equal( @app.negative_auth_criteria )
125
+ expect( subclass.positive_perms_criteria ).to eq( @app.positive_perms_criteria )
126
+ expect( subclass.positive_perms_criteria ).to_not equal( @app.positive_perms_criteria )
127
+ expect( subclass.negative_perms_criteria ).to eq( @app.negative_perms_criteria )
128
+ expect( subclass.negative_perms_criteria ).to_not equal( @app.negative_perms_criteria )
129
+ end
130
+
131
+
132
+ RSpec::Matchers.define( :require_auth_for_request ) do |request|
133
+ match do |app|
134
+ app.request_should_auth?( request )
135
+ end
135
136
  end
136
137
 
137
138
 
@@ -140,13 +141,14 @@ describe Strelka::App::Auth do
140
141
  app = @app.new
141
142
 
142
143
  req = @request_factory.get( '/api/v1/string' )
143
- app.request_should_auth?( req ).should be_true()
144
+ expect( app ).to require_auth_for_request( req )
145
+ expect( app.request_should_auth?(req) ).to be_true()
144
146
  req = @request_factory.get( '/api/v1/strong' )
145
- app.request_should_auth?( req ).should be_false()
147
+ expect( app.request_should_auth?(req) ).to be_false()
146
148
  req = @request_factory.get( '/api/v1/stri' )
147
- app.request_should_auth?( req ).should be_false()
149
+ expect( app.request_should_auth?(req) ).to be_false()
148
150
  req = @request_factory.get( '/api/v1/string/long' )
149
- app.request_should_auth?( req ).should be_false()
151
+ expect( app.request_should_auth?(req) ).to be_false()
150
152
  end
151
153
 
152
154
  it "allows auth criteria to be declared with a regexp" do
@@ -154,17 +156,17 @@ describe Strelka::App::Auth do
154
156
  app = @app.new
155
157
 
156
158
  req = @request_factory.get( '/api/v1/stri' )
157
- app.request_should_auth?( req ).should be_true()
159
+ expect( app.request_should_auth?(req) ).to be_true()
158
160
  req = @request_factory.get( '/api/v1/stro' )
159
- app.request_should_auth?( req ).should be_true()
161
+ expect( app.request_should_auth?(req) ).to be_true()
160
162
  req = @request_factory.get( '/api/v1/string' ) # not right-bound
161
- app.request_should_auth?( req ).should be_true()
163
+ expect( app.request_should_auth?(req) ).to be_true()
162
164
  req = @request_factory.get( '/api/v1/string/long' )
163
- app.request_should_auth?( req ).should be_true()
165
+ expect( app.request_should_auth?(req) ).to be_true()
164
166
  req = @request_factory.get( '/api/v1/other/string/long' ) # Not left-bound
165
- app.request_should_auth?( req ).should be_true()
167
+ expect( app.request_should_auth?(req) ).to be_true()
166
168
  req = @request_factory.get( '/api/v1/chatlog' ) # Not left-bound
167
- app.request_should_auth?( req ).should be_false()
169
+ expect( app.request_should_auth?(req) ).to be_false()
168
170
  end
169
171
 
170
172
  it "allows auth criteria to be declared with a string and a block" do
@@ -175,15 +177,15 @@ describe Strelka::App::Auth do
175
177
  app = @app.new
176
178
 
177
179
  req = @request_factory.get( '/api/v1/string' )
178
- app.request_should_auth?( req ).should be_false()
180
+ expect( app.request_should_auth?(req) ).to be_false()
179
181
  req = @request_factory.post( '/api/v1/string' )
180
- app.request_should_auth?( req ).should be_true()
182
+ expect( app.request_should_auth?(req) ).to be_true()
181
183
  req = @request_factory.put( '/api/v1/string' )
182
- app.request_should_auth?( req ).should be_true()
184
+ expect( app.request_should_auth?(req) ).to be_true()
183
185
  req = @request_factory.delete( '/api/v1/string' )
184
- app.request_should_auth?( req ).should be_true()
186
+ expect( app.request_should_auth?(req) ).to be_true()
185
187
  req = @request_factory.options( '/api/v1/string' )
186
- app.request_should_auth?( req ).should be_true()
188
+ expect( app.request_should_auth?(req) ).to be_true()
187
189
  end
188
190
 
189
191
  it "allows auth criteria to be declared with a regexp and a block" do
@@ -194,11 +196,11 @@ describe Strelka::App::Auth do
194
196
  app = @app.new
195
197
 
196
198
  req = @request_factory.get( '/api/v1/regexp' )
197
- app.request_should_auth?( req ).should be_false()
199
+ expect( app.request_should_auth?(req) ).to be_false()
198
200
  req = @request_factory.get( '/api/v1/regexp/a_username' )
199
- app.request_should_auth?( req ).should be_true()
201
+ expect( app.request_should_auth?(req) ).to be_true()
200
202
  req = @request_factory.get( '/api/v1/regexp/%20not+a+username' )
201
- app.request_should_auth?( req ).should be_false()
203
+ expect( app.request_should_auth?(req) ).to be_false()
202
204
  end
203
205
 
204
206
  it "allows auth criteria to be declared with just a block" do
@@ -216,21 +218,21 @@ describe Strelka::App::Auth do
216
218
  app = @app.new
217
219
 
218
220
  req = @request_factory.get( '/api/v1/strong' )
219
- app.request_should_auth?( req ).should be_true()
221
+ expect( app.request_should_auth?(req) ).to be_true()
220
222
  req = @request_factory.get( '/api/v1/marlon_brando' )
221
- app.request_should_auth?( req ).should be_true()
223
+ expect( app.request_should_auth?(req) ).to be_true()
222
224
  req = @request_factory.post( '/api/v1/somewhere' )
223
- app.request_should_auth?( req ).should be_true()
225
+ expect( app.request_should_auth?(req) ).to be_true()
224
226
  req = @request_factory.put( '/api/v1/somewhere' )
225
227
  req.content_type = 'application/x-www-form-urlencoded'
226
- app.request_should_auth?( req ).should be_true()
228
+ expect( app.request_should_auth?(req) ).to be_true()
227
229
 
228
230
  req = @request_factory.get( '/api/v1/string' )
229
- app.request_should_auth?( req ).should be_false()
231
+ expect( app.request_should_auth?(req) ).to be_false()
230
232
  req = @request_factory.get( '/api/v1/marlon_brando/2' )
231
- app.request_should_auth?( req ).should be_false()
233
+ expect( app.request_should_auth?(req) ).to be_false()
232
234
  req = @request_factory.put( '/api/v1/somewhere' )
233
- app.request_should_auth?( req ).should be_false()
235
+ expect( app.request_should_auth?(req) ).to be_false()
234
236
 
235
237
  end
236
238
 
@@ -239,13 +241,13 @@ describe Strelka::App::Auth do
239
241
  app = @app.new
240
242
 
241
243
  req = @request_factory.get( '/api/v1/string' )
242
- app.request_should_auth?( req ).should be_false()
244
+ expect( app.request_should_auth?(req) ).to be_false()
243
245
  req = @request_factory.get( '/api/v1/strong' )
244
- app.request_should_auth?( req ).should be_true()
246
+ expect( app.request_should_auth?(req) ).to be_true()
245
247
  req = @request_factory.get( '/api/v1/stri' )
246
- app.request_should_auth?( req ).should be_true()
248
+ expect( app.request_should_auth?(req) ).to be_true()
247
249
  req = @request_factory.get( '/api/v1/string/long' )
248
- app.request_should_auth?( req ).should be_true()
250
+ expect( app.request_should_auth?(req) ).to be_true()
249
251
  end
250
252
 
251
253
  it "allows negative auth criteria to be declared with a regexp" do
@@ -253,17 +255,17 @@ describe Strelka::App::Auth do
253
255
  app = @app.new
254
256
 
255
257
  req = @request_factory.get( '/api/v1/stri' )
256
- app.request_should_auth?( req ).should be_false()
258
+ expect( app.request_should_auth?(req) ).to be_false()
257
259
  req = @request_factory.get( '/api/v1/stro' )
258
- app.request_should_auth?( req ).should be_false()
260
+ expect( app.request_should_auth?(req) ).to be_false()
259
261
  req = @request_factory.get( '/api/v1/string' ) # not right-bound
260
- app.request_should_auth?( req ).should be_false()
262
+ expect( app.request_should_auth?(req) ).to be_false()
261
263
  req = @request_factory.get( '/api/v1/string/long' )
262
- app.request_should_auth?( req ).should be_false()
264
+ expect( app.request_should_auth?(req) ).to be_false()
263
265
  req = @request_factory.get( '/api/v1/other/string/long' ) # Not left-bound
264
- app.request_should_auth?( req ).should be_false()
266
+ expect( app.request_should_auth?(req) ).to be_false()
265
267
  req = @request_factory.get( '/api/v1/chat' )
266
- app.request_should_auth?( req ).should be_true()
268
+ expect( app.request_should_auth?(req) ).to be_true()
267
269
  end
268
270
 
269
271
  it "allows negative auth criteria to be declared with a string and a block" do
@@ -272,17 +274,17 @@ describe Strelka::App::Auth do
272
274
  app = @app.new
273
275
 
274
276
  req = @request_factory.get( '/api/v1/string' )
275
- app.request_should_auth?( req ).should be_false()
277
+ expect( app.request_should_auth?(req) ).to be_false()
276
278
  req = @request_factory.get( '/api/v1/strong' )
277
- app.request_should_auth?( req ).should be_true()
279
+ expect( app.request_should_auth?(req) ).to be_true()
278
280
  req = @request_factory.post( '/api/v1/string' )
279
- app.request_should_auth?( req ).should be_true()
281
+ expect( app.request_should_auth?(req) ).to be_true()
280
282
  req = @request_factory.put( '/api/v1/string' )
281
- app.request_should_auth?( req ).should be_true()
283
+ expect( app.request_should_auth?(req) ).to be_true()
282
284
  req = @request_factory.delete( '/api/v1/string' )
283
- app.request_should_auth?( req ).should be_true()
285
+ expect( app.request_should_auth?(req) ).to be_true()
284
286
  req = @request_factory.options( '/api/v1/string' )
285
- app.request_should_auth?( req ).should be_true()
287
+ expect( app.request_should_auth?(req) ).to be_true()
286
288
  end
287
289
 
288
290
  it "allows negative auth criteria to be declared with a regexp and a block" do
@@ -293,13 +295,13 @@ describe Strelka::App::Auth do
293
295
  app = @app.new
294
296
 
295
297
  req = @request_factory.get( '/api/v1/regexp' )
296
- app.request_should_auth?( req ).should be_true()
298
+ expect( app.request_should_auth?(req) ).to be_true()
297
299
  req = @request_factory.get( '/api/v1/regexp/a_username' )
298
- app.request_should_auth?( req ).should be_true()
300
+ expect( app.request_should_auth?(req) ).to be_true()
299
301
  req = @request_factory.get( '/api/v1/regexp/%20not+a+username' )
300
- app.request_should_auth?( req ).should be_true()
302
+ expect( app.request_should_auth?(req) ).to be_true()
301
303
  req = @request_factory.get( '/api/v1/regexp/guest' )
302
- app.request_should_auth?( req ).should be_false()
304
+ expect( app.request_should_auth?(req) ).to be_false()
303
305
  end
304
306
 
305
307
  it "allows negative auth criteria to be declared with just a block" do
@@ -312,11 +314,11 @@ describe Strelka::App::Auth do
312
314
  app = @app.new
313
315
 
314
316
  req = @request_factory.get( '/api/v1/foom' )
315
- app.request_should_auth?( req ).should be_true()
317
+ expect( app.request_should_auth?(req) ).to be_true()
316
318
  req = @request_factory.post( '/api/v1/foom', :accept => 'text/plain, text/html; q=0.5' )
317
- app.request_should_auth?( req ).should be_true()
319
+ expect( app.request_should_auth?(req) ).to be_true()
318
320
  req = @request_factory.get( '/api/v1/foom', :accept => 'text/plain, text/html; q=0.5' )
319
- app.request_should_auth?( req ).should be_false()
321
+ expect( app.request_should_auth?(req) ).to be_false()
320
322
 
321
323
  end
322
324
 
@@ -326,9 +328,9 @@ describe Strelka::App::Auth do
326
328
  app = @app.new
327
329
 
328
330
  req = @request_factory.get( '/api/v1/string' )
329
- app.required_perms_for( req ).should == [ :stringperm ]
331
+ expect( app.required_perms_for(req) ).to eq( [ :stringperm ] )
330
332
  req = @request_factory.get( '/api/v1/strong' )
331
- app.required_perms_for( req ).should == []
333
+ expect( app.required_perms_for(req) ).to eq( [] )
332
334
  end
333
335
 
334
336
  it "allows perms criteria to be declared with a regexp" do
@@ -337,13 +339,13 @@ describe Strelka::App::Auth do
337
339
  app = @app.new
338
340
 
339
341
  req = @request_factory.get( '/api/v1/admin' )
340
- app.required_perms_for( req ).should == [ :admin ]
342
+ expect( app.required_perms_for(req) ).to eq( [ :admin ] )
341
343
  req = @request_factory.get( '/api/v1/admin/grant' )
342
- app.required_perms_for( req ).should == [ :admin, :grant ]
344
+ expect( app.required_perms_for(req) ).to eq( [ :admin, :grant ] )
343
345
  req = @request_factory.get( '/api/v1/users' )
344
- app.required_perms_for( req ).should == []
346
+ expect( app.required_perms_for(req) ).to eq( [] )
345
347
  req = @request_factory.get( '/api/v1/users/grant' )
346
- app.required_perms_for( req ).should == [ :grant ]
348
+ expect( app.required_perms_for(req) ).to eq( [ :grant ] )
347
349
  end
348
350
 
349
351
  it "allows perms criteria to be declared with a string and a block" do
@@ -354,9 +356,9 @@ describe Strelka::App::Auth do
354
356
  app = @app.new
355
357
 
356
358
  req = @request_factory.get( '/api/v1/string' )
357
- app.required_perms_for( req ).should == [ :stringperm, :otherperm ]
359
+ expect( app.required_perms_for(req) ).to eq( [ :stringperm, :otherperm ] )
358
360
  req = @request_factory.get( '/api/v1/strong' )
359
- app.required_perms_for( req ).should == []
361
+ expect( app.required_perms_for(req) ).to eq( [] )
360
362
  end
361
363
 
362
364
  it "allows multiple perms criteria for the same path" do
@@ -367,13 +369,13 @@ describe Strelka::App::Auth do
367
369
  app = @app.new
368
370
 
369
371
  req = @request_factory.get( '/api/v1' )
370
- app.required_perms_for( req ).should == [ :it_assets_webapp ]
372
+ expect( app.required_perms_for(req) ).to eq( [ :it_assets_webapp ] )
371
373
  req = @request_factory.post( '/api/v1' )
372
- app.required_perms_for( req ).should == [ :it_assets_webapp, :@sysadmin ]
374
+ expect( app.required_perms_for(req) ).to eq( [ :it_assets_webapp, :@sysadmin ] )
373
375
  req = @request_factory.get( '/api/v1/users' )
374
- app.required_perms_for( req ).should == [ :it_assets_webapp ]
376
+ expect( app.required_perms_for(req) ).to eq( [ :it_assets_webapp ] )
375
377
  req = @request_factory.post( '/api/v1/users' )
376
- app.required_perms_for( req ).should == [ :it_assets_webapp, :@sysadmin ]
378
+ expect( app.required_perms_for(req) ).to eq( [ :it_assets_webapp, :@sysadmin ] )
377
379
  end
378
380
 
379
381
  it "allows perms criteria to be declared with a regexp and a block" do
@@ -394,11 +396,11 @@ describe Strelka::App::Auth do
394
396
  app = @app.new
395
397
 
396
398
  req = @request_factory.get( '/api/v1/user' )
397
- app.required_perms_for( req ).should == [ :admin ]
399
+ expect( app.required_perms_for(req) ).to eq( [ :admin ] )
398
400
  req = @request_factory.get( '/api/v1/user/jzero' )
399
- app.required_perms_for( req ).should == [ :admin ]
401
+ expect( app.required_perms_for(req) ).to eq( [ :admin ] )
400
402
  req = @request_factory.get( '/api/v1/user/madeline' )
401
- app.required_perms_for( req ).should == [ :admin, :superuser ]
403
+ expect( app.required_perms_for(req) ).to eq( [ :admin, :superuser ] )
402
404
  end
403
405
 
404
406
  it "allows perms the same as the appid to be declared with just a block" do
@@ -408,11 +410,11 @@ describe Strelka::App::Auth do
408
410
  app = @app.new
409
411
 
410
412
  req = @request_factory.get( '/api/v1/accounts' )
411
- app.required_perms_for( req ).should == []
413
+ expect( app.required_perms_for(req) ).to eq( [] )
412
414
  req = @request_factory.post( '/api/v1/accounts', '' )
413
- app.required_perms_for( req ).should == [ :auth_test ]
415
+ expect( app.required_perms_for(req) ).to eq( [ :auth_test ] )
414
416
  req = @request_factory.put( '/api/v1/accounts/1', '' )
415
- app.required_perms_for( req ).should == [ :auth_test ]
417
+ expect( app.required_perms_for(req) ).to eq( [ :auth_test ] )
416
418
  end
417
419
 
418
420
  it "allows negative perms criteria to be declared with a string" do
@@ -420,9 +422,9 @@ describe Strelka::App::Auth do
420
422
  app = @app.new
421
423
 
422
424
  req = @request_factory.get( '/api/v1/string' )
423
- app.required_perms_for( req ).should be_empty()
425
+ expect( app.required_perms_for(req) ).to be_empty()
424
426
  req = @request_factory.get( '/api/v1/strong' )
425
- app.required_perms_for( req ).should == [ :auth_test ] # default == appid
427
+ expect( app.required_perms_for(req) ).to eq([ :auth_test ]) # default == appid
426
428
  end
427
429
 
428
430
  it "allows negative perms criteria to be declared with a regexp" do
@@ -430,11 +432,11 @@ describe Strelka::App::Auth do
430
432
  app = @app.new
431
433
 
432
434
  req = @request_factory.get( '/api/v1/signup' )
433
- app.required_perms_for( req ).should be_empty()
435
+ expect( app.required_perms_for(req) ).to be_empty()
434
436
  req = @request_factory.get( '/api/v1/signup/reapply' )
435
- app.required_perms_for( req ).should be_empty()
437
+ expect( app.required_perms_for(req) ).to be_empty()
436
438
  req = @request_factory.get( '/api/v1/index' )
437
- app.required_perms_for( req ).should == [ :auth_test ]
439
+ expect( app.required_perms_for(req) ).to eq( [ :auth_test ] )
438
440
  end
439
441
 
440
442
  it "allows negative perms criteria to be declared with a string and a block" do
@@ -444,11 +446,12 @@ describe Strelka::App::Auth do
444
446
  app = @app.new
445
447
 
446
448
  req = @request_factory.get( '/api/v1' )
447
- app.required_perms_for( req ).should be_empty()
449
+ expect( app.required_perms_for(req) ).to be_empty()
448
450
  req = @request_factory.post( '/api/v1' )
449
- app.required_perms_for( req ).should == [ :auth_test ] # default == appid
451
+ expect( app.required_perms_for(req) ).to eq([ :auth_test ]) # default == appid
450
452
  req = @request_factory.get( '/api/v1/users' )
451
- app.required_perms_for( req ).should == [ :auth_test ]
453
+
454
+ expect( app.required_perms_for(req) ).to eq( [ :auth_test ] )
452
455
  end
453
456
 
454
457
  it "allows negative perms criteria to be declared with a regexp and a block" do
@@ -460,15 +463,15 @@ describe Strelka::App::Auth do
460
463
  app = @app.new
461
464
 
462
465
  req = @request_factory.get( '/api/v1/collection' )
463
- app.required_perms_for( req ).should == [ :auth_test ]
466
+ expect( app.required_perms_for(req) ).to eq( [ :auth_test ] )
464
467
  req = @request_factory.get( '/api/v1/collection/degasse' )
465
- app.required_perms_for( req ).should be_empty()
468
+ expect( app.required_perms_for(req) ).to be_empty()
466
469
  req = @request_factory.get( '/api/v1/collection/ione' )
467
- app.required_perms_for( req ).should be_empty()
470
+ expect( app.required_perms_for(req) ).to be_empty()
468
471
  req = @request_factory.get( '/api/v1/collection/champhion' )
469
- app.required_perms_for( req ).should be_empty()
472
+ expect( app.required_perms_for(req) ).to be_empty()
470
473
  req = @request_factory.get( '/api/v1/collection/calindra' )
471
- app.required_perms_for( req ).should == [ :auth_test ]
474
+ expect( app.required_perms_for(req) ).to eq( [ :auth_test ] )
472
475
  end
473
476
 
474
477
  it "allows negative perms criteria to be declared with just a block" do
@@ -479,9 +482,9 @@ describe Strelka::App::Auth do
479
482
  app = @app.new
480
483
 
481
484
  req = @request_factory.get( '/api/v1/collection', x_forwarded_for: '10.0.1.68' )
482
- app.required_perms_for( req ).should be_empty()
485
+ expect( app.required_perms_for(req) ).to be_empty()
483
486
  req = @request_factory.get( '/api/v1/collection', x_forwarded_for: '192.0.43.10' )
484
- app.required_perms_for( req ).should == [ :auth_test ]
487
+ expect( app.required_perms_for(req) ).to eq( [ :auth_test ] )
485
488
  end
486
489
 
487
490
 
@@ -503,8 +506,8 @@ describe Strelka::App::Auth do
503
506
  req = @request_factory.get( '/api/v1/onlyperms' )
504
507
 
505
508
  app = @app.new
506
- app.auth_provider.should_not_receive( :authenticate )
507
- app.auth_provider.should_receive( :authorize )
509
+ expect( app.auth_provider ).to_not receive( :authenticate )
510
+ expect( app.auth_provider ).to receive( :authorize )
508
511
 
509
512
  app.handle( req )
510
513
  end
@@ -513,8 +516,8 @@ describe Strelka::App::Auth do
513
516
  req = @request_factory.get( '/api/v1/onlyauth' )
514
517
 
515
518
  app = @app.new
516
- app.auth_provider.should_receive( :authenticate )
517
- app.auth_provider.should_not_receive( :authorize )
519
+ expect( app.auth_provider ).to receive( :authenticate )
520
+ expect( app.auth_provider ).to_not receive( :authorize )
518
521
 
519
522
  app.handle( req )
520
523
  end
@@ -523,8 +526,8 @@ describe Strelka::App::Auth do
523
526
  req = @request_factory.get( '/api/v1/both' )
524
527
 
525
528
  app = @app.new
526
- app.auth_provider.should_receive( :authenticate )
527
- app.auth_provider.should_receive( :authorize )
529
+ expect( app.auth_provider ).to receive( :authenticate )
530
+ expect( app.auth_provider ).to receive( :authorize )
528
531
 
529
532
  app.handle( req )
530
533
  end
@@ -533,8 +536,8 @@ describe Strelka::App::Auth do
533
536
  req = @request_factory.get( '/api/v1/neither' )
534
537
 
535
538
  app = @app.new
536
- app.auth_provider.should_not_receive( :authenticate )
537
- app.auth_provider.should_not_receive( :authorize )
539
+ expect( app.auth_provider ).to_not receive( :authenticate )
540
+ expect( app.auth_provider ).to_not receive( :authorize )
538
541
 
539
542
  app.handle( req )
540
543
  end
@@ -552,8 +555,8 @@ describe Strelka::App::Auth do
552
555
  req = @request_factory.get( '/api/v1/onlyperms' )
553
556
 
554
557
  app = @app.new
555
- app.auth_provider.should_not_receive( :authenticate )
556
- app.auth_provider.should_not_receive( :authorize )
558
+ expect( app.auth_provider ).to_not receive( :authenticate )
559
+ expect( app.auth_provider ).to_not receive( :authorize )
557
560
 
558
561
  app.handle( req )
559
562
  end
@@ -562,8 +565,8 @@ describe Strelka::App::Auth do
562
565
  req = @request_factory.get( '/api/v1/onlyauth' )
563
566
 
564
567
  app = @app.new
565
- app.auth_provider.should_receive( :authenticate )
566
- app.auth_provider.should_receive( :authorize )
568
+ expect( app.auth_provider ).to receive( :authenticate )
569
+ expect( app.auth_provider ).to receive( :authorize )
567
570
 
568
571
  app.handle( req )
569
572
  end
@@ -572,8 +575,8 @@ describe Strelka::App::Auth do
572
575
  req = @request_factory.get( '/api/v1/both' )
573
576
 
574
577
  app = @app.new
575
- app.auth_provider.should_receive( :authenticate )
576
- app.auth_provider.should_not_receive( :authorize )
578
+ expect( app.auth_provider ).to receive( :authenticate )
579
+ expect( app.auth_provider ).to_not receive( :authorize )
577
580
 
578
581
  app.handle( req )
579
582
  end
@@ -582,8 +585,8 @@ describe Strelka::App::Auth do
582
585
  req = @request_factory.get( '/api/v1/neither' )
583
586
 
584
587
  app = @app.new
585
- app.auth_provider.should_not_receive( :authenticate )
586
- app.auth_provider.should_receive( :authorize )
588
+ expect( app.auth_provider ).to_not receive( :authenticate )
589
+ expect( app.auth_provider ).to receive( :authorize )
587
590
 
588
591
  app.handle( req )
589
592
  end
@@ -611,8 +614,8 @@ describe Strelka::App::Auth do
611
614
  req = @request_factory.get( '/api/v1/onlyperms' )
612
615
 
613
616
  app = @app.new
614
- app.auth_provider.should_receive( :authenticate )
615
- app.auth_provider.should_receive( :authorize )
617
+ expect( app.auth_provider ).to receive( :authenticate )
618
+ expect( app.auth_provider ).to receive( :authorize )
616
619
 
617
620
  app.handle( req )
618
621
  end
@@ -621,8 +624,8 @@ describe Strelka::App::Auth do
621
624
  req = @request_factory.get( '/api/v1/onlyauth' )
622
625
 
623
626
  app = @app.new
624
- app.auth_provider.should_not_receive( :authenticate )
625
- app.auth_provider.should_not_receive( :authorize )
627
+ expect( app.auth_provider ).to_not receive( :authenticate )
628
+ expect( app.auth_provider ).to_not receive( :authorize )
626
629
 
627
630
  app.handle( req )
628
631
  end
@@ -631,8 +634,8 @@ describe Strelka::App::Auth do
631
634
  req = @request_factory.get( '/api/v1/both' )
632
635
 
633
636
  app = @app.new
634
- app.auth_provider.should_not_receive( :authenticate )
635
- app.auth_provider.should_receive( :authorize )
637
+ expect( app.auth_provider ).to_not receive( :authenticate )
638
+ expect( app.auth_provider ).to receive( :authorize )
636
639
 
637
640
  app.handle( req )
638
641
  end
@@ -641,8 +644,8 @@ describe Strelka::App::Auth do
641
644
  req = @request_factory.get( '/api/v1/neither' )
642
645
 
643
646
  app = @app.new
644
- app.auth_provider.should_receive( :authenticate )
645
- app.auth_provider.should_not_receive( :authorize )
647
+ expect( app.auth_provider ).to receive( :authenticate )
648
+ expect( app.auth_provider ).to_not receive( :authorize )
646
649
 
647
650
  app.handle( req )
648
651
  end
@@ -660,8 +663,8 @@ describe Strelka::App::Auth do
660
663
  req = @request_factory.get( '/api/v1/onlyperms' )
661
664
 
662
665
  app = @app.new
663
- app.auth_provider.should_receive( :authenticate )
664
- app.auth_provider.should_not_receive( :authorize )
666
+ expect( app.auth_provider ).to receive( :authenticate )
667
+ expect( app.auth_provider ).to_not receive( :authorize )
665
668
 
666
669
  app.handle( req )
667
670
  end
@@ -670,8 +673,8 @@ describe Strelka::App::Auth do
670
673
  req = @request_factory.get( '/api/v1/onlyauth' )
671
674
 
672
675
  app = @app.new
673
- app.auth_provider.should_not_receive( :authenticate )
674
- app.auth_provider.should_receive( :authorize )
676
+ expect( app.auth_provider ).to_not receive( :authenticate )
677
+ expect( app.auth_provider ).to receive( :authorize )
675
678
 
676
679
  app.handle( req )
677
680
  end
@@ -680,8 +683,8 @@ describe Strelka::App::Auth do
680
683
  req = @request_factory.get( '/api/v1/both' )
681
684
 
682
685
  app = @app.new
683
- app.auth_provider.should_not_receive( :authenticate )
684
- app.auth_provider.should_not_receive( :authorize )
686
+ expect( app.auth_provider ).to_not receive( :authenticate )
687
+ expect( app.auth_provider ).to_not receive( :authorize )
685
688
 
686
689
  app.handle( req )
687
690
  end
@@ -690,8 +693,8 @@ describe Strelka::App::Auth do
690
693
  req = @request_factory.get( '/api/v1/neither' )
691
694
 
692
695
  app = @app.new
693
- app.auth_provider.should_receive( :authenticate )
694
- app.auth_provider.should_receive( :authorize )
696
+ expect( app.auth_provider ).to receive( :authenticate )
697
+ expect( app.auth_provider ).to receive( :authorize )
695
698
 
696
699
  app.handle( req )
697
700
  end
@@ -712,8 +715,8 @@ describe Strelka::App::Auth do
712
715
  req = @request_factory.get( '/api/v1/admin/upload' )
713
716
 
714
717
  app = @app.new
715
- app.auth_provider.stub!( :authenticate ).and_return( :credentials )
716
- app.auth_provider.should_receive( :authorize ).with( :credentials, req, [:admin, :upload] )
718
+ allow( app.auth_provider ).to receive( :authenticate ).and_return( :credentials )
719
+ expect( app.auth_provider ).to receive( :authorize ).with( :credentials, req, [:admin, :upload] )
717
720
 
718
721
  app.handle( req )
719
722
  end