wash_out 0.5.6 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +21 -19
- data/lib/wash_out/dispatcher.rb +10 -22
- data/lib/wash_out/param.rb +1 -1
- data/lib/wash_out/version.rb +1 -1
- data/lib/wash_out/wsse.rb +3 -3
- data/spec/lib/wash_out/dispatcher_spec.rb +19 -23
- data/spec/lib/wash_out_spec.rb +446 -538
- data/spec/spec_helper.rb +4 -16
- data/wash_out.gemspec +1 -11
- metadata +20 -125
- data/spec/support/httpi-rack.rb +0 -46
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -1,2 +1,15 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
+
|
2
3
|
gemspec
|
4
|
+
|
5
|
+
gem 'wasabi'
|
6
|
+
gem 'savon'
|
7
|
+
gem 'httpi', :git => 'git://github.com/savonrb/httpi.git'
|
8
|
+
|
9
|
+
gem 'rspec-rails'
|
10
|
+
gem 'guard'
|
11
|
+
gem 'guard-rspec'
|
12
|
+
gem 'rb-fsevent'
|
13
|
+
gem 'appraisal'
|
14
|
+
gem 'tzinfo'
|
15
|
+
gem 'pry'
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,15 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/savonrb/httpi.git
|
3
|
+
revision: 6536d498160ecb0e969bb161ad091c49493f6bc2
|
4
|
+
specs:
|
5
|
+
httpi (2.0.0)
|
6
|
+
rack
|
7
|
+
|
1
8
|
PATH
|
2
9
|
remote: .
|
3
10
|
specs:
|
4
|
-
wash_out (0.
|
5
|
-
nori (~>
|
11
|
+
wash_out (0.6.0)
|
12
|
+
nori (~> 2.0.0)
|
6
13
|
|
7
14
|
GEM
|
8
15
|
remote: http://rubygems.org/
|
@@ -33,8 +40,6 @@ GEM
|
|
33
40
|
coderay (1.0.8)
|
34
41
|
diff-lcs (1.1.3)
|
35
42
|
erubis (2.7.0)
|
36
|
-
ffi (1.2.0)
|
37
|
-
ffi (1.2.0-java)
|
38
43
|
guard (1.6.1)
|
39
44
|
listen (>= 0.6.0)
|
40
45
|
lumberjack (>= 1.0.2)
|
@@ -46,8 +51,6 @@ GEM
|
|
46
51
|
gyoku (1.0.0)
|
47
52
|
builder (>= 2.1.2)
|
48
53
|
hike (1.2.1)
|
49
|
-
httpi (0.9.7)
|
50
|
-
rack
|
51
54
|
i18n (0.6.1)
|
52
55
|
journey (1.0.4)
|
53
56
|
json (1.7.5)
|
@@ -58,7 +61,7 @@ GEM
|
|
58
61
|
multi_json (1.5.0)
|
59
62
|
nokogiri (1.5.6)
|
60
63
|
nokogiri (1.5.6-java)
|
61
|
-
nori (
|
64
|
+
nori (2.0.0)
|
62
65
|
pry (0.9.10)
|
63
66
|
coderay (~> 1.0.5)
|
64
67
|
method_source (~> 0.8)
|
@@ -84,8 +87,6 @@ GEM
|
|
84
87
|
thor (>= 0.14.6, < 2.0)
|
85
88
|
rake (10.0.3)
|
86
89
|
rb-fsevent (0.9.2)
|
87
|
-
rb-inotify (0.8.8)
|
88
|
-
ffi (>= 0.5.0)
|
89
90
|
rdoc (3.12)
|
90
91
|
json (~> 1.4)
|
91
92
|
rspec (2.12.0)
|
@@ -103,14 +104,14 @@ GEM
|
|
103
104
|
rspec-core (~> 2.12.0)
|
104
105
|
rspec-expectations (~> 2.12.0)
|
105
106
|
rspec-mocks (~> 2.12.0)
|
106
|
-
savon (0.
|
107
|
-
akami (~> 1.0)
|
107
|
+
savon (2.0.2)
|
108
|
+
akami (~> 1.2.0)
|
108
109
|
builder (>= 2.1.2)
|
109
|
-
gyoku (
|
110
|
-
httpi (~> 0.
|
110
|
+
gyoku (~> 1.0.0)
|
111
|
+
httpi (~> 2.0.0)
|
111
112
|
nokogiri (>= 1.4.0)
|
112
|
-
nori (~>
|
113
|
-
wasabi (~>
|
113
|
+
nori (~> 2.0.0)
|
114
|
+
wasabi (~> 3.0.0)
|
114
115
|
slop (3.3.3)
|
115
116
|
spoon (0.0.1)
|
116
117
|
sprockets (2.2.2)
|
@@ -121,7 +122,8 @@ GEM
|
|
121
122
|
thor (0.16.0)
|
122
123
|
tilt (1.3.3)
|
123
124
|
tzinfo (0.3.35)
|
124
|
-
wasabi (
|
125
|
+
wasabi (3.0.0)
|
126
|
+
httpi (~> 2.0)
|
125
127
|
nokogiri (>= 1.4.0)
|
126
128
|
|
127
129
|
PLATFORMS
|
@@ -132,11 +134,11 @@ DEPENDENCIES
|
|
132
134
|
appraisal
|
133
135
|
guard
|
134
136
|
guard-rspec
|
137
|
+
httpi!
|
135
138
|
pry
|
136
139
|
rb-fsevent
|
137
|
-
rb-inotify
|
138
140
|
rspec-rails
|
139
|
-
savon
|
141
|
+
savon
|
140
142
|
tzinfo
|
141
|
-
wasabi
|
143
|
+
wasabi
|
142
144
|
wash_out!
|
data/lib/wash_out/dispatcher.rb
CHANGED
@@ -12,34 +12,22 @@ module WashOut
|
|
12
12
|
|
13
13
|
# This filter parses the SOAP request and puts it into +params+ array.
|
14
14
|
def _parse_soap_parameters
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
else
|
26
|
-
Nori.convert_tags_to { |tag| tag.to_sym }
|
27
|
-
end
|
28
|
-
|
29
|
-
request_body = request.body.read
|
30
|
-
@_params = Nori.parse(request_body)
|
31
|
-
|
15
|
+
parser = Nori.new(
|
16
|
+
:strip_namespaces => true,
|
17
|
+
:advanced_typecasting => true,
|
18
|
+
:convert_tags_to => (
|
19
|
+
WashOut::Engine.snakecase_input ? lambda { |tag| tag.snakecase.to_sym }
|
20
|
+
: lambda { |tag| tag.to_sym }
|
21
|
+
)
|
22
|
+
)
|
23
|
+
|
24
|
+
@_params = parser.parse(request.body.read)
|
32
25
|
references = WashOut::Dispatcher.deep_select(@_params){|k,v| v.is_a?(Hash) && v.has_key?(:@id)}
|
33
26
|
|
34
27
|
unless references.blank?
|
35
28
|
replaces = {}; references.each{|r| replaces['#'+r[:@id]] = r}
|
36
29
|
@_params = WashOut::Dispatcher.deep_replace_href(@_params, replaces)
|
37
30
|
end
|
38
|
-
|
39
|
-
# Reset Nori setup to project-space
|
40
|
-
Nori.strip_namespaces = strip
|
41
|
-
Nori.advanced_typecasting = typecast
|
42
|
-
Nori.convert_tags_to convert
|
43
31
|
end
|
44
32
|
|
45
33
|
def _authenticate_wsse
|
data/lib/wash_out/param.rb
CHANGED
data/lib/wash_out/version.rb
CHANGED
data/lib/wash_out/wsse.rb
CHANGED
@@ -36,7 +36,7 @@ module WashOut
|
|
36
36
|
|
37
37
|
# Token should not be accepted if timestamp is older than 5 minutes ago
|
38
38
|
# http://www.oasis-open.org/committees/download.php/16782/wss-v1.1-spec-os-UsernameTokenProfile.pdf
|
39
|
-
offset_in_minutes = ((DateTime.now -
|
39
|
+
offset_in_minutes = ((DateTime.now - timestamp)* 24 * 60).to_i
|
40
40
|
return false if offset_in_minutes >= 5
|
41
41
|
|
42
42
|
# There are a few different implementations of the digest calculation
|
@@ -44,11 +44,11 @@ module WashOut
|
|
44
44
|
flavors = Array.new
|
45
45
|
|
46
46
|
# Ruby / Savon
|
47
|
-
token = nonce + timestamp + expected_password
|
47
|
+
token = nonce + timestamp.to_s + expected_password
|
48
48
|
flavors << Base64.encode64(Digest::SHA1.hexdigest(token)).chomp!
|
49
49
|
|
50
50
|
# Java
|
51
|
-
token = Base64.decode64(nonce) + timestamp + expected_password
|
51
|
+
token = Base64.decode64(nonce) + timestamp.to_s + expected_password
|
52
52
|
flavors << Base64.encode64(Digest::SHA1.digest(token)).chomp!
|
53
53
|
|
54
54
|
flavors.each do |f|
|
@@ -4,22 +4,12 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe WashOut::Dispatcher do
|
6
6
|
|
7
|
-
class TestBody
|
8
|
-
attr_accessor :read
|
9
|
-
def initialize(read); @read = read; end
|
10
|
-
end
|
11
|
-
|
12
|
-
class TestRequest
|
13
|
-
attr_accessor :body
|
14
|
-
def initialize(body); @body = body; end
|
15
|
-
end
|
16
|
-
|
17
7
|
class Dispatcher < ApplicationController
|
18
8
|
include WashOut::SOAP
|
19
9
|
|
20
10
|
def self.mock(text="")
|
21
11
|
dispatcher = self.new
|
22
|
-
dispatcher.request =
|
12
|
+
dispatcher.request = OpenStruct.new(:body => OpenStruct.new(:read => text))
|
23
13
|
dispatcher
|
24
14
|
end
|
25
15
|
|
@@ -46,20 +36,26 @@ describe WashOut::Dispatcher do
|
|
46
36
|
|
47
37
|
it "parses href request" do
|
48
38
|
dispatcher = Dispatcher.mock <<-XML
|
49
|
-
<
|
50
|
-
<
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
<
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
<
|
59
|
-
|
39
|
+
<root>
|
40
|
+
<request>
|
41
|
+
<entities href="#id1">
|
42
|
+
</entities>
|
43
|
+
</request>
|
44
|
+
<entity id="id1">
|
45
|
+
<foo><bar>1</bar></foo>
|
46
|
+
<sub href="#id2" />
|
47
|
+
</entity>
|
48
|
+
<ololo id="id2">
|
49
|
+
<foo>1</foo>
|
50
|
+
</ololo>
|
51
|
+
</root>
|
60
52
|
XML
|
61
53
|
dispatcher._parse_soap_parameters
|
62
|
-
dispatcher.params[:request][:entities].should == {
|
54
|
+
dispatcher.params[:root][:request][:entities].should == {
|
55
|
+
:foo => {:bar=>"1"},
|
56
|
+
:sub => {:foo=>"1", :@id=>"id2"},
|
57
|
+
:@id => "id1"
|
58
|
+
}
|
63
59
|
end
|
64
60
|
|
65
61
|
end
|