Commit e9eeb111 authored by Terence Lee's avatar Terence Lee

actually test https with hitting https

parent ff012e3a
......@@ -118,11 +118,18 @@ RSpec.describe "Simple" do
let(:name) { "https_only" }
it "should redirect http to https" do
response = app.get("/foo")
expect(response.code).to eq("301")
uri = URI(response['Location'])
expect(uri.scheme).to eq("https")
expect(uri.path).to eq("/foo")
app.run do
response = app.get("/foo.html")
expect(response.code).to eq("301")
uri = URI(response['Location'])
expect(uri.scheme).to eq("https")
expect(uri.path).to eq("/foo.html")
response = app.get(uri)
expect(response.code).to eq("200")
expect(response.body.chomp).to eq("foobar")
end
end
end
end
......
......@@ -115,11 +115,18 @@ class AppRunner
def get_retry(path, max_retries)
network_retry(max_retries) do
uri = URI(path)
uri.host = RouterRunner::HOST_IP if uri.host.nil?
uri.port = RouterRunner::HOST_PORT if (uri.host == RouterRunner::HOST_IP && uri.port != RouterRunner::HOST_PORT) || uri.port.nil?
uri.scheme = "http" if uri.scheme.nil?
Net::HTTP.get_response(URI(uri.to_s))
uri.host = RouterRunner::HOST_IP if uri.host.nil?
uri.scheme = "http" if uri.scheme.nil?
Net::HTTP.start(
uri.host,
uri.port,
use_ssl: uri.scheme == "https",
verify_mode: OpenSSL::SSL::VERIFY_NONE
) do |http|
request = Net::HTTP::Get.new(uri.to_s)
http.request(request)
end
end
end
......
......@@ -7,9 +7,9 @@ class RouterRunner < ContainerRunner
rescue Errno::ENOENT
end
CONTAINER_PORT = "80"
HOST_PORT = "80"
HOST_IP = boot2docker_ip || "127.0.0.1"
HTTP_PORT = "80"
HTTPS_PORT = "443"
HOST_IP = boot2docker_ip || "127.0.0.1"
def initialize
super({
......@@ -18,9 +18,13 @@ class RouterRunner < ContainerRunner
"HostConfig" => {
"Links" => ["app:app"],
"PortBindings" => {
"#{CONTAINER_PORT}/tcp" => [{
"#{HTTP_PORT}/tcp" => [{
"HostIp" => HOST_IP,
"HostPort" => HOST_PORT,
"HostPort" => HTTP_PORT
}],
"#{HTTPS_PORT}/tcp" => [{
"HostIp" => HOST_IP,
"HostPort" => HTTPS_PORT
}]
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment