Add validations for host/ssl roles
Roles with SSL can only have one server. Two roles with SSL can't use the same host.
This commit is contained in:
@@ -346,4 +346,35 @@ class ConfigurationTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test "proxy ssl roles with no host" do
|
||||
@deploy_with_roles[:servers]["workers"]["proxy"] = { "ssl" => true }
|
||||
|
||||
exception = assert_raises(Kamal::ConfigurationError) do
|
||||
Kamal::Configuration.new(@deploy_with_roles)
|
||||
end
|
||||
|
||||
assert_equal "servers/workers/proxy: Must set a host to enable automatic SSL", exception.message
|
||||
end
|
||||
|
||||
test "proxy ssl roles with multiple servers" do
|
||||
@deploy_with_roles[:servers]["workers"]["proxy"] = { "ssl" => true, "host" => "foo.example.com" }
|
||||
|
||||
exception = assert_raises(Kamal::ConfigurationError) do
|
||||
Kamal::Configuration.new(@deploy_with_roles)
|
||||
end
|
||||
|
||||
assert_equal "SSL is only supported on a single server, found 2 servers for role workers", exception.message
|
||||
end
|
||||
|
||||
test "two proxy ssl roles with same host" do
|
||||
@deploy_with_roles[:servers]["web"] = { "hosts" => [ "1.1.1.1" ], "proxy" => { "ssl" => true, "host" => "foo.example.com" } }
|
||||
@deploy_with_roles[:servers]["workers"] = { "hosts" => [ "1.1.1.1" ], "proxy" => { "ssl" => true, "host" => "foo.example.com" } }
|
||||
|
||||
exception = assert_raises(Kamal::ConfigurationError) do
|
||||
Kamal::Configuration.new(@deploy_with_roles)
|
||||
end
|
||||
|
||||
assert_equal "Different roles can't share the same host for SSL: foo.example.com", exception.message
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@ class MainTest < IntegrationTest
|
||||
assert_match /Proxy Host: vm2/, details
|
||||
assert_match /App Host: vm1/, details
|
||||
assert_match /App Host: vm2/, details
|
||||
assert_match /basecamp\/kamal-proxy:#{Kamal::Configuration::Proxy::MINIMUM_VERSION}/, details
|
||||
assert_match /basecamp\/kamal-proxy:#{Kamal::Configuration::PROXY_MINIMUM_VERSION}/, details
|
||||
assert_match /registry:4443\/app:#{first_version}/, details
|
||||
|
||||
audit = kamal :audit, capture: true
|
||||
|
||||
@@ -53,11 +53,11 @@ class ProxyTest < IntegrationTest
|
||||
|
||||
private
|
||||
def assert_proxy_running
|
||||
assert_match /basecamp\/kamal-proxy:#{Kamal::Configuration::Proxy::MINIMUM_VERSION} \"kamal-proxy run\"/, proxy_details
|
||||
assert_match /basecamp\/kamal-proxy:#{Kamal::Configuration::PROXY_MINIMUM_VERSION} \"kamal-proxy run\"/, proxy_details
|
||||
end
|
||||
|
||||
def assert_proxy_not_running
|
||||
assert_no_match /basecamp\/kamal-proxy:#{Kamal::Configuration::Proxy::MINIMUM_VERSION} \"kamal-proxy run\"/, proxy_details
|
||||
assert_no_match /basecamp\/kamal-proxy:#{Kamal::Configuration::PROXY_MINIMUM_VERSION} \"kamal-proxy run\"/, proxy_details
|
||||
end
|
||||
|
||||
def proxy_details
|
||||
|
||||
Reference in New Issue
Block a user