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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/Gemfile +0 -5
  4. data/README.textile +13 -31
  5. data/addon-manifest.json +11 -4
  6. data/lib/maitre_d.rb +4 -1
  7. data/lib/maitre_d/api.rb +30 -0
  8. data/lib/maitre_d/api/authenticated.rb +45 -0
  9. data/lib/maitre_d/api/change_plan.rb +15 -0
  10. data/lib/maitre_d/api/create.rb +10 -0
  11. data/lib/maitre_d/api/delete.rb +13 -0
  12. data/lib/maitre_d/api/sso.rb +65 -0
  13. data/lib/maitre_d/cloud_control.rb +4 -3
  14. data/lib/maitre_d/heroku.rb +4 -4
  15. data/maitre_d.gemspec +7 -4
  16. data/spec/api/cloud_control/provisioning_spec.rb +18 -18
  17. data/spec/api/cloud_control/single_sign_on_spec.rb +13 -13
  18. data/spec/api/heroku/provisioning_spec.rb +31 -23
  19. data/spec/api/heroku/single_sign_on_spec.rb +15 -15
  20. data/spec/internal/app/listeners/cloud_control_listener.rb +1 -1
  21. data/spec/internal/app/listeners/heroku_listener.rb +1 -1
  22. data/spec/internal/config/initializers/heroku.rb +2 -2
  23. data/spec/internal/config/routes.rb +3 -5
  24. data/spec/spec_helper.rb +1 -2
  25. metadata +50 -42
  26. data/lib/maitre_d/broadstack.rb +0 -40
  27. data/lib/maitre_d/broadstack/api.rb +0 -49
  28. data/lib/maitre_d/broadstack/api_helpers.rb +0 -44
  29. data/lib/maitre_d/cloud_control/api.rb +0 -47
  30. data/lib/maitre_d/cloud_control/api_helpers.rb +0 -28
  31. data/lib/maitre_d/heroku/api.rb +0 -47
  32. data/lib/maitre_d/heroku/api_helpers.rb +0 -46
  33. data/lib/maitre_d/heroku/listener.rb +0 -17
  34. data/lib/maitre_d/opperator.rb +0 -25
  35. data/lib/maitre_d/opperator/api.rb +0 -25
  36. data/lib/maitre_d/opperator/api_helpers.rb +0 -11
  37. data/lib/maitre_d/opperator/listener.rb +0 -13
  38. data/spec/api/broadstack/provisioning_spec.rb +0 -94
  39. data/spec/api/broadstack/single_sign_on_spec.rb +0 -49
  40. data/spec/api/opperator/provisioning_spec.rb +0 -55
  41. data/spec/internal/app/listeners/broadstack_listener.rb +0 -30
  42. data/spec/internal/app/listeners/opperator_listener.rb +0 -16
  43. data/spec/internal/config/initializers/broadstack.rb +0 -8
  44. 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
@@ -1,8 +0,0 @@
1
- require 'maitre_d/broadstack'
2
-
3
- MaitreD::Broadstack.configure do |config|
4
- config.id = 'foo'
5
- config.password = 'bar'
6
- config.sso_salt = 'sea salt'
7
- config.listener = BroadstackListener
8
- end
@@ -1,6 +0,0 @@
1
- require 'maitre_d/opperator'
2
-
3
- MaitreD::Opperator.configure do |config|
4
- config.shared_secret = 'something-special'
5
- config.listener = OpperatorListener
6
- end