maitre_d 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +0 -5
- data/README.textile +13 -31
- data/addon-manifest.json +11 -4
- data/lib/maitre_d.rb +4 -1
- data/lib/maitre_d/api.rb +30 -0
- data/lib/maitre_d/api/authenticated.rb +45 -0
- data/lib/maitre_d/api/change_plan.rb +15 -0
- data/lib/maitre_d/api/create.rb +10 -0
- data/lib/maitre_d/api/delete.rb +13 -0
- data/lib/maitre_d/api/sso.rb +65 -0
- data/lib/maitre_d/cloud_control.rb +4 -3
- data/lib/maitre_d/heroku.rb +4 -4
- data/maitre_d.gemspec +7 -4
- data/spec/api/cloud_control/provisioning_spec.rb +18 -18
- data/spec/api/cloud_control/single_sign_on_spec.rb +13 -13
- data/spec/api/heroku/provisioning_spec.rb +31 -23
- data/spec/api/heroku/single_sign_on_spec.rb +15 -15
- data/spec/internal/app/listeners/cloud_control_listener.rb +1 -1
- data/spec/internal/app/listeners/heroku_listener.rb +1 -1
- data/spec/internal/config/initializers/heroku.rb +2 -2
- data/spec/internal/config/routes.rb +3 -5
- data/spec/spec_helper.rb +1 -2
- metadata +50 -42
- data/lib/maitre_d/broadstack.rb +0 -40
- data/lib/maitre_d/broadstack/api.rb +0 -49
- data/lib/maitre_d/broadstack/api_helpers.rb +0 -44
- data/lib/maitre_d/cloud_control/api.rb +0 -47
- data/lib/maitre_d/cloud_control/api_helpers.rb +0 -28
- data/lib/maitre_d/heroku/api.rb +0 -47
- data/lib/maitre_d/heroku/api_helpers.rb +0 -46
- data/lib/maitre_d/heroku/listener.rb +0 -17
- data/lib/maitre_d/opperator.rb +0 -25
- data/lib/maitre_d/opperator/api.rb +0 -25
- data/lib/maitre_d/opperator/api_helpers.rb +0 -11
- data/lib/maitre_d/opperator/listener.rb +0 -13
- data/spec/api/broadstack/provisioning_spec.rb +0 -94
- data/spec/api/broadstack/single_sign_on_spec.rb +0 -49
- data/spec/api/opperator/provisioning_spec.rb +0 -55
- data/spec/internal/app/listeners/broadstack_listener.rb +0 -30
- data/spec/internal/app/listeners/opperator_listener.rb +0 -16
- data/spec/internal/config/initializers/broadstack.rb +0 -8
- data/spec/internal/config/initializers/opperator.rb +0 -6
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Broadstack SSO API' do
|
4
|
-
let(:timestamp) { Time.now.to_i }
|
5
|
-
let(:nav_data) { 'heroku-nav-data-goes-here' }
|
6
|
-
let(:token) {
|
7
|
-
pre_token = "789:sea salt:#{timestamp.to_s}"
|
8
|
-
Digest::SHA1.hexdigest(pre_token).to_s
|
9
|
-
}
|
10
|
-
|
11
|
-
it "renders a 403 if the token is incorrect" do
|
12
|
-
post '/broadstack/sso', :token => 'foo', :id => '789',
|
13
|
-
:timestamp => timestamp, 'nav-data' => nav_data
|
14
|
-
|
15
|
-
response.status.should == 403
|
16
|
-
end
|
17
|
-
|
18
|
-
it "renders a 403 if the timestamp is older than 5 minutes" do
|
19
|
-
timestamp = 5.minutes.ago.to_i - 1
|
20
|
-
pre_token = "789:sea salt:#{timestamp.to_s}"
|
21
|
-
token = Digest::SHA1.hexdigest(pre_token).to_s
|
22
|
-
|
23
|
-
post '/broadstack/sso', :token => token, :id => '789',
|
24
|
-
:timestamp => timestamp, 'nav-data' => nav_data
|
25
|
-
|
26
|
-
response.status.should == 403
|
27
|
-
end
|
28
|
-
|
29
|
-
it "sets the heroku nav data cookie" do
|
30
|
-
post '/broadstack/sso', :token => token, :id => '789',
|
31
|
-
:timestamp => timestamp, 'nav-data' => nav_data
|
32
|
-
|
33
|
-
cookies['heroku-nav-data'].should == nav_data
|
34
|
-
end
|
35
|
-
|
36
|
-
it "redirects to the appropriate URL" do
|
37
|
-
post '/broadstack/sso', :token => token, :id => '789',
|
38
|
-
:timestamp => timestamp, 'nav-data' => nav_data
|
39
|
-
|
40
|
-
response.should redirect_to('/my/dashboard')
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should set the provided session variables" do
|
44
|
-
post '/broadstack/sso', :token => token, :id => '789',
|
45
|
-
:timestamp => timestamp, 'nav-data' => nav_data
|
46
|
-
|
47
|
-
session[:app_id].should == '789'
|
48
|
-
end
|
49
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Opperator Provisioning API' do
|
4
|
-
let(:json_response) { JSON.parse response.body }
|
5
|
-
|
6
|
-
describe 'Subscription' do
|
7
|
-
it "returns a 401 status if the secret does not match" do
|
8
|
-
post '/opperator/instances', {'features' => {}},
|
9
|
-
{'X-Opperator-Shared-Secret' => 'wrong-secret'}
|
10
|
-
|
11
|
-
response.status.should == 401
|
12
|
-
end
|
13
|
-
|
14
|
-
it "returns the instance id" do
|
15
|
-
post '/opperator/instances', {'features' => {}},
|
16
|
-
{'X-Opperator-Shared-Secret' => 'something-special'}
|
17
|
-
|
18
|
-
json_response['id'].should == '321'
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns a hash of options" do
|
22
|
-
post '/opperator/instances', {'features' => {}},
|
23
|
-
{'X-Opperator-Shared-Secret' => 'something-special'}
|
24
|
-
|
25
|
-
json_response['config'].should == {'provisioned_for' => 'opperator'}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'Cancellation' do
|
30
|
-
it "returns a 401 status if the secret does not match" do
|
31
|
-
delete '/opperator/instances/323', {},
|
32
|
-
{'X-Opperator-Shared-Secret' => 'wrong-secret'}
|
33
|
-
|
34
|
-
response.status.should == 401
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'Modification' do
|
39
|
-
it "returns a 401 status if the secret does not match" do
|
40
|
-
put '/opperator/instances/323', {'features' => {}},
|
41
|
-
{'X-Opperator-Shared-Secret' => 'wrong-secret'}
|
42
|
-
|
43
|
-
response.status.should == 401
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'Warning' do
|
48
|
-
it "returns a 401 status if the secret does not match" do
|
49
|
-
put '/opperator/plan_warning/323', {},
|
50
|
-
{'X-Opperator-Shared-Secret' => 'wrong-secret'}
|
51
|
-
|
52
|
-
response.status.should == 401
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
class BroadstackListener
|
2
|
-
def provision(heroku_id, plan, region, callback_url, logplex_token, options)
|
3
|
-
{
|
4
|
-
:id => '123',
|
5
|
-
:config => {'FOO_PROVISIONED' => 'true'},
|
6
|
-
:message => 'Add-on provisioned!',
|
7
|
-
:region => region
|
8
|
-
}
|
9
|
-
end
|
10
|
-
|
11
|
-
def plan_change(resource_id, heroku_id, plan)
|
12
|
-
{
|
13
|
-
:config => {'FOO_PROVISIONED' => 'false'},
|
14
|
-
:message => 'Add-on upgraded or downgraded.'
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
def deprovision(resource_id)
|
19
|
-
{
|
20
|
-
:message => 'Add-on removed.'
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
def single_sign_on(resource_id)
|
25
|
-
{
|
26
|
-
:uri => '/my/dashboard',
|
27
|
-
:session => {:app_id => resource_id}
|
28
|
-
}
|
29
|
-
end
|
30
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class OpperatorListener < MaitreD::Opperator::Listener
|
2
|
-
def provision(features)
|
3
|
-
{
|
4
|
-
'id' => '321',
|
5
|
-
'config' => {'provisioned_for' => 'opperator'}
|
6
|
-
}
|
7
|
-
end
|
8
|
-
|
9
|
-
def deprovision(resource_id)
|
10
|
-
#
|
11
|
-
end
|
12
|
-
|
13
|
-
def change_plan(resource_id, features)
|
14
|
-
#
|
15
|
-
end
|
16
|
-
end
|