Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add provider check for builtin services

 - Unit test to verify provider check for built-in services
Change-Id: I1ac9443c33e3d051a9b2e9a7b7669542535b57f2
  • Loading branch information...
commit 3d6883e80765e8c402d4347056226a22e248f0bb 1 parent a1ce3d3
Harshawardhan Gadgil authored
View
2  cloud_controller/app/models/service.rb
@@ -167,7 +167,7 @@ def synthesize_service_type
end
def is_builtin?
- AppConfig.has_key?(:builtin_services) && AppConfig[:builtin_services].has_key?(self.name.to_sym)
+ AppConfig.has_key?(:builtin_services) && AppConfig[:builtin_services].has_key?(self.name.to_sym) && (self.provider == nil || self.provider == "core")
end
def verify_auth_token(token)
View
32 cloud_controller/spec/controllers/services_controller_spec.rb
@@ -206,6 +206,38 @@
response.status.should == 403
AppConfig[:builtin_services].delete(:foo)
end
+
+ it 'should ensure that builtin services have nil or core provider' do
+ AppConfig[:builtin_services][:foo1] = {:token => 'foobar1'}
+ AppConfig[:builtin_services][:foo2] = {:token => 'foobar2'}
+
+ svc_nil_provider = Service.create(
+ :label => 'foo1-1',
+ :url => 'http://www.fooservice.com',
+ :token => ['foobar1'])
+ svc_nil_provider.should be_valid
+ svc_nil_provider.is_builtin?.should == true
+
+ svc_core_provider = Service.create(
+ :label => 'foo2-1',
+ :url => 'http://www.foo2service.com',
+ :token => ['foobar2'],
+ :provider => "core")
+ svc_core_provider.should be_valid
+ svc_core_provider.is_builtin?.should == true
+
+ svc_my_provider = Service.create(
+ :label => 'foo1-1',
+ :url => 'http://www.barservice.com',
+ :token => ['bar'],
+ :provider => "my")
+ svc_my_provider.should be_valid
+ svc_my_provider.is_builtin?.should == false
+
+ AppConfig[:builtin_services].delete(:foo1)
+ AppConfig[:builtin_services].delete(:foo2)
+ end
+
end
describe '#delete' do
Please sign in to comment.
Something went wrong with that request. Please try again.