Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #69 from 18F/service-binder-update
Browse files Browse the repository at this point in the history
Service binder update
  • Loading branch information
RAMIREZG committed Aug 17, 2015
2 parents e4122ef + 416e1f3 commit da73671
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
2 changes: 1 addition & 1 deletion static/app/views/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ <h3 class="panel-title">VCAP Info</h3>
</div>
<div class="panel-body" ng-show='service.credentials' ng-init='showCredentials=false'>
<button type="button" class="btn btn-xs btn-danger" ng-hide="showCredentials" mwl-confirm
title="Warning!" message="These are senstive data DO NOT SHARE!"
title="Warning!" message="Look behind you! This info may contain sensitive data such as passwords. DO NOT SHARE!"
on-confirm="showCredentials=true" confirm-button-type="danger"
cancel-button-type="default">Show Credentials</button>
<button type="button" class="btn btn-xs btn-info" ng-show="showCredentials" ng-click="showCredentials=false">Hide Credentials</button>
Expand Down
44 changes: 41 additions & 3 deletions static/tests/CFService_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ describe('CloudFoundry Service Tests', function() {
})
httpBackend.flush();
});
});


describe('getOrgs', function() {
it('should return false if not authenticated', function() {
httpBackend.whenGET('/v2/authstatus').respond({
status: 'unauthorized'
Expand Down Expand Up @@ -343,6 +346,41 @@ describe('CloudFoundry Service Tests', function() {
});
});

describe('getServiceCredentials', function() {
it('it should return service credentials for a bound app by searching through and finding the instances that matches', function() {
httpBackend.whenGET('/v2/services_instances/serviceguid/service_bindings')
.respond({
resources: [{
entity: {
space_guid: 'spaceguid2',
credentials: {}
}
}, {
entity: {
space_guid: 'spaceguid1',
credentials: {
secret: 'a'
}
}
}]
})
var service = {
entity: {
service_bindings_url: '/v2/services_instances/serviceguid/service_bindings'
},
space_guid: 'spaceguid1'
}
$cloudfoundry.getServiceCredentials(service)
.then(function(data) {
expect(data).toEqual({
secret: 'a'
})
});
httpBackend.flush();
})

})

describe('getServiceDetails', function() {
it('should collect a specific service\'s details', function() {

Expand Down Expand Up @@ -464,9 +502,9 @@ describe('CloudFoundry Service Tests', function() {

it('should delete all bound instances when the bound parameter is true', function() {
httpBackend.whenDELETE('/v2/service_instance/serviceguid').respond({
message: 'service instance deleted'
})
// These two requests should be flushed when call is finished
message: 'service instance deleted'
})
// These two requests should be flushed when call is finished
httpBackend.whenDELETE('/v2/bindingurl1').respond({
message: 'deleted'
})
Expand Down
9 changes: 7 additions & 2 deletions static/tests/Ctrl_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ describe('SpaceCtrl', function() {

});


});

describe('MarketCtrl', function() {
Expand Down Expand Up @@ -425,6 +426,7 @@ describe('MarketCtrl', function() {
it('should return the active org', function() {
expect(scope.activeOrg.entity.name).toEqual('org1')
});

});

describe('ServiceCtrl', function() {
Expand Down Expand Up @@ -558,6 +560,7 @@ describe('AppCtrl', function() {


it('should put the available services into the app along with the boundService and credentials obj if it\'s bound', function() {

expect(scope.availableServices).toEqual([{
metadata: {
guid: 'serviceguid'
Expand All @@ -566,6 +569,7 @@ describe('AppCtrl', function() {
guid: 'serviceguid'
},
credentials: {}

}]);
});

Expand Down Expand Up @@ -599,9 +603,9 @@ describe('AppCtrl', function() {
app_guid: 'appguid'
})
});
// TODO test callback

it('should bind service when called', function() {
spyOn(cloudfoundry, 'unbindService')
spyOn(cloudfoundry, 'unbindService').and.callThrough()
scope.unbindService({
boundService: {
guid: 'serviceguid2'
Expand All @@ -612,6 +616,7 @@ describe('AppCtrl', function() {
app_guid: 'appguid'
}, jasmine.any(Function))
});

it('should bind service when called and then refresh appSummary', function() {
scope.unbindService({
boundService: {
Expand Down

0 comments on commit da73671

Please sign in to comment.