dot_net_services 0.3.0 → 0.4.0
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/LICENSE +21 -24
- data/README +26 -16
- data/Rakefile +65 -0
- data/lib/acs/saml_token_provider.rb +54 -0
- data/lib/acs/shared_secret_token_provider.rb +55 -0
- data/lib/acs/simple_api_auth_token_provider.rb +57 -0
- data/lib/acs/simple_web_token_provider.rb +54 -0
- data/lib/acs/token_constants.rb +112 -0
- data/lib/acs/token_info.rb +33 -0
- data/lib/acs/token_provider.rb +74 -0
- data/lib/acs/token_validator.rb +114 -0
- data/lib/common/dot_net_services_environment.rb +61 -0
- data/lib/common/environment.yml +23 -0
- data/lib/common/host_name_config.yml +45 -0
- data/lib/dot_net_services.rb +31 -144
- data/lib/service_bus/http_proxy.rb +34 -0
- data/lib/service_bus/locked_message_info.rb +34 -0
- data/lib/service_bus/message_buffer.rb +313 -0
- data/lib/service_bus/message_buffer_constants.rb +48 -0
- data/lib/service_bus/message_buffer_policy.rb +55 -0
- data/lib/service_bus/requests.rb +95 -0
- data/test/config/test_config.yml +40 -0
- data/test/dot_net_services_environment_test.rb +54 -0
- data/test/message_buffer_test.rb +96 -0
- data/test/token_test.rb +98 -0
- metadata +50 -48
- data/lib/dot_net_services/authentication.rb +0 -168
- data/lib/dot_net_services/error.rb +0 -4
- data/lib/dot_net_services/message_buffer.rb +0 -283
- data/lib/dot_net_services/session.rb +0 -308
- data/lib/net/http/create_mb.rb +0 -14
- data/lib/net/http/retrieve.rb +0 -14
- data/lib/net/http/subscribe.rb +0 -14
- data/lib/net/http/unsubscribe.rb +0 -14
- data/spec/integration/TestService/Service/AnonymousResourceService.cs +0 -9
- data/spec/integration/TestService/Service/App.config +0 -32
- data/spec/integration/TestService/Service/PlainTextService.cs +0 -37
- data/spec/integration/TestService/Service/Program.cs +0 -49
- data/spec/integration/TestService/Service/Properties/AssemblyInfo.cs +0 -33
- data/spec/integration/TestService/Service/ResourceContract.cs +0 -17
- data/spec/integration/TestService/Service/ResourceService.cs +0 -58
- data/spec/integration/TestService/Service/Service.csproj +0 -71
- data/spec/integration/TestService/TestService.sln +0 -33
- data/spec/integration/end_to_end_spec.rb +0 -84
- data/spec/integration/vmb_spec.rb +0 -30
- data/spec/spec_helper.rb +0 -23
- data/spec/unit/dot_net_services/authentication_spec.rb +0 -289
- data/spec/unit/dot_net_services/message_buffer_spec.rb +0 -161
- data/spec/unit/dot_net_services/session_spec.rb +0 -247
@@ -1,247 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../../spec_helper"
|
2
|
-
|
3
|
-
module DotNetServices
|
4
|
-
|
5
|
-
describe Session do
|
6
|
-
|
7
|
-
describe "new(endpoint, auth_data = nil)" do
|
8
|
-
it "should take a relative path of the endpoint and convert to a full path" do
|
9
|
-
session = Session.new("/alexeyv/EchoService/")
|
10
|
-
session.endpoint.should == "#{DotNetServices.root_url}/alexeyv/EchoService/"
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should not prefix an absolute endpoint path" do
|
14
|
-
Session.new("http://foo/").endpoint.should == "http://foo/"
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should prefix relative endpoint path with a slash if necessary" do
|
18
|
-
Session.new("alexeyv/EchoService/").endpoint.should == "#{DotNetServices.root_url}/alexeyv/EchoService/"
|
19
|
-
Session.new("/alexeyv/EchoService/").endpoint.should == "#{DotNetServices.root_url}/alexeyv/EchoService/"
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should append a slash to the endpoint path if necessary" do
|
23
|
-
Session.new("/alexeyv/EchoService").endpoint.should == "#{DotNetServices.root_url}/alexeyv/EchoService/"
|
24
|
-
Session.new("/alexeyv/EchoService/").endpoint.should == "#{DotNetServices.root_url}/alexeyv/EchoService/"
|
25
|
-
Session.new("http://foo").endpoint.should == "http://foo/"
|
26
|
-
Session.new("http://foo/").endpoint.should == "http://foo/"
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "open" do
|
32
|
-
it "should create the session and return it" do
|
33
|
-
authenticator = mock('authenticator')
|
34
|
-
authenticator.should_receive(:authenticate)
|
35
|
-
|
36
|
-
session = Session.open("http://foo/", authenticator)
|
37
|
-
|
38
|
-
session.should be_instance_of(Session)
|
39
|
-
session.authenticator.should == authenticator
|
40
|
-
session.endpoint.should == "http://foo/"
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should, given a block, pass the session to a block and return the result of the block" do
|
44
|
-
yielded_session = nil
|
45
|
-
result = Session.open("http://foo/") { |session| yielded_session = session; "been here"}
|
46
|
-
|
47
|
-
yielded_session.should be_instance_of(Session)
|
48
|
-
yielded_session.endpoint.should == "http://foo/"
|
49
|
-
result.should == "been here"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "get(query_options=nil)" do
|
54
|
-
it "should send a get request to the endpoint and return the response" do
|
55
|
-
mock_http_get('foo', 80, '/')
|
56
|
-
result = Session.open("http://foo/") { |session| session.get }
|
57
|
-
result.should == :http_get_result
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should accept query options" do
|
61
|
-
mock_http_get('foo', 80, '/', 'bar=baz')
|
62
|
-
result = Session.open("http://foo/") { |session| session.get(:bar => 'baz') }
|
63
|
-
result.should == :http_get_result
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should escape elements of the query" do
|
67
|
-
mock_http_get('foo', 80, '/', "foo=bar%2Bbaz%7Equx")
|
68
|
-
result = Session.open("http://foo/") { |session| session.get(:foo => "bar+baz~qux") }
|
69
|
-
result.should == :http_get_result
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should pass a request through authentication handler" do
|
73
|
-
mock_http, mock_get = mock_http_get('foo', 80, '/')
|
74
|
-
|
75
|
-
authenticator = mock('authenticator')
|
76
|
-
authenticator.should_receive(:authenticate)
|
77
|
-
authenticator.should_receive(:enhance).with(mock_get)
|
78
|
-
|
79
|
-
result = Session.open("http://foo/", authenticator) { |session| session.get }
|
80
|
-
result.should == :http_get_result
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
describe "get_to_url(url, data=nil, content_type='application/x-www-form-urlencoded')" do
|
86
|
-
|
87
|
-
it "should get data from the URL under the endpoint" do
|
88
|
-
mock_http_get('foo', 80, '/services/suburl', "foo=bar")
|
89
|
-
result = Session.open("http://foo/services/") { |session| session.get_from_url('suburl', :foo => "bar") }
|
90
|
-
result.should == :http_get_result
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "post(data=nil, content_type='application/x-www-form-urlencoded')" do
|
96
|
-
it "should pass data as URL encoded form if data is a Hash" do
|
97
|
-
mock_http_post_form('foo', 80, '/', :foo => 'bar')
|
98
|
-
result = Session.open("http://foo/") { |session| session.post(:foo => "bar") }
|
99
|
-
result.should == :http_post_result
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should set data instead of form data on the Net::HTTP::Post instance, if content type is not url-encoded-form" do
|
103
|
-
mock_http = mock('http')
|
104
|
-
mock_post = mock('post')
|
105
|
-
Net::HTTP.should_receive(:start).with('foo', 80).and_yield(mock_http)
|
106
|
-
Net::HTTP::Post.should_receive(:new).with('/services/').and_return(mock_post)
|
107
|
-
mock_post.should_receive(:body=).with("post body")
|
108
|
-
mock_post.should_receive(:content_type=).with("text/plain")
|
109
|
-
mock_http.should_receive(:request).with(mock_post).and_return(:http_post_result)
|
110
|
-
|
111
|
-
result = Session.open("http://foo/services/") { |session| session.post("post body", "text/plain") }
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "post_to_url(url, data=nil, content_type='application/x-www-form-urlencoded')" do
|
117
|
-
|
118
|
-
it "should post data to the URL under the endpoint" do
|
119
|
-
mock_http_post_form('foo', 80, '/services/suburl', :foo => 'bar')
|
120
|
-
result = Session.open("http://foo/services/") { |session| session.post_to_url('suburl', :foo => "bar") }
|
121
|
-
result.should == :http_post_result
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
125
|
-
|
126
|
-
|
127
|
-
describe "createmb" do
|
128
|
-
it "should make a createmb request" do
|
129
|
-
mock_createmb = mock('createmb')
|
130
|
-
Net::HTTP::CreateMB.should_receive(:new).with('/services/user/location/').and_return(mock_createmb)
|
131
|
-
mock_createmb.should_receive(:[]=).with(
|
132
|
-
"X-Process-At", "http://schemas.microsoft.com/ws/2007/08/connect/roles/relay")
|
133
|
-
mock_http = mock('http')
|
134
|
-
Net::HTTP.should_receive(:start).with(DotNetServices.relay_host, 80).and_yield(mock_http)
|
135
|
-
mock_http.should_receive(:request).with(mock_createmb).and_return(:response)
|
136
|
-
Session.open("http://#{DotNetServices.relay_host}/services/user/location") { |session| session.createmb }
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe "retrieve" do
|
141
|
-
it "should make a retrieve request" do
|
142
|
-
mock_retrieve = mock('retrieve')
|
143
|
-
Net::HTTP::Retrieve.should_receive(:new).with('/services/user/location/?timeout=10').and_return(mock_retrieve)
|
144
|
-
mock_retrieve.should_receive(:[]=).with(
|
145
|
-
'X-Process-At', "http://schemas.microsoft.com/ws/2007/08/connect/roles/relay")
|
146
|
-
mock_http = mock('http')
|
147
|
-
Net::HTTP.should_receive(:start).with(DotNetServices.relay_host, 80).and_yield(mock_http)
|
148
|
-
mock_http.should_receive(:request).with(mock_retrieve).and_return(:response)
|
149
|
-
actual_response = Session.open("http://#{DotNetServices.relay_host}/services/user/location") { |session| session.retrieve(:timeout => 10) }
|
150
|
-
actual_response.should == :response
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should coerce the keys in options to strings and downcase them" do
|
154
|
-
mock_retrieve = mock('retrieve')
|
155
|
-
mock_retrieve.stub!(:[]=)
|
156
|
-
mock_http = mock('http')
|
157
|
-
|
158
|
-
Net::HTTP::Retrieve.should_receive(:new).with("/services/user/location/?timeout=5").and_return(mock_retrieve)
|
159
|
-
Net::HTTP::Retrieve.should_receive(:new).with("/services/user/location/?timeout=6").and_return(mock_retrieve)
|
160
|
-
Net::HTTP.should_receive(:start).twice.and_yield(mock_http)
|
161
|
-
mock_http.should_receive(:request).twice.with(mock_retrieve).and_return(:response)
|
162
|
-
|
163
|
-
Session.open("http://#{DotNetServices.relay_host}/services/user/location") do
|
164
|
-
|session|
|
165
|
-
session.retrieve :timeout => 5
|
166
|
-
session.retrieve "TIMEOUT" => 6
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
it "should insert a default timeout of 15 seconds if it's not provided" do
|
171
|
-
mock_retrieve = mock('retrieve')
|
172
|
-
mock_retrieve.stub!(:[]=)
|
173
|
-
mock_http = mock('http')
|
174
|
-
|
175
|
-
Net::HTTP::Retrieve.should_receive(:new).with("/services/user/location/?timeout=15").and_return(mock_retrieve)
|
176
|
-
Net::HTTP.should_receive(:start).and_yield(mock_http)
|
177
|
-
mock_http.should_receive(:request).with(mock_retrieve).and_return(:response)
|
178
|
-
|
179
|
-
Session.open("http://#{DotNetServices.relay_host}/services/user/location") do
|
180
|
-
|session|
|
181
|
-
session.retrieve
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
end
|
186
|
-
|
187
|
-
describe "get_from_relay" do
|
188
|
-
|
189
|
-
it "should set X-Process-At header and send to the bus as normal post" do
|
190
|
-
mock_http = mock('http')
|
191
|
-
Net::HTTP.should_receive(:start).with(DotNetServices.relay_host, 80).and_yield(mock_http)
|
192
|
-
|
193
|
-
mock_http.should_receive(:request) do |get_request|
|
194
|
-
get_request['X-Process-At'].should == 'http://schemas.microsoft.com/ws/2007/08/connect/roles/relay'
|
195
|
-
true
|
196
|
-
end
|
197
|
-
|
198
|
-
Session.open("http://#{DotNetServices.relay_host}/services/user/location") do
|
199
|
-
|session|
|
200
|
-
session.get_from_relay
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
end
|
205
|
-
|
206
|
-
describe "post_to_relay" do
|
207
|
-
|
208
|
-
it "should set X-Process-At header and send to the bus as normal post" do
|
209
|
-
mock_http = mock('http')
|
210
|
-
Net::HTTP.should_receive(:start).with(DotNetServices.relay_host, 80).and_yield(mock_http)
|
211
|
-
|
212
|
-
mock_http.should_receive(:request) do |post_request|
|
213
|
-
post_request['X-Process-At'].should == 'http://schemas.microsoft.com/ws/2007/08/connect/roles/relay'
|
214
|
-
true
|
215
|
-
end
|
216
|
-
|
217
|
-
Session.open("http://#{DotNetServices.relay_host}/services/user/location") do
|
218
|
-
|session|
|
219
|
-
session.post_to_relay
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
end
|
224
|
-
|
225
|
-
def mock_http_get(host, port, path, query = nil)
|
226
|
-
mock_http = mock('http')
|
227
|
-
mock_get = mock('get')
|
228
|
-
Net::HTTP.should_receive(:start).with(host, port).and_yield(mock_http)
|
229
|
-
path_and_query = query ? "#{path}?#{query}" : path
|
230
|
-
Net::HTTP::Get.should_receive(:new).with(path_and_query).and_return(mock_get)
|
231
|
-
mock_http.should_receive(:request).with(mock_get).and_return(:http_get_result)
|
232
|
-
[mock_http, mock_get]
|
233
|
-
end
|
234
|
-
|
235
|
-
def mock_http_post_form(host, port, path, form_data=nil)
|
236
|
-
mock_http = mock('http')
|
237
|
-
mock_post = mock('post')
|
238
|
-
Net::HTTP.should_receive(:start).with(host, port).and_yield(mock_http)
|
239
|
-
Net::HTTP::Post.should_receive(:new).with(path).and_return(mock_post)
|
240
|
-
mock_post.should_receive(:form_data=).with(form_data)
|
241
|
-
mock_post.should_receive(:content_type=).with('application/x-www-form-urlencoded')
|
242
|
-
mock_http.should_receive(:request).with(mock_post).and_return(:http_post_result)
|
243
|
-
[mock_http, mock_post]
|
244
|
-
end
|
245
|
-
|
246
|
-
end
|
247
|
-
end
|