vidibus-service 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +38 -0
- data/Rakefile +10 -20
- data/config/routes.rb +1 -1
- data/lib/vidibus-service.rb +1 -3
- data/lib/vidibus/service.rb +5 -10
- data/lib/vidibus/service/connector_app.rb +2 -1
- data/lib/vidibus/service/errors.rb +5 -0
- data/lib/vidibus/service/version.rb +5 -0
- metadata +92 -80
- data/.bundle/config +0 -2
- data/.document +0 -5
- data/.rspec +0 -2
- data/Gemfile +0 -18
- data/README.rdoc +0 -30
- data/VERSION +0 -1
- data/spec/spec_helper.rb +0 -31
- data/spec/vidibus/service/client_spec.rb +0 -73
- data/spec/vidibus/service/connector_app_spec.rb +0 -320
- data/spec/vidibus/service/controller_validations_spec.rb +0 -5
- data/spec/vidibus/service/mongoid_spec.rb +0 -226
- data/spec/vidibus/service_spec.rb +0 -14
- data/vidibus-service.gemspec +0 -106
data/.bundle/config
DELETED
data/.document
DELETED
data/.rspec
DELETED
data/Gemfile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
source :rubygems
|
2
|
-
|
3
|
-
gem "mongoid", "~> 2.0.0"
|
4
|
-
gem "vidibus-core_extensions"
|
5
|
-
gem "vidibus-secure"
|
6
|
-
gem "vidibus-uuid"
|
7
|
-
gem "vidibus-validate_uri"
|
8
|
-
gem "httparty"
|
9
|
-
gem "json"
|
10
|
-
|
11
|
-
group :development do
|
12
|
-
gem "jeweler"
|
13
|
-
gem "rake"
|
14
|
-
gem "rspec", "~> 2.0.0"
|
15
|
-
gem "rr"
|
16
|
-
gem "relevance-rcov"
|
17
|
-
gem "webmock"
|
18
|
-
end
|
data/README.rdoc
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
= Vidibus::Service
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
|
6
|
-
== Requirements
|
7
|
-
|
8
|
-
In order to work properly this gem needs the route /connector to call a Rack app. Usually this route gets provided automatically but that may fail if your application has some sort of catch-all route. To check if the route works as expected, just call http://yourapp.com/connector and expect an error message like +This service has not been configured yet. Use your Connector to set it up.+
|
9
|
-
|
10
|
-
If you don't see this error message, add the route manually at the top of your routes.rb:
|
11
|
-
|
12
|
-
match "/connector" => Vidibus::Service::ConnectorApp
|
13
|
-
|
14
|
-
== TODO
|
15
|
-
|
16
|
-
* ControllerValidations: Setting @service and @realm is inconsistent; @service is a service object, @realm is a string
|
17
|
-
|
18
|
-
== Note on Patches/Pull Requests
|
19
|
-
|
20
|
-
* Fork the project.
|
21
|
-
* Make your feature addition or bug fix.
|
22
|
-
* Add tests for it. This is important so I don't break it in a
|
23
|
-
future version unintentionally.
|
24
|
-
* Commit, do not mess with rakefile, version, or history.
|
25
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
26
|
-
* Send me a pull request. Bonus points for topic branches.
|
27
|
-
|
28
|
-
== Copyright
|
29
|
-
|
30
|
-
Copyright (c) 2010 Andre Pankratz. See LICENSE for details.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.0
|
data/spec/spec_helper.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "active_support/core_ext"
|
6
|
-
require "rspec"
|
7
|
-
require "rr"
|
8
|
-
require "mongoid"
|
9
|
-
require "webmock/rspec"
|
10
|
-
|
11
|
-
require "vidibus-service"
|
12
|
-
require "app/models/service"
|
13
|
-
|
14
|
-
Mongoid.configure do |config|
|
15
|
-
name = "vidibus-service_test"
|
16
|
-
host = "localhost"
|
17
|
-
config.master = Mongo::Connection.new.db(name)
|
18
|
-
config.logger = nil
|
19
|
-
end
|
20
|
-
|
21
|
-
RSpec.configure do |config|
|
22
|
-
config.include WebMock::API
|
23
|
-
config.mock_with :rr
|
24
|
-
config.before(:each) do
|
25
|
-
Mongoid.master.collections.select {|c| c.name !~ /system/}.each(&:drop)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
I18n.load_path += Dir[File.join('config', 'locales', '**', '*.{rb,yml}')]
|
30
|
-
|
31
|
-
#ENV["VIDIBUS_SECURE_KEY"] = "c4l60HC/lyerr2VEnrP7s2YAldyZGfIBePUzCl+tBsTs1EWJOc8dEJ7F2Vty7KPEeRuBWGxZHVAbku8pLo+UvXRpLcRiF7lxKiKl"
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Vidibus::Service::Client do
|
4
|
-
let(:this) {Service.create!(:function => "manager", :url => "http://manager.local", :uuid => "973a8710926e012d0a8c58b035f038ab", :secret => "EaDai5nz16DbQTWQuuFdd4WcAiZYRPDwZTn2IQeXbPE4yBg3rr", :this => true, :realm_uuid => nil)}
|
5
|
-
let(:uploader) {Service.create!(:function => "uploader", :url => "http://uploader.local", :uuid => "ddeb4500668e012d47bb58b035f038ab", :secret => "XaDai5nz1sDbQTWQuuFdd4WcAiZYRPDwZTn2IQeXbPE4yBg3rr", :realm_uuid => "e33f0d9093f9012d0dbc58b035f038ab")}
|
6
|
-
let(:client) { this; Vidibus::Service::Client.new(uploader) }
|
7
|
-
|
8
|
-
describe "#initialize" do
|
9
|
-
it "should require a service object" do
|
10
|
-
expect { Vidibus::Service::Client.new(:uploader) }.should raise_error(Vidibus::Service::Client::ServiceError)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should require this" do
|
14
|
-
expect { Vidibus::Service::Client.new(uploader) }.should raise_error(Service::ConfigurationError)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should set URL of given service as base_uri" do
|
18
|
-
this
|
19
|
-
client = Vidibus::Service::Client.new(uploader)
|
20
|
-
client.base_uri.should eql(uploader.url)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#get" do
|
25
|
-
it "should load data via GET" do
|
26
|
-
stub_http_request(:get, "http://uploader.local/success").
|
27
|
-
with(:query => {:realm => uploader.realm_uuid, :service => this.uuid, :sign => "43a4d004c55113131f198c9772760467727b5564de74aacfcf4686751e3d388a"}).
|
28
|
-
to_return(:status => 200, :body => %({"hot":"stuff"}))
|
29
|
-
response = client.get("/success")
|
30
|
-
response.code.should eql(200)
|
31
|
-
response.should eql({"hot" => "stuff"})
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should handle non-JSON responses" do
|
35
|
-
stub_http_request(:get, "http://uploader.local/success").
|
36
|
-
with(:query => {:realm => uploader.realm_uuid, :service => this.uuid, :sign => "43a4d004c55113131f198c9772760467727b5564de74aacfcf4686751e3d388a"}).
|
37
|
-
to_return(:status => 200, :body => "something")
|
38
|
-
response = client.get("/success")
|
39
|
-
response.code.should eql(200)
|
40
|
-
response.should eql("something")
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "#post" do
|
45
|
-
it "should send data via POST" do
|
46
|
-
stub_http_request(:post, "http://uploader.local/create").
|
47
|
-
with(:body => {:some => "thing", :realm => uploader.realm_uuid, :service => this.uuid, :sign => "9c16bc080f106c73f28813f02899be97301b1b627d25a65d52f68a3c9732559d"}).
|
48
|
-
to_return(:status => 200)
|
49
|
-
response = client.post("/create", :body => {:some => "thing"})
|
50
|
-
response.code.should eql(200)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "#put" do
|
55
|
-
it "should send data via PUT" do
|
56
|
-
stub_http_request(:put, "http://uploader.local/update").
|
57
|
-
with(:body => {:some => "thing", :realm => uploader.realm_uuid, :service => this.uuid, :sign => "57e75433e49d9ef160b03b9e6a7d91fbd6523471eb8e7e36bb861066101f0903"}).
|
58
|
-
to_return(:status => 200)
|
59
|
-
response = client.put("/update", :body => {:some => "thing"})
|
60
|
-
response.code.should eql(200)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "#delete" do
|
65
|
-
it "should send a DELETE request" do
|
66
|
-
stub_http_request(:delete, "http://uploader.local/record/123").
|
67
|
-
with(:query => {:realm => uploader.realm_uuid, :service => this.uuid, :sign => "b9c026563d950a719e168c6f072f75c13f4843b82274f57f6e5a9a4cd8e0cc64"}).
|
68
|
-
to_return(:status => 200)
|
69
|
-
response = client.delete("/record/123")
|
70
|
-
response.code.should eql(200)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,320 +0,0 @@
|
|
1
|
-
require "spec_helper.rb"
|
2
|
-
|
3
|
-
describe "Vidibus::Service::ConnectorApp" do
|
4
|
-
include Rack::Test::Methods
|
5
|
-
let(:this_uuid) {"344b4b8088fb012dd3e558b035f038ab"}
|
6
|
-
let(:this_uri) {"https://connector.local/services/#{this_uuid}/secret"}
|
7
|
-
let(:connector_uuid) {"60dfef509a8e012d599558b035f038ab"}
|
8
|
-
|
9
|
-
let(:nonce) {"hkO2ssb28Gks19s9h2hdhbBs83hdis"}
|
10
|
-
let(:secret) {"EaDai5nz16DbQTWQuuFdd4WcAiZYRPDwZTn2IQeXbPE4yBg3rr"}
|
11
|
-
let(:encrypted_secret) {Vidibus::Secure.encrypt(secret, nonce)}
|
12
|
-
let(:signature) {Vidibus::Secure.sign(encrypted_secret, nonce)}
|
13
|
-
|
14
|
-
let(:this_params) {{:uuid => this_uuid, :url => "http://manager.local", :function => "manager", :this => true}}
|
15
|
-
let(:connector_params) {{:uuid => connector_uuid, :url => "https://connector.local", :function => "connector", :secret => nil, :realm_uuid => nil}}
|
16
|
-
let(:this) {Service.create!(this_params.merge(:secret => "EaDai5nz16DbQTWQuuFdd4WcAiZYRPDwZTn2IQeXbPE4yBg3rr", :realm_uuid => nil))}
|
17
|
-
let(:connector) {Service.create!(connector_params)}
|
18
|
-
let(:uploader_params) {{:uuid => "c0861d609247012d0a8b58b035f038ab", :url => "http://uploader.local", :function => "uploader"}}
|
19
|
-
let(:uploader) {Service.create!(uploader_params.merge(:secret => "whatever", :realm_uuid => "408411702613012e39ec58b035f038ab"))}
|
20
|
-
|
21
|
-
def app
|
22
|
-
@app ||= Vidibus::Service::ConnectorApp
|
23
|
-
end
|
24
|
-
|
25
|
-
# Sends a signed request.
|
26
|
-
def signed_request(method, url, params = nil)
|
27
|
-
self.send(method, *Vidibus::Secure.sign_request(method, url, params, this.secret))
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should fail for request methods other than GET, POST, PUT, and DELETE" do
|
31
|
-
head "http://manager.local/connector"
|
32
|
-
last_response.status.should eql(400)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should fail for paths other than /connector" do
|
36
|
-
get "http://manager.local/something"
|
37
|
-
last_response.status.should eql(400)
|
38
|
-
last_response.body.should eql(%({"error":"This app must be configured to respond to /connector path."}))
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "GET requests" do
|
42
|
-
it "should fail without signature" do
|
43
|
-
this and connector
|
44
|
-
get "http://manager.local/connector"
|
45
|
-
last_response.status.should eql(400)
|
46
|
-
last_response.body.should eql(%({"error":"Invalid signature."}))
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should fail without valid signature" do
|
50
|
-
this and connector
|
51
|
-
get "http://manager.local/connector?sign=xxx"
|
52
|
-
last_response.status.should eql(400)
|
53
|
-
last_response.body.should eql(%({"error":"Invalid signature."}))
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should fail without this service" do
|
57
|
-
connector
|
58
|
-
get "http://manager.local/connector"
|
59
|
-
last_response.status.should eql(400)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should return public data of this service as JSON" do
|
63
|
-
this
|
64
|
-
signed_request(:get, "http://manager.local/connector")
|
65
|
-
last_response.body.should eql({:this => this.public_data}.to_json)
|
66
|
-
last_response.status.should eql(200)
|
67
|
-
last_response.content_type.should eql("text/javascript; charset=utf-8")
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should also return public data of connector as JSON, if a connector is given" do
|
71
|
-
this and connector
|
72
|
-
signed_request(:get, "http://manager.local/connector")
|
73
|
-
last_response.body.should eql({:this => this.public_data, :connector => connector.public_data}.to_json)
|
74
|
-
last_response.content_type.should eql("text/javascript; charset=utf-8")
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "POST requests" do
|
79
|
-
it "should fail if this service has already been set up" do
|
80
|
-
this
|
81
|
-
post "http://manager/connector", {}
|
82
|
-
last_response.status.should eql(400)
|
83
|
-
last_response.body.should match("This service has already been set up.")
|
84
|
-
end
|
85
|
-
|
86
|
-
context "without Connector or Connector params" do
|
87
|
-
it "should require Connector params" do
|
88
|
-
post "http://manager.local/connector"
|
89
|
-
last_response.status.should eql(400)
|
90
|
-
last_response.body.should match("No Connector data given.")
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "with Connector params" do
|
95
|
-
before {stub.any_instance_of(Vidibus::Service::ConnectorApp).create_this!}
|
96
|
-
|
97
|
-
it "should fail if params are invalid given" do
|
98
|
-
post "http://manager.local/connector", {connector_uuid => connector_params.except(:url)}
|
99
|
-
last_response.status.should eql(400)
|
100
|
-
last_response.body.should match("Setting up the Connector failed:")
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should set up a Connector with valid params" do
|
104
|
-
post "http://manager.local/connector", {connector_uuid => connector_params}
|
105
|
-
last_response.status.should eql(201)
|
106
|
-
connector = Service.where(:uuid => connector_params[:uuid]).first
|
107
|
-
connector.should be_a(Service)
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should accept any value as key" do
|
111
|
-
post "http://manager.local/connector", {"something" => connector_params}
|
112
|
-
last_response.status.should eql(201)
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should not create another connector if one already exists" do
|
116
|
-
connector
|
117
|
-
post "http://manager.local/connector", {connector_uuid => connector_params}
|
118
|
-
last_response.status.should eql(201)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
context "with existing Connector" do
|
123
|
-
let(:secret_data) {{"secret" => encrypted_secret, "sign" => signature}}
|
124
|
-
let(:stub_secret_request!) {stub(HTTParty).get(this_uri, :format => :json) {secret_data}}
|
125
|
-
before { connector }
|
126
|
-
|
127
|
-
it "should not require Connector params if a Connector is present" do
|
128
|
-
post "http://manager.local/connector"
|
129
|
-
last_response.body.should_not match("No Connector data given.")
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should require params for this service" do
|
133
|
-
post "http://manager.local/connector"
|
134
|
-
last_response.status.should eql(400)
|
135
|
-
last_response.body.should match("No data given for this service.")
|
136
|
-
end
|
137
|
-
|
138
|
-
it "should fail if params for this service are invalid" do
|
139
|
-
post "http://manager.local/connector", {this_uuid => this_params.except(:function)}
|
140
|
-
last_response.status.should eql(400)
|
141
|
-
last_response.body.should match("Setting up this service failed:")
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should fail if a secret is given" do
|
145
|
-
post "http://manager.local/connector", {this_uuid => this_params.merge(:secret => "something")}
|
146
|
-
last_response.status.should eql(400)
|
147
|
-
last_response.body.should match("Setting a secret for this service is not allowed!")
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should fail unless a nonce is given" do
|
151
|
-
post "http://manager.local/connector", {this_uuid => this_params}
|
152
|
-
last_response.status.should eql(400)
|
153
|
-
last_response.body.should match("No nonce given.")
|
154
|
-
end
|
155
|
-
|
156
|
-
it "should request a secret for this Service" do
|
157
|
-
mock(HTTParty).get(this_uri, :format => :json) {{}}
|
158
|
-
stub.any_instance_of(Vidibus::Service::ConnectorApp).decrypt_secret! {"ok"}
|
159
|
-
post "http://manager.local/connector", {this_uuid => this_params.merge(:nonce => nonce)}
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should fail if sign cannot be validated with nonce" do
|
163
|
-
stub_secret_request!
|
164
|
-
post "http://manager.local/connector", {this_uuid => this_params.merge(:nonce => "invalid")}
|
165
|
-
last_response.status.should eql(400)
|
166
|
-
last_response.body.should match("Nonce is invalid.")
|
167
|
-
end
|
168
|
-
|
169
|
-
it "should decrypt the secret with a valid nonce" do
|
170
|
-
stub_secret_request!
|
171
|
-
mock.any_instance_of(Service).secret=(secret)
|
172
|
-
post "http://manager.local/connector", {this_uuid => this_params.merge(:nonce => nonce)}
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should set up this Service with valid params" do
|
176
|
-
stub_secret_request!
|
177
|
-
post "http://manager.local/connector", {connector_uuid => this_params.merge(:nonce => nonce)}
|
178
|
-
stub(HTTParty).get(this_uri, :format => :json) {secret_data}
|
179
|
-
last_response.status.should eql(201)
|
180
|
-
this = Service.where(:this => true).first
|
181
|
-
this.should be_a(Service)
|
182
|
-
this.secret.should eql(secret)
|
183
|
-
this.url.should eql("http://manager.local")
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
describe "PUT requests" do
|
189
|
-
it "should fail without signature" do
|
190
|
-
this and connector
|
191
|
-
put "http://manager.local/connector"
|
192
|
-
last_response.status.should eql(400)
|
193
|
-
last_response.body.should eql(%({"error":"Invalid signature."}))
|
194
|
-
end
|
195
|
-
|
196
|
-
it "should fail without valid signature" do
|
197
|
-
this and connector
|
198
|
-
put "http://manager.local/connector?sign=xxx"
|
199
|
-
last_response.status.should eql(400)
|
200
|
-
last_response.body.should eql(%({"error":"Invalid signature."}))
|
201
|
-
end
|
202
|
-
|
203
|
-
it "should succeed with valid signature" do
|
204
|
-
this and connector
|
205
|
-
signed_request(:put, "http://manager.local/connector")
|
206
|
-
last_response.status.should eql(200)
|
207
|
-
end
|
208
|
-
|
209
|
-
it "should fail if this service is unconfigured" do
|
210
|
-
get "http://manager.local/connector?sign=jkasdnkajdb"
|
211
|
-
last_response.status.should eql(400)
|
212
|
-
end
|
213
|
-
|
214
|
-
it "should update an existing service without realm_uuid" do
|
215
|
-
this and connector
|
216
|
-
url = "http://newconnector.local"
|
217
|
-
signed_request(:put, "http://manager.local/connector", {connector.uuid => {:url => url}})
|
218
|
-
last_response.status.should eql(200)
|
219
|
-
Service.local(:connector).url.should eql(url)
|
220
|
-
end
|
221
|
-
|
222
|
-
it "should update an existing service with given realm_uuid" do
|
223
|
-
this and connector and uploader
|
224
|
-
url = "http://newuploader.local"
|
225
|
-
signed_request(:put, "http://manager.local/connector", {uploader.uuid => {:url => url, :realm_uuid => uploader.realm_uuid}})
|
226
|
-
last_response.status.should eql(200)
|
227
|
-
Service.local(:uploader, uploader.realm_uuid).url.should eql(url)
|
228
|
-
end
|
229
|
-
|
230
|
-
it "should not update existing services with a different realm_uuid" do
|
231
|
-
this and connector and uploader
|
232
|
-
different_realm_uuid = "e75234809111012d05ac58b035f038ab"
|
233
|
-
different_uploader = Service.create!(uploader_params.merge(:secret => "whatever", :realm_uuid => different_realm_uuid))
|
234
|
-
signed_request(:put, "http://manager.local/connector", {uploader.uuid => {:url => "http://newuploader.local", :realm_uuid => uploader.realm_uuid}})
|
235
|
-
last_response.status.should eql(200)
|
236
|
-
Service.local(:uploader, different_realm_uuid).url.should eql(different_uploader.url)
|
237
|
-
end
|
238
|
-
|
239
|
-
it "should update all existing services with matching uuid" do
|
240
|
-
this and connector and uploader
|
241
|
-
another_uploader = Service.create!(uploader_params.merge(:realm_uuid => "e75234809111012d05ac58b035f038ab", :secret => "whatever"))
|
242
|
-
signed_request(:put, "http://manager.local/connector", {uploader.uuid => {:function => "fancy"}})
|
243
|
-
last_response.status.should eql(200)
|
244
|
-
Service.where(:function => "fancy").to_a.should have(2).services
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should fail if no uuid is given" do
|
248
|
-
this and connector
|
249
|
-
url = "http://newconnector.local"
|
250
|
-
signed_request(:put, "http://manager.local/connector", {:url => url})
|
251
|
-
last_response.status.should eql(400)
|
252
|
-
last_response.body.should match("Updating failed: 'url' is not a valid UUID.")
|
253
|
-
end
|
254
|
-
|
255
|
-
it "should fail if an invalid uuid is given" do
|
256
|
-
this and connector
|
257
|
-
url = "http://newconnector.local"
|
258
|
-
signed_request(:put, "http://manager.local/connector", {"c0861d609247012d0a8b58b035f038ab" => {:url => url}})
|
259
|
-
last_response.status.should eql(400)
|
260
|
-
last_response.body.should match("Updating service c0861d609247012d0a8b58b035f038ab failed:")
|
261
|
-
end
|
262
|
-
|
263
|
-
it "should fail if invalid data is given" do
|
264
|
-
this and connector
|
265
|
-
url = "http://newconnector.local"
|
266
|
-
signed_request(:put, "http://manager.local/connector", {connector.uuid => {:secret => "not allowed"}})
|
267
|
-
last_response.status.should eql(400)
|
268
|
-
last_response.body.should match("Updating service 60dfef509a8e012d599558b035f038ab failed:")
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
describe "DELETE requests" do
|
273
|
-
it "should fail without signature" do
|
274
|
-
this and connector
|
275
|
-
delete "http://manager.local/connector"
|
276
|
-
last_response.status.should eql(400)
|
277
|
-
last_response.body.should eql(%({"error":"Invalid signature."}))
|
278
|
-
end
|
279
|
-
|
280
|
-
it "should fail without valid signature" do
|
281
|
-
this and connector
|
282
|
-
delete "http://manager.local/connector?sign=xxx"
|
283
|
-
last_response.status.should eql(400)
|
284
|
-
last_response.body.should eql(%({"error":"Invalid signature."}))
|
285
|
-
end
|
286
|
-
|
287
|
-
it "should fail if this service is unconfigured" do
|
288
|
-
delete "http://manager.local/connector?sign=jkasdnkajdb"
|
289
|
-
last_response.status.should eql(400)
|
290
|
-
end
|
291
|
-
|
292
|
-
it "should fail if list of UUIDs is not given" do
|
293
|
-
this and connector
|
294
|
-
signed_request(:delete, "http://manager.local/connector", {})
|
295
|
-
last_response.status.should eql(400)
|
296
|
-
last_response.body.should eql(%({"error":"Provide list of UUIDs of services to delete."}))
|
297
|
-
end
|
298
|
-
|
299
|
-
it "should fail if deleting of a service fails" do
|
300
|
-
this and connector
|
301
|
-
stub.any_instance_of(Service).destroy {false} # Would be nice: errors.add(:base, "Failed")
|
302
|
-
signed_request(:delete, "http://manager.local/connector", {:uuids =>[connector_uuid]})
|
303
|
-
last_response.status.should eql(400)
|
304
|
-
last_response.body.should eql(%({"error":"Deleting service 60dfef509a8e012d599558b035f038ab failed: "}))
|
305
|
-
end
|
306
|
-
|
307
|
-
it "should delete services given by UUID" do
|
308
|
-
this and connector
|
309
|
-
signed_request(:delete, "http://manager.local/connector", {:uuids =>[connector_uuid]})
|
310
|
-
last_response.status.should eql(200)
|
311
|
-
Service.local(:connector).should be_nil
|
312
|
-
end
|
313
|
-
|
314
|
-
it "should not care if any given UUID is invalid" do
|
315
|
-
this and connector
|
316
|
-
signed_request(:delete, "http://manager.local/connector", {:uuids =>["invalid", connector_uuid]})
|
317
|
-
last_response.status.should eql(200)
|
318
|
-
end
|
319
|
-
end
|
320
|
-
end
|