This repository was archived by the owner on Jun 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ def validate
4444 if ( offending_domain = domains_exist_in_other_orgs? )
4545 errors . add ( :name , Sequel . lit ( %{The domain name "#{ name } " cannot be created because "#{ offending_domain . name } " is already reserved by another domain} ) )
4646 end
47+ validate_system_domain_overlap
4748 validate_total_private_domains
4849 end
4950
@@ -115,5 +116,16 @@ def reserved?
115116 rule = PublicSuffix ::List . default . find ( name )
116117 !rule . nil? && rule . decompose ( name ) . last . nil?
117118 end
119+
120+ def validate_system_domain_overlap
121+ system_domain = VCAP ::CloudController ::Config . config . get ( :system_domain )
122+ reserved_system_domains = VCAP ::CloudController ::Config . config . get ( :system_hostnames ) . map { |host | host + '.' + system_domain }
123+ if reserved_system_domains . include? ( name )
124+ errors . add (
125+ :name ,
126+ Sequel . lit ( %{The domain name "#{ name } " cannot be created because "#{ name } " is already reserved by the system} )
127+ )
128+ end
129+ end
118130 end
119131end
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ module VCAP::CloudController
66 let ( :reserved ) { nil }
77
88 before ( :each ) do
9- TestConfig . override ( { reserved_private_domains : reserved } )
9+ TestConfig . override ( system_domain : 'customer-app-domain1.com' , reserved_private_domains : reserved )
1010 end
1111
1212 it { is_expected . to have_timestamp_columns }
@@ -32,6 +32,10 @@ module VCAP::CloudController
3232 include_examples 'domain validation'
3333 end
3434
35+ it 'denies private uaa.customer-app-domain1.com when customer-app-domain1.com is the system domain' do
36+ expect { PrivateDomain . make name : 'uaa.customer-app-domain1.com' } . to raise_error ( Sequel ::ValidationFailed , /is already reserved by the system/ )
37+ end
38+
3539 it 'allows private bar.foo.com when foo.com has the same owner' do
3640 private_domain = PrivateDomain . make name : 'foo.com'
3741 expect { PrivateDomain . make name : 'bar.foo.com' , owning_organization_id : private_domain . owning_organization_id } . to_not raise_error
You can’t perform that action at this time.
0 commit comments