Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Bumped vcap_common and pass the dashboard_url back to CCNG in the pro…
Browse files Browse the repository at this point in the history
…vision request response
  • Loading branch information
Phan Le committed May 9, 2013
1 parent a90144f commit 045f1d5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion marketplace/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GIT

GIT
remote: git://github.com/cloudfoundry/vcap-common.git
revision: b9c47759e11e1f55b7ad5265b95db3fc17a8c51f
revision: 129ef520424a81155c097b7a79aa13bb8b736fd7
specs:
vcap_common (2.0.10)
em-http-request (~> 1.0)
Expand Down
10 changes: 5 additions & 5 deletions marketplace/lib/marketplaces/appdirect/appdirect_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def initialize(opts, logger)
@appdirect_endpoint = appdirect_config[:endpoint]
@offering_whitelist = OfferingWhitelist.new(opts[:offering_whitelist], logger)
@app_direct_catalog = AppDirectCatalog.new(@appdirect_endpoint,
method(:perform_request),
logger)
method(:perform_request),
logger)
@test_mode = opts[:test_mode]

if !@test_mode
Expand Down Expand Up @@ -84,9 +84,9 @@ def purchase_service(order)
http_status, response_body = perform_request("post", url, HEADER, body)

if http_status >= 200 and http_status < 300
logger.info("Provision successful")
logger.debug("Body: #{response_body}")
JSON.parse(response_body)
result = JSON.parse(response_body)
result.merge!('dashboard_url' => [url,result.fetch('uuid'), 'sso'].join('/'))
return result
else
# 400 bad request
# 500 if AppDirect has issues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def provision_service(request_body)
{
:configuration => {:plan => request.plan, :name => request.name, :options => {} },
:credentials => credentials,
:service_id => receipt["uuid"],
:service_id => receipt.fetch("uuid"),
:dashboard_url => receipt.fetch('dashboard_url'),
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,18 @@ module VCAP::Services::Marketplace::Appdirect
end.
and_return(
'credentials' => {},
'id' => 'receipt_id'
'id' => 'receipt_id',
'uuid' => 'acbd-efgh',
'dashboard_url' => 'http://dashboard.io',
)
appdirect_marketplace.provision_service(request_body)
appdirect_marketplace.provision_service(request_body).should ==
{
:configuration => {
:plan=>"free", :name=>"mongo name", :options=>{}},
:credentials=>{"name"=>"receipt_id"},
:service_id=>"acbd-efgh",
:dashboard_url=>"http://dashboard.io"
}
end

it "properly provisions services with dashes in their label" do
Expand Down
7 changes: 5 additions & 2 deletions spec/integration/marketplace_gateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@
sendgrid_plans.fetch('resources').first.fetch('entity').fetch('extra').should be
end

it "can provision a service instance" do
it "can provision a service instance with dashboad_url" do
ccng_guid = provision_service_instance('awsome mongo', 'mongolab-dev', 'free')

ccng_guid.should_not be_nil
ccng_service_instance_guids.should include(ccng_guid)
service = ccng_get('/v2/service_instances').fetch('resources').first
service.fetch('metadata').fetch('guid').should == ccng_guid
service.fetch('entity').fetch('dashboard_url').should =~
%r|http://localhost:9999/api/custom/cloudfoundry/v1/services/.*/sso|

app_direct_service_instances = get_json('http://localhost:9999/test/provisioned_services')
app_direct_service_instances.should have(1).entry
Expand Down

0 comments on commit 045f1d5

Please sign in to comment.