mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-13 00:02:57 -04:00
setting up functional tests for altsvc functionality
This commit is contained in:
parent
43fead1ab0
commit
b616bea46c
@ -19,6 +19,7 @@ services:
|
||||
- BUNDLE_PATH=/usr/local/bundle
|
||||
- BUNDLE_SILENCE_ROOT_WARNING=1
|
||||
- BUNDLE_APP_CONFIG=/usr/local/bundle
|
||||
- HTTPBIN_ALTSVC_HOST=another2
|
||||
image: ruby:alpine
|
||||
depends_on:
|
||||
- httpproxy
|
||||
@ -27,6 +28,8 @@ services:
|
||||
- nghttp2
|
||||
volumes:
|
||||
- ./:/home
|
||||
links:
|
||||
- "altsvc-nghttp2:another2"
|
||||
entrypoint:
|
||||
/home/test/support/ci/build.sh
|
||||
|
||||
@ -64,8 +67,22 @@ services:
|
||||
volumes:
|
||||
- ./test/support/ci:/home
|
||||
command:
|
||||
--conf /home/nghttp.conf --no-ocsp
|
||||
|
||||
--conf /home/nghttp.conf --no-ocsp --frontend 0.0.0.0,80;no-tls --frontend 0.0.0.0,443
|
||||
|
||||
altsvc-nghttp2:
|
||||
image: registry.gitlab.com/honeyryderchuck/httpx/nghttp2:2
|
||||
ports:
|
||||
- 81:80
|
||||
- 444:443
|
||||
depends_on:
|
||||
- httpbin
|
||||
entrypoint:
|
||||
/usr/local/bin/nghttpx
|
||||
volumes:
|
||||
- ./test/support/ci:/home
|
||||
command:
|
||||
--conf /home/nghttp.conf --no-ocsp --frontend 0.0.0.0,80;no-tls --frontend 0.0.0.0,443 --altsvc "h2,443,nghttp2"
|
||||
|
||||
httpbin:
|
||||
environment:
|
||||
- DEBUG=True
|
||||
|
@ -15,6 +15,7 @@ class HTTPTest < Minitest::Test
|
||||
include IO
|
||||
include Timeouts
|
||||
include Errors
|
||||
include AltSvc if ENV.key?("HTTPBIN_ALTSVC_HOST")
|
||||
|
||||
include Plugins::Proxy unless ENV.key?("HTTPX_NO_PROXY")
|
||||
include Plugins::Authentication
|
||||
|
@ -13,6 +13,8 @@ class HTTPSTest < Minitest::Test
|
||||
include IO
|
||||
include Timeouts
|
||||
include Errors
|
||||
# TODO: uncomment as soon as nghttpx supports altsvc for HTTP/2
|
||||
# include AltSvc if ENV.key?("HTTPBIN_ALTSVC_HOST")
|
||||
|
||||
include Plugins::Proxy unless ENV.key?("HTTPX_NO_PROXY")
|
||||
include Plugins::Authentication
|
||||
|
@ -1,5 +1,3 @@
|
||||
frontend=0.0.0.0,80;no-tls
|
||||
frontend=0.0.0.0,443
|
||||
backend=httpbin,8000
|
||||
private-key-file=/home/certs/server.key
|
||||
certificate-file=/home/certs/server.crt
|
||||
|
@ -8,8 +8,8 @@ module HTTPHelpers
|
||||
|
||||
private
|
||||
|
||||
def build_uri(suffix = "/")
|
||||
"#{origin}#{suffix || "/"}"
|
||||
def build_uri(suffix = "/", uri_origin = origin)
|
||||
"#{uri_origin}#{suffix || "/"}"
|
||||
end
|
||||
|
||||
def json_body(response)
|
||||
|
23
test/support/requests/altsvc.rb
Normal file
23
test/support/requests/altsvc.rb
Normal file
@ -0,0 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Requests
|
||||
module AltSvc
|
||||
def test_altsvc_get
|
||||
altsvc_origin = origin(ENV["HTTPBIN_ALTSVC_HOST"])
|
||||
|
||||
HTTPX.wrap do |http|
|
||||
altsvc_uri = build_uri("/get", altsvc_origin)
|
||||
response = http.get(altsvc_uri)
|
||||
verify_status(response, 200)
|
||||
# this is only needed for http/1.1
|
||||
response2 = http.get(altsvc_uri)
|
||||
verify_status(response2, 200)
|
||||
# introspection time
|
||||
pool = http.__send__(:pool)
|
||||
connections = pool.instance_variable_get(:@connections)
|
||||
origins = connections.map { |conn| conn.instance_variable_get(:@origin) }.uniq
|
||||
assert origins.size == 2, "connection didn't follow altsvc (expected a connection for both origins)"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user