summaryrefslogtreecommitdiff
path: root/spec/models/clusters
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2019-02-13 09:46:59 +1300
committerThong Kuah <tkuah@gitlab.com>2019-02-21 23:16:11 +1300
commitaf16fd687e2e5b15a63e6e51d76847512ae8ee72 (patch)
treed54dce5502bc7ceeb856e0fa0dacc5b7f7fda5af /spec/models/clusters
parent66b20a66f4b25a69ff3f59da855ac2cb38c8bca9 (diff)
downloadgitlab-ce-af16fd687e2e5b15a63e6e51d76847512ae8ee72.tar.gz
Do not allow local urls in Kubernetes form
Use existing `public_url` validation to block various local urls. Note that this validation will allow local urls if the "Allow requests to the local network from hooks and services" admin setting is enabled. Block KubeClient from using local addresses It will also respect `allow_local_requests_from_hooks_and_services` so if that is enabled KubeClinet will allow local addresses
Diffstat (limited to 'spec/models/clusters')
-rw-r--r--spec/models/clusters/platforms/kubernetes_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/models/clusters/platforms/kubernetes_spec.rb b/spec/models/clusters/platforms/kubernetes_spec.rb
index 4068d98d8f7..3b32ca8df05 100644
--- a/spec/models/clusters/platforms/kubernetes_spec.rb
+++ b/spec/models/clusters/platforms/kubernetes_spec.rb
@@ -98,6 +98,22 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
it { expect(kubernetes.save).to be_truthy }
end
+
+ context 'when api_url is localhost' do
+ let(:api_url) { 'http://localhost:22' }
+
+ it { expect(kubernetes.save).to be_falsey }
+
+ context 'Application settings allows local requests' do
+ before do
+ allow(ApplicationSetting)
+ .to receive(:current)
+ .and_return(ApplicationSetting.build_from_defaults(allow_local_requests_from_hooks_and_services: true))
+ end
+
+ it { expect(kubernetes.save).to be_truthy }
+ end
+ end
end
context 'when validates token' do