dzl 1.0.0.rc6 → 1.0.0.rc7
Sign up to get free protection for your applications and to get access to all the features.
- data/config.ru +8 -8
- data/lib/dzl/dsl_subjects/parameter_block.rb +7 -5
- data/lib/dzl/examples/fun_with_params.rb +12 -0
- data/lib/dzl/version.rb +1 -1
- data/spec/fun_with_params_spec.rb +37 -0
- metadata +6 -6
data/config.ru
CHANGED
@@ -15,10 +15,10 @@ end
|
|
15
15
|
# run Dzl::Examples::Trey
|
16
16
|
# end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
require 'dzl/examples/fun_with_params'
|
19
|
+
map '/' do
|
20
|
+
run Dzl::Examples::FunWithParams
|
21
|
+
end
|
22
22
|
|
23
23
|
# require 'dzl/examples/fun_with_requests'
|
24
24
|
# map '/' do
|
@@ -45,10 +45,10 @@ end
|
|
45
45
|
# run Dzl::Examples::FunWithScopes
|
46
46
|
# end
|
47
47
|
|
48
|
-
require 'dzl/examples/fun_with_hashes'
|
49
|
-
map '/' do
|
50
|
-
|
51
|
-
end
|
48
|
+
# require 'dzl/examples/fun_with_hashes'
|
49
|
+
# map '/' do
|
50
|
+
# run Dzl::Examples::FunWithHashes
|
51
|
+
# end
|
52
52
|
|
53
53
|
# require 'dzl/examples/fun_with_pblocks'
|
54
54
|
# map '/' do
|
@@ -57,18 +57,20 @@ class Dzl::DSLSubjects::ParameterBlock < Dzl::DSLSubject
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
if
|
61
|
-
Dzl::ValueOrError.new(e: errors)
|
62
|
-
elsif @opts[:protection]
|
60
|
+
if @opts[:protection]
|
63
61
|
protection_errors = @opts[:protection].collect do |protection|
|
64
62
|
protection.allow?(parandidates, request)
|
65
63
|
end.select { |result| result.error? }
|
66
64
|
|
67
|
-
if protection_errors.empty?
|
65
|
+
if protection_errors.empty? && errors.empty?
|
68
66
|
Dzl::ValueOrError.new(v: parandidates)
|
67
|
+
elsif !protection_errors.empty?
|
68
|
+
protection_errors.first
|
69
69
|
else
|
70
|
-
|
70
|
+
Dzl::ValueOrError.new(e: errors)
|
71
71
|
end
|
72
|
+
elsif !errors.empty?
|
73
|
+
Dzl::ValueOrError.new(e: errors)
|
72
74
|
else
|
73
75
|
Dzl::ValueOrError.new(v: parandidates)
|
74
76
|
end
|
@@ -36,6 +36,18 @@ class Dzl::Examples::FunWithParams < Dzl::Examples::Base
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
post '/body' do
|
40
|
+
required :foo, :bar
|
41
|
+
end
|
42
|
+
|
43
|
+
post '/other_protected', :get do
|
44
|
+
required :foo
|
45
|
+
|
46
|
+
protect do
|
47
|
+
http_basic username: 'no', password: 'way'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
39
51
|
endpoint '/arithmetic' do
|
40
52
|
optional :int do
|
41
53
|
type Fixnum
|
data/lib/dzl/version.rb
CHANGED
@@ -126,6 +126,14 @@ describe Dzl::Examples::FunWithParams do
|
|
126
126
|
get '/protected' do |response|
|
127
127
|
response.status.should == 401
|
128
128
|
end
|
129
|
+
|
130
|
+
post '/other_protected', foo: 'present' do |response|
|
131
|
+
response.status.should == 401
|
132
|
+
end
|
133
|
+
|
134
|
+
get '/other_protected' do |response|
|
135
|
+
response.status.should == 401
|
136
|
+
end
|
129
137
|
end
|
130
138
|
|
131
139
|
it 'should present the http basic challenge with invalid credentials' do
|
@@ -140,6 +148,27 @@ describe Dzl::Examples::FunWithParams do
|
|
140
148
|
get '/protected' do |response|
|
141
149
|
response.status.should == 200
|
142
150
|
end
|
151
|
+
|
152
|
+
post '/other_protected', foo: 'present' do |response|
|
153
|
+
response.status.should == 200
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'should 404 with valid auth and bad params' do
|
158
|
+
authorize('no', 'way')
|
159
|
+
post '/other_protected' do |response|
|
160
|
+
response.status.should == 404
|
161
|
+
end
|
162
|
+
|
163
|
+
get '/other_protected' do |response|
|
164
|
+
response.status.should == 404
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should 401 with invalid auth' do
|
169
|
+
get '/other_protected' do |response|
|
170
|
+
response.status.should == 401
|
171
|
+
end
|
143
172
|
end
|
144
173
|
end
|
145
174
|
|
@@ -237,5 +266,13 @@ describe Dzl::Examples::FunWithParams do
|
|
237
266
|
}
|
238
267
|
end
|
239
268
|
end
|
269
|
+
|
270
|
+
describe '/body' do
|
271
|
+
specify 'works' do
|
272
|
+
post('/body', foo: 'hello', bar: 'world') do |response|
|
273
|
+
response.status.should == 200
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
240
277
|
end
|
241
278
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dzl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc7
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-04-
|
13
|
+
date: 2012-04-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
17
|
-
requirement: &
|
17
|
+
requirement: &70287627293400 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 1.4.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70287627293400
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activesupport
|
28
|
-
requirement: &
|
28
|
+
requirement: &70287627291640 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 3.2.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70287627291640
|
37
37
|
description: Small, fast racktivesupport web framework with handy DSL and explicit
|
38
38
|
parameter validation.
|
39
39
|
email:
|