escher 0.4.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/escher/request/factory.rb +1 -1
- data/lib/escher/request.rb +0 -1
- data/lib/escher/version.rb +1 -1
- data/spec/escher/request/factory_spec.rb +19 -7
- metadata +3 -6
- data/lib/escher/request/action_dispatch_request.rb +0 -47
- data/spec/escher/request/action_dispatch_request_spec.rb +0 -120
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5d7892a58786fb9802e66a734ddc2f7f84a4b42
|
4
|
+
data.tar.gz: 18bf4433e019a4581eb6980f9819f2b336c3495a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 006d627eddd82e86ef6e803019bee58183314d85b299a82a62da7e2579b069bd11e247d20d444822dd87acba7276612d19af415f608d5f55ccb88e532bdc36e4
|
7
|
+
data.tar.gz: 6d7cabbbaba10921751b255dcd9865f9bdc6abb08b1a7114190aac257f168f1118f9ea40b8399ac6502530ae3f04b38ebc7ef43cdc044eedf9f5eee9c4fcc71b
|
@@ -6,7 +6,7 @@ module Escher
|
|
6
6
|
case request
|
7
7
|
|
8
8
|
when defined?(ActionDispatch::Request) && ActionDispatch::Request
|
9
|
-
|
9
|
+
RackRequest.new(Rack::Request.new(request.env))
|
10
10
|
|
11
11
|
when defined?(Rack::Request) && Rack::Request
|
12
12
|
RackRequest.new(request)
|
data/lib/escher/request.rb
CHANGED
data/lib/escher/version.rb
CHANGED
@@ -7,19 +7,31 @@ require 'action_dispatch'
|
|
7
7
|
describe Escher::Request::Factory do
|
8
8
|
|
9
9
|
describe ".from_request" do
|
10
|
+
request_env = {Rack::PATH_INFO.to_s => "request-path"}
|
11
|
+
|
10
12
|
{
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
{uri: "request-path"} => Escher::Request::HashRequest,
|
15
|
+
Struct.new("Request", :uri).new("request-path") => Escher::Request::LegacyRequest,
|
16
|
+
Rack::Request.new(request_env) => Escher::Request::RackRequest,
|
17
|
+
ActionDispatch::Request.new(request_env) => Escher::Request::RackRequest
|
16
18
|
|
17
19
|
}.each do |request, expected_class|
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
+
context "the request to be wrapped is a #{request.class.name}" do
|
22
|
+
|
23
|
+
it "returns a #{expected_class.name}" do
|
24
|
+
wrapped_request = described_class.from_request request
|
25
|
+
|
26
|
+
expect(wrapped_request).to be_an_instance_of expected_class
|
27
|
+
end
|
28
|
+
|
29
|
+
it "wraps the path from the original request" do
|
30
|
+
wrapped_request = described_class.from_request request
|
31
|
+
|
32
|
+
expect(wrapped_request.path).to eq "request-path"
|
33
|
+
end
|
21
34
|
|
22
|
-
expect(described_class.from_request request).to eq "#{expected_class.name} wrapping request"
|
23
35
|
end
|
24
36
|
|
25
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: escher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andras Barthazi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -127,7 +127,6 @@ files:
|
|
127
127
|
- lib/escher/auth.rb
|
128
128
|
- lib/escher/escher_error.rb
|
129
129
|
- lib/escher/request.rb
|
130
|
-
- lib/escher/request/action_dispatch_request.rb
|
131
130
|
- lib/escher/request/base.rb
|
132
131
|
- lib/escher/request/dci.rb
|
133
132
|
- lib/escher/request/dci/rack_env.rb
|
@@ -315,7 +314,6 @@ files:
|
|
315
314
|
- spec/emarsys_testsuite/post-header-value-spaces.sreq
|
316
315
|
- spec/emarsys_testsuite/post-header-value-spaces.sts
|
317
316
|
- spec/escher/auth_spec.rb
|
318
|
-
- spec/escher/request/action_dispatch_request_spec.rb
|
319
317
|
- spec/escher/request/factory_spec.rb
|
320
318
|
- spec/escher/request/hash_request_spec.rb
|
321
319
|
- spec/escher/request/rack_request_spec.rb
|
@@ -343,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
343
341
|
version: '0'
|
344
342
|
requirements: []
|
345
343
|
rubyforge_project:
|
346
|
-
rubygems_version: 2.
|
344
|
+
rubygems_version: 2.6.8
|
347
345
|
signing_key:
|
348
346
|
specification_version: 4
|
349
347
|
summary: Library for HTTP request signing (Ruby implementation)
|
@@ -526,7 +524,6 @@ test_files:
|
|
526
524
|
- spec/emarsys_testsuite/post-header-value-spaces.sreq
|
527
525
|
- spec/emarsys_testsuite/post-header-value-spaces.sts
|
528
526
|
- spec/escher/auth_spec.rb
|
529
|
-
- spec/escher/request/action_dispatch_request_spec.rb
|
530
527
|
- spec/escher/request/factory_spec.rb
|
531
528
|
- spec/escher/request/hash_request_spec.rb
|
532
529
|
- spec/escher/request/rack_request_spec.rb
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module Escher
|
2
|
-
module Request
|
3
|
-
class ActionDispatchRequest < Base
|
4
|
-
|
5
|
-
include Escher::Request::DCI::RackEnv
|
6
|
-
|
7
|
-
def headers
|
8
|
-
get_headers_by_rack_env(request.env)
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def method
|
14
|
-
request.request_method
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def body
|
20
|
-
case request.body
|
21
|
-
when StringIO
|
22
|
-
request.body.string
|
23
|
-
else
|
24
|
-
request.body.to_s
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
def path
|
31
|
-
request.env['REQUEST_PATH'] || request.path
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
def query_values
|
37
|
-
Addressable::URI.new(:query => request.env['QUERY_STRING']).query_values(Array) or []
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
def set_header(header_name, value)
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,120 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'action_dispatch'
|
4
|
-
|
5
|
-
describe Escher::Request::ActionDispatchRequest do
|
6
|
-
|
7
|
-
let(:request_params) { {"PATH_INFO" => "/", } }
|
8
|
-
let(:request) { ActionDispatch::Request.new(request_params) }
|
9
|
-
|
10
|
-
subject { described_class.new request }
|
11
|
-
|
12
|
-
describe "#request" do
|
13
|
-
it "should return the underlying request object" do
|
14
|
-
expect(subject.request).to eq request
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
describe "#headers" do
|
20
|
-
it "should return only the HTTP request headers" do
|
21
|
-
request_params.merge! 'HTTP_HOST' => 'some host',
|
22
|
-
'SOME_HEADER' => 'some header'
|
23
|
-
|
24
|
-
expect(subject.headers).to eq [['HOST', 'some host']]
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should replace underscores with dashes in the header name" do
|
28
|
-
request_params.merge! 'HTTP_HOST_NAME' => 'some host'
|
29
|
-
|
30
|
-
expect(subject.headers).to eq [['HOST-NAME', 'some host']]
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should add the content-type and content-length to the headers' do
|
34
|
-
request_params.merge!( 'CONTENT_LENGTH' => '123', 'CONTENT_TYPE' => 'text/plain' )
|
35
|
-
|
36
|
-
expect(subject.headers).to eq [%w(CONTENT-LENGTH 123), %w(CONTENT-TYPE text/plain)]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
describe "#has_header?" do
|
42
|
-
it "should return true if request has specified header, false otherwise" do
|
43
|
-
request_params.merge! 'HTTP_HOST_NAME' => 'some host'
|
44
|
-
|
45
|
-
expect(subject.has_header? 'host-name').to be_truthy
|
46
|
-
expect(subject.has_header? 'no-such-header').to be_falsey
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
describe "#header" do
|
52
|
-
it "should return the value for the requested header" do
|
53
|
-
request_params.merge! 'HTTP_HOST' => 'some host'
|
54
|
-
|
55
|
-
expect(subject.header 'host').to eq 'some host'
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should return nil if no such header exists" do
|
59
|
-
expect(subject.header 'host').to be_nil
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
describe "#method" do
|
65
|
-
it "should return the request method" do
|
66
|
-
request_params.merge! 'REQUEST_METHOD' => 'GET'
|
67
|
-
|
68
|
-
expect(subject.method).to eq 'GET'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
|
73
|
-
describe "#body" do
|
74
|
-
it "should return the request body" do
|
75
|
-
request_params.merge! 'rack.input' => 'request body'
|
76
|
-
|
77
|
-
expect(subject.body).to eq 'request body'
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should return empty string for no body" do
|
81
|
-
expect(subject.body).to eq ''
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
describe "#path" do
|
87
|
-
it "should return the request path" do
|
88
|
-
request_params.merge! 'REQUEST_PATH' => '/resources/id///'
|
89
|
-
|
90
|
-
expect(subject.path).to eq '/resources/id///'
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
describe "#query_values" do
|
96
|
-
it "should return the request query parameters as an array of key-value pairs" do
|
97
|
-
request_params.merge! 'QUERY_STRING' => 'search=query¶m=value'
|
98
|
-
|
99
|
-
expect(subject.query_values).to eq [['search', 'query'], ['param', 'value']]
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should return the query parameters regardless of fragments" do
|
103
|
-
request_params.merge! 'QUERY_STRING' => "@\#$%^&+=/,?><`\";:\\|][{}"
|
104
|
-
|
105
|
-
expect(subject.query_values).to eq [["@\#$%^"], ["+", "/,?><`\";:\\|][{}"]]
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should return an empty array if the request has no query parameters" do
|
109
|
-
expect(subject.query_values).to eq []
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
describe "#set_header" do
|
115
|
-
it "should ignore calls" do
|
116
|
-
expect { subject.set_header 'test-header', 'test value' }.not_to raise_error
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|