strelka 0.0.1.pre.200 → 0.0.1.pre.203
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.
- data/ChangeLog +36 -4
- data/lib/strelka/app/parameters.rb +37 -3
- data/lib/strelka/mixins.rb +6 -1
- data/lib/strelka/paramvalidator.rb +20 -4
- data/spec/lib/helpers.rb +149 -0
- data/spec/strelka/app/parameters_spec.rb +2 -2
- data/spec/strelka/authprovider/basic_spec.rb +16 -25
- data/spec/strelka/authprovider_spec.rb +1 -6
- data/spec/strelka/httprequest_spec.rb +1 -1
- data/spec/strelka/paramvalidator_spec.rb +19 -7
- data/spec/strelka/router/default_spec.rb +2 -9
- data/spec/strelka/router/exclusive_spec.rb +2 -9
- data.tar.gz.sig +0 -0
- metadata +34 -34
- metadata.gz.sig +0 -0
data/ChangeLog
CHANGED
@@ -1,12 +1,44 @@
|
|
1
|
+
2012-04-21 Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
* lib/strelka/app/parameters.rb:
|
4
|
+
Add some better docs for the :parameters plugin
|
5
|
+
[f0c8f37e24d7] [tip]
|
6
|
+
|
7
|
+
2012-04-20 Michael Granger <ged@FaerieMUD.org>
|
8
|
+
|
9
|
+
* lib/strelka/app.rb, lib/strelka/app/errors.rb,
|
10
|
+
spec/strelka/app/errors_spec.rb, spec/strelka/app_spec.rb:
|
11
|
+
Set the status info in the transaction notes on status responses.
|
12
|
+
[cd78c839f328]
|
13
|
+
|
14
|
+
* lib/strelka/httprequest.rb, lib/strelka/httpresponse.rb,
|
15
|
+
lib/strelka/mixins.rb, spec/strelka/app/filters_spec.rb,
|
16
|
+
spec/strelka/httpresponse_spec.rb:
|
17
|
+
Make HTTPResponse share the request's notes Hash.
|
18
|
+
[9d7fb3d16c12]
|
19
|
+
|
20
|
+
* lib/strelka/app/errors.rb:
|
21
|
+
Allow re-throwing with the status_info struct
|
22
|
+
[90e1c9e72ae7]
|
23
|
+
|
24
|
+
* bin/strelka, lib/strelka/app.rb:
|
25
|
+
Add the local 'lib' directory to the discovery path.
|
26
|
+
|
27
|
+
This makes it easier to use the 'strelka' command to interact with
|
28
|
+
apps during development, and also some kinds of deployment
|
29
|
+
environments like 'supervise'-style ones.
|
30
|
+
[612140994e8b]
|
31
|
+
|
1
32
|
2012-04-19 Michael Granger <ged@FaerieMUD.org>
|
2
33
|
|
3
|
-
* lib/strelka/
|
4
|
-
|
5
|
-
|
34
|
+
* bin/strelka, lib/strelka.rb, lib/strelka/app.rb:
|
35
|
+
Use a local data/<something> directory as the Strelka datadir for
|
36
|
+
the 'strelka' command.
|
37
|
+
[c3e9ce4035b6]
|
6
38
|
|
7
39
|
* lib/strelka/plugins.rb:
|
8
40
|
Moving application stack dump function to the PluginLoader mixin
|
9
|
-
[3c35f0dd2089]
|
41
|
+
[3c35f0dd2089]
|
10
42
|
|
11
43
|
2012-04-18 Michael Granger <ged@FaerieMUD.org>
|
12
44
|
|
@@ -10,8 +10,13 @@ require 'strelka/paramvalidator'
|
|
10
10
|
|
11
11
|
# Parameter validation and untainting for Strelka apps.
|
12
12
|
#
|
13
|
-
#
|
14
|
-
#
|
13
|
+
# When you include the +:parameters+ plugin, you can declare valid parameters, specify
|
14
|
+
# constraints that describe what they should contain, and automatically untaint the incoming
|
15
|
+
# values that match.
|
16
|
+
#
|
17
|
+
# == Parameter Declaration
|
18
|
+
#
|
19
|
+
# Parameters are declared using the +param+ declarative:
|
15
20
|
#
|
16
21
|
# class UserManager < Strelka::App
|
17
22
|
#
|
@@ -22,9 +27,37 @@ require 'strelka/paramvalidator'
|
|
22
27
|
# param :id, /\d+/, "The user's numeric ID"
|
23
28
|
# param :mode, ['add', 'remove']
|
24
29
|
#
|
30
|
+
# The first item is the parameter _key_, which corresponds to the field 'name' attribute for
|
31
|
+
# a form, or the key for JSON or YAML data.
|
32
|
+
#
|
33
|
+
# The second item is the _constraint_, which specifies what the value in that parameter should
|
34
|
+
# look like if it's valid. This can be one of several things:
|
35
|
+
#
|
36
|
+
# [a Regexp]::
|
37
|
+
# The parameter value, as a String, is matched against the Regexp and validates if the
|
38
|
+
# pattern matches. If the Regexp contains one match group, and the pattern matches, the
|
39
|
+
# validated value will be the capture from that group. If it contains two or more match
|
40
|
+
# groups, the new value is an Array of the captures from the match. If the pattern contains
|
41
|
+
# at least one named capture group, the value will be a Hash of the captures from the named
|
42
|
+
# capture groups. Note that you cannot intermix named and positional capture groups.
|
43
|
+
# [a Symbol]::
|
44
|
+
# The parameter value is matched using a built-in constraint. The current built-in
|
45
|
+
# constraints are documented in the ParamValidator API documentation. As a shortcut, if the
|
46
|
+
# parameter's _key_ is the same as a built-in constraint, you can omit the _constraint_ from
|
47
|
+
# the declaration.
|
48
|
+
# [a Proc or Method]::
|
49
|
+
# The parameter (or parameters in the case where there are more than one value) are passed to
|
50
|
+
# the given Proc, and the Proc should return what the validated value of the parameter should
|
51
|
+
# be. If it's invalid, the Proc should raise a RuntimeError.
|
52
|
+
#
|
53
|
+
# == Parameter Routing
|
54
|
+
#
|
55
|
+
# The inclusion of this plugin also allows you to use parameters in your routes:
|
56
|
+
#
|
25
57
|
# # :username gets validated and merged into query args; URI parameters
|
26
58
|
# # clobber query params
|
27
|
-
# get '/info/:username'
|
59
|
+
# get '/info/:username' do |req|
|
60
|
+
# req.params.add( :id, /[XRT]\d{4}-\d{8}/ )
|
28
61
|
# req.params.okay?
|
29
62
|
# req.params[:username]
|
30
63
|
# req.params.values_at( :id, :username )
|
@@ -35,6 +68,7 @@ require 'strelka/paramvalidator'
|
|
35
68
|
#
|
36
69
|
# end # class UserManager
|
37
70
|
#
|
71
|
+
# [:FIXME:] Add more docs
|
38
72
|
module Strelka::App::Parameters
|
39
73
|
extend Strelka::Plugin
|
40
74
|
|
data/lib/strelka/mixins.rb
CHANGED
@@ -357,7 +357,12 @@ module Strelka
|
|
357
357
|
status_info = http_status
|
358
358
|
else
|
359
359
|
message ||= HTTP::STATUS_NAME[ http_status ]
|
360
|
-
status_info = {
|
360
|
+
status_info = {
|
361
|
+
status: http_status,
|
362
|
+
message: message,
|
363
|
+
headers: headers,
|
364
|
+
backtrace: caller(1),
|
365
|
+
}
|
361
366
|
end
|
362
367
|
|
363
368
|
throw :finish, status_info
|
@@ -220,7 +220,7 @@ class Strelka::ParamValidator < ::FormValidator
|
|
220
220
|
### Fetch the constraint/s that apply to the parameter with the given
|
221
221
|
### +name+.
|
222
222
|
def constraint_for( name )
|
223
|
-
constraint = self.profile[:constraints][ name.
|
223
|
+
constraint = self.profile[:constraints][ name.to_s ] or
|
224
224
|
raise ScriptError, "no parameter %p defined" % [ name ]
|
225
225
|
return constraint
|
226
226
|
end
|
@@ -270,11 +270,12 @@ class Strelka::ParamValidator < ::FormValidator
|
|
270
270
|
### Add a validation for a parameter with the specified +name+. The +args+ can include
|
271
271
|
### a constraint, a description, and one or more flags.
|
272
272
|
def add( name, *args, &block )
|
273
|
-
name = name.
|
273
|
+
name = name.to_s
|
274
274
|
raise ArgumentError,
|
275
275
|
"parameter %p is already defined; perhaps you meant to use #override?" % [name] if
|
276
276
|
self.param_names.include?( name )
|
277
277
|
|
278
|
+
self.log.debug "Adding parameter '%s' to profile" % [ name ]
|
278
279
|
self.set_param( name, *args, &block )
|
279
280
|
end
|
280
281
|
|
@@ -282,11 +283,12 @@ class Strelka::ParamValidator < ::FormValidator
|
|
282
283
|
### Replace the existing parameter with the specified +name+. The +args+ replace
|
283
284
|
### the existing description, constraints, and flags. See #add for details.
|
284
285
|
def override( name, *args, &block )
|
285
|
-
name = name.
|
286
|
+
name = name.to_s
|
286
287
|
raise ArgumentError,
|
287
288
|
"no parameter %p defined; perhaps you meant to use #add?" % [name] unless
|
288
289
|
self.param_names.include?( name )
|
289
290
|
|
291
|
+
self.log.debug "Overriding parameter '%s' in profile" % [ name ]
|
290
292
|
self.set_param( name, *args, &block )
|
291
293
|
end
|
292
294
|
|
@@ -397,6 +399,8 @@ class Strelka::ParamValidator < ::FormValidator
|
|
397
399
|
else
|
398
400
|
self.profile[:untaint_constraint_fields].delete( :name )
|
399
401
|
end
|
402
|
+
|
403
|
+
self.revalidate if self.validated?
|
400
404
|
end
|
401
405
|
|
402
406
|
|
@@ -431,6 +435,12 @@ class Strelka::ParamValidator < ::FormValidator
|
|
431
435
|
alias_method :has_args?, :args?
|
432
436
|
|
433
437
|
|
438
|
+
### Returns +true+ if the parameters have been validated.
|
439
|
+
def validated?
|
440
|
+
return !@raw_form.empty?
|
441
|
+
end
|
442
|
+
|
443
|
+
|
434
444
|
### Returns +true+ if any fields are missing or contain invalid values.
|
435
445
|
def errors?
|
436
446
|
return !self.okay?
|
@@ -553,8 +563,14 @@ class Strelka::ParamValidator < ::FormValidator
|
|
553
563
|
### re-validate the resulting values.
|
554
564
|
def merge!( params )
|
555
565
|
return if params.empty?
|
556
|
-
|
557
566
|
self.log.debug "Merging parameters for revalidation: %p" % [ params ]
|
567
|
+
self.revalidate( params )
|
568
|
+
end
|
569
|
+
|
570
|
+
|
571
|
+
### Clear existing validation information and re-check against the
|
572
|
+
### current state of the profile.
|
573
|
+
def revalidate( params={} )
|
558
574
|
@missing_fields.clear
|
559
575
|
@unknown_fields.clear
|
560
576
|
@required_fields.clear
|
data/spec/lib/helpers.rb
CHANGED
@@ -145,6 +145,155 @@ module Strelka::SpecHelpers
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
+
# finish_with matcher
|
149
|
+
class FinishWithMatcher
|
150
|
+
|
151
|
+
### Create a new matcher for the specified +status+, +expected_message+, and
|
152
|
+
### +expected_headers+.
|
153
|
+
def initialize( status, expected_message=nil, expected_headers={} )
|
154
|
+
|
155
|
+
# Allow headers, but no message
|
156
|
+
if expected_message.is_a?( Hash )
|
157
|
+
expected_headers = expected_message
|
158
|
+
expected_message = nil
|
159
|
+
end
|
160
|
+
|
161
|
+
@expected_status = status
|
162
|
+
@expected_message = expected_message
|
163
|
+
@expected_headers = expected_headers || {}
|
164
|
+
|
165
|
+
@failure = nil
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
######
|
170
|
+
public
|
171
|
+
######
|
172
|
+
|
173
|
+
##
|
174
|
+
# The data structures expected to be part of the response's status_info.
|
175
|
+
attr_reader :expected_status, :expected_message, :expected_headers
|
176
|
+
|
177
|
+
|
178
|
+
### Also expect a header with the given +name+ and +value+ from the response.
|
179
|
+
def and_header( name, value=nil )
|
180
|
+
if name.is_a?( Hash )
|
181
|
+
self.expected_headers.merge!( name )
|
182
|
+
else
|
183
|
+
self.expected_headers[ name ] = value
|
184
|
+
end
|
185
|
+
return self
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
### RSpec matcher API -- call the +given_proc+ and ensure that it behaves in
|
190
|
+
### the expected manner.
|
191
|
+
def matches?( given_proc )
|
192
|
+
result = nil
|
193
|
+
status_info = catch( :finish ) do
|
194
|
+
given_proc.call
|
195
|
+
nil
|
196
|
+
end
|
197
|
+
|
198
|
+
return self.check_finish( status_info ) &&
|
199
|
+
self.check_status_code( status_info ) &&
|
200
|
+
self.check_message( status_info ) &&
|
201
|
+
self.check_headers( status_info )
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
### Check the result from calling the proc to ensure it's a status
|
206
|
+
### info Hash, returning true if so, or setting the failure message and
|
207
|
+
### returning false if not.
|
208
|
+
def check_finish( status_info )
|
209
|
+
return true if status_info && status_info.is_a?( Hash )
|
210
|
+
@failure = "an abnormal status"
|
211
|
+
return false
|
212
|
+
end
|
213
|
+
|
214
|
+
|
215
|
+
### Check the result's status code against the expectation, returning true if
|
216
|
+
### it was the same, or setting the failure message and returning false if not.
|
217
|
+
def check_status_code( status_info )
|
218
|
+
return true if status_info[:status] == self.expected_status
|
219
|
+
@failure = "a %d status, but got %d instead" %
|
220
|
+
[ self.expected_status, status_info[:status] ]
|
221
|
+
return false
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
### Check the result's status message against the expectation, returning true if
|
226
|
+
### it was present and matched the expectation, or setting the failure message
|
227
|
+
### and returning false if not.
|
228
|
+
def check_message( status_info )
|
229
|
+
msg = self.expected_message or return true
|
230
|
+
|
231
|
+
if msg.respond_to?( :match )
|
232
|
+
return true if msg.match( status_info[:message] )
|
233
|
+
@failure = "a message matching %p, but got: %p" % [ msg, status_info[:message] ]
|
234
|
+
return false
|
235
|
+
else
|
236
|
+
return true if msg == status_info[:message]
|
237
|
+
@failure = "the message %p, but got: %p" % [ msg, status_info[:message] ]
|
238
|
+
return false
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
|
243
|
+
### Check the result's headers against the expectation, returning true if all
|
244
|
+
### expected headers were present and set to expected values, or setting the failure
|
245
|
+
### message and returning false if not.
|
246
|
+
def check_headers( status_info )
|
247
|
+
headers = self.expected_headers or return true
|
248
|
+
return true if headers.empty?
|
249
|
+
|
250
|
+
status_headers = status_info[:headers]
|
251
|
+
headers.each do |name, value|
|
252
|
+
unless status_value = status_headers[ name ]
|
253
|
+
@failure = "a %s header" % [ name ]
|
254
|
+
return false
|
255
|
+
end
|
256
|
+
|
257
|
+
if value.respond_to?( :match )
|
258
|
+
unless value.match( status_value )
|
259
|
+
@failure = "a %s header matching %p, but got %p" %
|
260
|
+
[ name, value, status_value ]
|
261
|
+
return false
|
262
|
+
end
|
263
|
+
else
|
264
|
+
unless value == status_value
|
265
|
+
@failure = "the %s header %p, but got %p" %
|
266
|
+
[ name, value, status_value ]
|
267
|
+
return false
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
return true
|
273
|
+
end
|
274
|
+
|
275
|
+
|
276
|
+
### Return a message suitable for describing when the matcher fails when it should succeed.
|
277
|
+
def failure_message_for_should
|
278
|
+
return "expected response to finish_with %s" % [ @failure ]
|
279
|
+
end
|
280
|
+
|
281
|
+
|
282
|
+
### Return a message suitable for describing when the matcher succeeds when it should fail.
|
283
|
+
def failure_message_for_should_not
|
284
|
+
return "expected response not to finish_with %s" % [ @failure ]
|
285
|
+
end
|
286
|
+
|
287
|
+
|
288
|
+
end # class FinishWithMatcher
|
289
|
+
|
290
|
+
|
291
|
+
### Match a response thrown via the +finish_with+ function.
|
292
|
+
def finish_with( status, message=nil, headers={} )
|
293
|
+
FinishWithMatcher.new( status, message, headers )
|
294
|
+
end
|
295
|
+
|
296
|
+
|
148
297
|
end
|
149
298
|
|
150
299
|
|
@@ -69,7 +69,7 @@ describe Strelka::App::Parameters do
|
|
69
69
|
param :username, /\w+/i
|
70
70
|
end
|
71
71
|
|
72
|
-
@app.paramvalidator.param_names.should == [
|
72
|
+
@app.paramvalidator.param_names.should == [ 'username' ]
|
73
73
|
end
|
74
74
|
|
75
75
|
|
@@ -79,7 +79,7 @@ describe Strelka::App::Parameters do
|
|
79
79
|
end
|
80
80
|
subapp = Class.new( @app )
|
81
81
|
|
82
|
-
subapp.paramvalidator.param_names.should == [
|
82
|
+
subapp.paramvalidator.param_names.should == [ 'username' ]
|
83
83
|
end
|
84
84
|
|
85
85
|
describe "instance" do
|
@@ -77,22 +77,13 @@ describe Strelka::AuthProvider::Basic do
|
|
77
77
|
|
78
78
|
context "unconfigured" do
|
79
79
|
|
80
|
-
before( :each ) do
|
81
|
-
@expected_info = {
|
82
|
-
status: 401,
|
83
|
-
message: "Requires authentication.",
|
84
|
-
headers: {
|
85
|
-
www_authenticate: "Basic realm=test-app"
|
86
|
-
}
|
87
|
-
}
|
88
|
-
end
|
89
|
-
|
90
80
|
it "rejects a request with no Authorization header" do
|
91
81
|
req = @request_factory.get( '/admin/console' )
|
92
82
|
|
93
83
|
expect {
|
94
84
|
@provider.authenticate( req )
|
95
|
-
}.to
|
85
|
+
}.to finish_with( HTTP::UNAUTHORIZED, /requires authentication/i ).
|
86
|
+
and_header( www_authenticate: "Basic realm=test-app" )
|
96
87
|
end
|
97
88
|
|
98
89
|
it "rejects a request with credentials" do
|
@@ -101,7 +92,8 @@ describe Strelka::AuthProvider::Basic do
|
|
101
92
|
|
102
93
|
expect {
|
103
94
|
@provider.authenticate( req )
|
104
|
-
}.to
|
95
|
+
}.to finish_with( HTTP::UNAUTHORIZED, /requires authentication/i ).
|
96
|
+
and_header( www_authenticate: "Basic realm=test-app" )
|
105
97
|
end
|
106
98
|
|
107
99
|
end
|
@@ -110,13 +102,6 @@ describe Strelka::AuthProvider::Basic do
|
|
110
102
|
context "configured with at least one user" do
|
111
103
|
|
112
104
|
before( :each ) do
|
113
|
-
@expected_info = {
|
114
|
-
status: 401,
|
115
|
-
message: "Requires authentication.",
|
116
|
-
headers: {
|
117
|
-
www_authenticate: "Basic realm=Pern"
|
118
|
-
}
|
119
|
-
}
|
120
105
|
described_class.configure( @config )
|
121
106
|
end
|
122
107
|
|
@@ -124,7 +109,8 @@ describe Strelka::AuthProvider::Basic do
|
|
124
109
|
req = @request_factory.get( '/admin/console' )
|
125
110
|
expect {
|
126
111
|
@provider.authenticate( req )
|
127
|
-
}.to
|
112
|
+
}.to finish_with( HTTP::UNAUTHORIZED, /requires authentication/i ).
|
113
|
+
and_header( www_authenticate: "Basic realm=Pern" )
|
128
114
|
end
|
129
115
|
|
130
116
|
it "rejects a request with an authorization header for some other auth scheme" do
|
@@ -141,7 +127,8 @@ describe Strelka::AuthProvider::Basic do
|
|
141
127
|
|
142
128
|
expect {
|
143
129
|
@provider.authenticate( req )
|
144
|
-
}.to
|
130
|
+
}.to finish_with( HTTP::UNAUTHORIZED, /requires authentication/i ).
|
131
|
+
and_header( www_authenticate: "Basic realm=Pern" )
|
145
132
|
end
|
146
133
|
|
147
134
|
it "rejects a request with malformed credentials (no ':')" do
|
@@ -150,7 +137,8 @@ describe Strelka::AuthProvider::Basic do
|
|
150
137
|
|
151
138
|
expect {
|
152
139
|
@provider.authenticate( req )
|
153
|
-
}.to
|
140
|
+
}.to finish_with( HTTP::UNAUTHORIZED, /requires authentication/i ).
|
141
|
+
and_header( www_authenticate: "Basic realm=Pern" )
|
154
142
|
end
|
155
143
|
|
156
144
|
it "rejects a request with malformed credentials (invalid base64)" do
|
@@ -159,7 +147,8 @@ describe Strelka::AuthProvider::Basic do
|
|
159
147
|
|
160
148
|
expect {
|
161
149
|
@provider.authenticate( req )
|
162
|
-
}.to
|
150
|
+
}.to finish_with( HTTP::UNAUTHORIZED, /requires authentication/i ).
|
151
|
+
and_header( www_authenticate: "Basic realm=Pern" )
|
163
152
|
end
|
164
153
|
|
165
154
|
it "rejects a request with non-existant user credentials" do
|
@@ -168,7 +157,8 @@ describe Strelka::AuthProvider::Basic do
|
|
168
157
|
|
169
158
|
expect {
|
170
159
|
@provider.authenticate( req )
|
171
|
-
}.to
|
160
|
+
}.to finish_with( HTTP::UNAUTHORIZED, /requires authentication/i ).
|
161
|
+
and_header( www_authenticate: "Basic realm=Pern" )
|
172
162
|
end
|
173
163
|
|
174
164
|
it "rejects a request with a valid user, but the wrong password" do
|
@@ -177,7 +167,8 @@ describe Strelka::AuthProvider::Basic do
|
|
177
167
|
|
178
168
|
expect {
|
179
169
|
@provider.authenticate( req )
|
180
|
-
}.to
|
170
|
+
}.to finish_with( HTTP::UNAUTHORIZED, /requires authentication/i ).
|
171
|
+
and_header( www_authenticate: "Basic realm=Pern" )
|
181
172
|
end
|
182
173
|
|
183
174
|
it "accepts a request with valid credentials" do
|
@@ -79,16 +79,11 @@ describe Strelka::AuthProvider do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "fails with a 403 (Forbidden) if the app's authz callback returns false" do
|
82
|
-
expected_info = {
|
83
|
-
status: 403,
|
84
|
-
message: "You are not authorized to access this resource.",
|
85
|
-
headers: {}
|
86
|
-
}
|
87
82
|
req = @request_factory.get( '/admin/console' )
|
88
83
|
|
89
84
|
expect {
|
90
85
|
@provider.authorize( 'anonymous', req ) { false }
|
91
|
-
}.to
|
86
|
+
}.to finish_with( HTTP::FORBIDDEN, /you are not authorized/i )
|
92
87
|
end
|
93
88
|
|
94
89
|
end
|
@@ -51,21 +51,33 @@ describe Strelka::ParamValidator do
|
|
51
51
|
|
52
52
|
it "allows constraints to be added" do
|
53
53
|
@validator.add( :a_field, :string )
|
54
|
-
@validator.param_names.should include(
|
54
|
+
@validator.param_names.should include( 'a_field' )
|
55
55
|
end
|
56
56
|
|
57
57
|
it "doesn't allow a parameter to be added twice" do
|
58
58
|
@validator.add( :a_field, :string )
|
59
59
|
expect {
|
60
60
|
@validator.add( :a_field, :string )
|
61
|
-
}.to raise_error( /parameter
|
62
|
-
@validator.param_names.should include(
|
61
|
+
}.to raise_error( /parameter "a_field" is already defined/i )
|
62
|
+
@validator.param_names.should include( 'a_field' )
|
63
|
+
end
|
64
|
+
|
65
|
+
it "re-validates if profile is modified" do
|
66
|
+
@validator.add( :a_field, :string )
|
67
|
+
@validator.validate( 'a_field' => 'a string!' )
|
68
|
+
@validator.should_not have_errors()
|
69
|
+
@validator.should be_okay()
|
70
|
+
|
71
|
+
@validator.override( :a_field, :integer )
|
72
|
+
@validator.should have_errors()
|
73
|
+
@validator.should_not be_okay()
|
74
|
+
@validator.error_messages.should include( "Invalid value for 'A Field'" )
|
63
75
|
end
|
64
76
|
|
65
77
|
it "allows an existing constraint to be overridden" do
|
66
78
|
@validator.add( :a_field, :string )
|
67
79
|
@validator.override( :a_field, :integer )
|
68
|
-
@validator.param_names.should include(
|
80
|
+
@validator.param_names.should include( 'a_field' )
|
69
81
|
@validator.validate( 'a_field' => 'a string!' )
|
70
82
|
@validator.should have_errors()
|
71
83
|
@validator.should_not be_okay()
|
@@ -75,14 +87,14 @@ describe Strelka::ParamValidator do
|
|
75
87
|
it "doesn't allow a non-existant parameter to be overridden" do
|
76
88
|
expect {
|
77
89
|
@validator.override( :a_field, :string )
|
78
|
-
}.to raise_error( /no parameter
|
79
|
-
@validator.param_names.should_not include(
|
90
|
+
}.to raise_error( /no parameter "a_field" defined/i )
|
91
|
+
@validator.param_names.should_not include( 'a_field' )
|
80
92
|
end
|
81
93
|
|
82
94
|
it "raises an exception on an unknown constraint type" do
|
83
95
|
expect {
|
84
96
|
@validator.add( :foo, $stderr )
|
85
|
-
}.to raise_error( /no builtin
|
97
|
+
}.to raise_error( /no builtin "foo" validator/ )
|
86
98
|
end
|
87
99
|
|
88
100
|
it "retains its parameters through a copy" do
|
@@ -74,18 +74,11 @@ describe Strelka::Router::Default do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it "responds with a 405 (method not allowed) for a POST request to /user/foo" do
|
77
|
-
expected_info = {
|
78
|
-
status: 405,
|
79
|
-
message: "Method not allowed.",
|
80
|
-
headers: {
|
81
|
-
allow: 'GET, HEAD'
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
77
|
req = @request_factory.post( '/user/foo' )
|
86
78
|
expect {
|
87
79
|
@router.route_request( req )
|
88
|
-
}.to
|
80
|
+
}.to finish_with( HTTP::METHOD_NOT_ALLOWED, /method not allowed/i ).
|
81
|
+
and_header( allow: 'GET, HEAD' )
|
89
82
|
end
|
90
83
|
|
91
84
|
end
|
@@ -108,18 +108,11 @@ describe Strelka::Router::Exclusive do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
it "responds with an HTTP::METHOD_NOT_ALLOWED for a POST request to /user/foo" do
|
111
|
-
expected_info = {
|
112
|
-
status: 405,
|
113
|
-
message: "Method not allowed.",
|
114
|
-
headers: {
|
115
|
-
allow: 'GET, HEAD'
|
116
|
-
}
|
117
|
-
}
|
118
|
-
|
119
111
|
req = @request_factory.post( '/user/foo' )
|
120
112
|
expect {
|
121
113
|
@router.route_request( req )
|
122
|
-
}.to
|
114
|
+
}.to finish_with( HTTP::METHOD_NOT_ALLOWED, /method not allowed/i ).
|
115
|
+
and_header( allow: 'GET, HEAD' )
|
123
116
|
end
|
124
117
|
end
|
125
118
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strelka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.pre.
|
4
|
+
version: 0.0.1.pre.203
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -36,11 +36,11 @@ cert_chain:
|
|
36
36
|
YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
|
37
37
|
Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
|
38
38
|
cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
39
|
-
date: 2012-04-
|
39
|
+
date: 2012-04-22 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: trollop
|
43
|
-
requirement: &
|
43
|
+
requirement: &70272015625260 !ruby/object:Gem::Requirement
|
44
44
|
none: false
|
45
45
|
requirements:
|
46
46
|
- - ~>
|
@@ -48,10 +48,10 @@ dependencies:
|
|
48
48
|
version: '1.16'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
|
-
version_requirements: *
|
51
|
+
version_requirements: *70272015625260
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
53
|
name: highline
|
54
|
-
requirement: &
|
54
|
+
requirement: &70272015624740 !ruby/object:Gem::Requirement
|
55
55
|
none: false
|
56
56
|
requirements:
|
57
57
|
- - ~>
|
@@ -59,10 +59,10 @@ dependencies:
|
|
59
59
|
version: '1.6'
|
60
60
|
type: :runtime
|
61
61
|
prerelease: false
|
62
|
-
version_requirements: *
|
62
|
+
version_requirements: *70272015624740
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: sysexits
|
65
|
-
requirement: &
|
65
|
+
requirement: &70272015624280 !ruby/object:Gem::Requirement
|
66
66
|
none: false
|
67
67
|
requirements:
|
68
68
|
- - ~>
|
@@ -70,10 +70,10 @@ dependencies:
|
|
70
70
|
version: '1.0'
|
71
71
|
type: :runtime
|
72
72
|
prerelease: false
|
73
|
-
version_requirements: *
|
73
|
+
version_requirements: *70272015624280
|
74
74
|
- !ruby/object:Gem::Dependency
|
75
75
|
name: formvalidator
|
76
|
-
requirement: &
|
76
|
+
requirement: &70272015623780 !ruby/object:Gem::Requirement
|
77
77
|
none: false
|
78
78
|
requirements:
|
79
79
|
- - ~>
|
@@ -81,10 +81,10 @@ dependencies:
|
|
81
81
|
version: '0.1'
|
82
82
|
type: :runtime
|
83
83
|
prerelease: false
|
84
|
-
version_requirements: *
|
84
|
+
version_requirements: *70272015623780
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: inversion
|
87
|
-
requirement: &
|
87
|
+
requirement: &70272015623300 !ruby/object:Gem::Requirement
|
88
88
|
none: false
|
89
89
|
requirements:
|
90
90
|
- - ~>
|
@@ -92,10 +92,10 @@ dependencies:
|
|
92
92
|
version: '0.8'
|
93
93
|
type: :runtime
|
94
94
|
prerelease: false
|
95
|
-
version_requirements: *
|
95
|
+
version_requirements: *70272015623300
|
96
96
|
- !ruby/object:Gem::Dependency
|
97
97
|
name: mongrel2
|
98
|
-
requirement: &
|
98
|
+
requirement: &70272015622700 !ruby/object:Gem::Requirement
|
99
99
|
none: false
|
100
100
|
requirements:
|
101
101
|
- - ~>
|
@@ -103,10 +103,10 @@ dependencies:
|
|
103
103
|
version: '0.20'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
|
-
version_requirements: *
|
106
|
+
version_requirements: *70272015622700
|
107
107
|
- !ruby/object:Gem::Dependency
|
108
108
|
name: uuidtools
|
109
|
-
requirement: &
|
109
|
+
requirement: &70272015682300 !ruby/object:Gem::Requirement
|
110
110
|
none: false
|
111
111
|
requirements:
|
112
112
|
- - ~>
|
@@ -114,10 +114,10 @@ dependencies:
|
|
114
114
|
version: '2.1'
|
115
115
|
type: :runtime
|
116
116
|
prerelease: false
|
117
|
-
version_requirements: *
|
117
|
+
version_requirements: *70272015682300
|
118
118
|
- !ruby/object:Gem::Dependency
|
119
119
|
name: configurability
|
120
|
-
requirement: &
|
120
|
+
requirement: &70272015681780 !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
@@ -125,10 +125,10 @@ dependencies:
|
|
125
125
|
version: '1.0'
|
126
126
|
type: :runtime
|
127
127
|
prerelease: false
|
128
|
-
version_requirements: *
|
128
|
+
version_requirements: *70272015681780
|
129
129
|
- !ruby/object:Gem::Dependency
|
130
130
|
name: pluginfactory
|
131
|
-
requirement: &
|
131
|
+
requirement: &70272015681280 !ruby/object:Gem::Requirement
|
132
132
|
none: false
|
133
133
|
requirements:
|
134
134
|
- - ~>
|
@@ -136,10 +136,10 @@ dependencies:
|
|
136
136
|
version: '1.0'
|
137
137
|
type: :runtime
|
138
138
|
prerelease: false
|
139
|
-
version_requirements: *
|
139
|
+
version_requirements: *70272015681280
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: hoe-mercurial
|
142
|
-
requirement: &
|
142
|
+
requirement: &70272015680760 !ruby/object:Gem::Requirement
|
143
143
|
none: false
|
144
144
|
requirements:
|
145
145
|
- - ~>
|
@@ -147,10 +147,10 @@ dependencies:
|
|
147
147
|
version: 1.4.0
|
148
148
|
type: :development
|
149
149
|
prerelease: false
|
150
|
-
version_requirements: *
|
150
|
+
version_requirements: *70272015680760
|
151
151
|
- !ruby/object:Gem::Dependency
|
152
152
|
name: hoe-manualgen
|
153
|
-
requirement: &
|
153
|
+
requirement: &70272015680200 !ruby/object:Gem::Requirement
|
154
154
|
none: false
|
155
155
|
requirements:
|
156
156
|
- - ~>
|
@@ -158,10 +158,10 @@ dependencies:
|
|
158
158
|
version: 0.3.0
|
159
159
|
type: :development
|
160
160
|
prerelease: false
|
161
|
-
version_requirements: *
|
161
|
+
version_requirements: *70272015680200
|
162
162
|
- !ruby/object:Gem::Dependency
|
163
163
|
name: hoe-highline
|
164
|
-
requirement: &
|
164
|
+
requirement: &70272015679720 !ruby/object:Gem::Requirement
|
165
165
|
none: false
|
166
166
|
requirements:
|
167
167
|
- - ~>
|
@@ -169,10 +169,10 @@ dependencies:
|
|
169
169
|
version: 0.1.0
|
170
170
|
type: :development
|
171
171
|
prerelease: false
|
172
|
-
version_requirements: *
|
172
|
+
version_requirements: *70272015679720
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
174
|
name: rdoc
|
175
|
-
requirement: &
|
175
|
+
requirement: &70272015679160 !ruby/object:Gem::Requirement
|
176
176
|
none: false
|
177
177
|
requirements:
|
178
178
|
- - ~>
|
@@ -180,10 +180,10 @@ dependencies:
|
|
180
180
|
version: '3.10'
|
181
181
|
type: :development
|
182
182
|
prerelease: false
|
183
|
-
version_requirements: *
|
183
|
+
version_requirements: *70272015679160
|
184
184
|
- !ruby/object:Gem::Dependency
|
185
185
|
name: hoe-deveiate
|
186
|
-
requirement: &
|
186
|
+
requirement: &70272015678660 !ruby/object:Gem::Requirement
|
187
187
|
none: false
|
188
188
|
requirements:
|
189
189
|
- - ~>
|
@@ -191,10 +191,10 @@ dependencies:
|
|
191
191
|
version: '0.1'
|
192
192
|
type: :development
|
193
193
|
prerelease: false
|
194
|
-
version_requirements: *
|
194
|
+
version_requirements: *70272015678660
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: simplecov
|
197
|
-
requirement: &
|
197
|
+
requirement: &70272015678180 !ruby/object:Gem::Requirement
|
198
198
|
none: false
|
199
199
|
requirements:
|
200
200
|
- - ~>
|
@@ -202,10 +202,10 @@ dependencies:
|
|
202
202
|
version: '0.6'
|
203
203
|
type: :development
|
204
204
|
prerelease: false
|
205
|
-
version_requirements: *
|
205
|
+
version_requirements: *70272015678180
|
206
206
|
- !ruby/object:Gem::Dependency
|
207
207
|
name: hoe
|
208
|
-
requirement: &
|
208
|
+
requirement: &70272015677640 !ruby/object:Gem::Requirement
|
209
209
|
none: false
|
210
210
|
requirements:
|
211
211
|
- - ~>
|
@@ -213,7 +213,7 @@ dependencies:
|
|
213
213
|
version: '3.0'
|
214
214
|
type: :development
|
215
215
|
prerelease: false
|
216
|
-
version_requirements: *
|
216
|
+
version_requirements: *70272015677640
|
217
217
|
description: ! 'Strelka is a framework for creating and deploying Mongrel2 web applications
|
218
218
|
|
219
219
|
in Ruby, and for managing a Mongrel2 cluster.
|
metadata.gz.sig
CHANGED
Binary file
|