Skip to content

Commit

Permalink
add http2 test case with httpx
Browse files Browse the repository at this point in the history
  • Loading branch information
thrau committed Mar 12, 2024
1 parent 2cba966 commit ed1ec1c
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 13 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Expand Up @@ -97,6 +97,7 @@ test = [
"localstack-core[runtime]",
"coverage[toml]>=5.5",
"deepdiff>=6.4.1",
"httpx[http2]>=0.25",
"pluggy>=1.3.0",
"pytest>=7.4.2",
"pytest-split>=0.8.0",
Expand Down
20 changes: 18 additions & 2 deletions requirements-dev.txt
Expand Up @@ -14,6 +14,8 @@ annotated-types==0.6.0
# via pydantic
antlr4-python3-runtime==4.13.1
# via localstack-core
anyio==4.3.0
# via httpx
apispec==6.5.0
# via localstack-core
argparse==1.4.0
Expand Down Expand Up @@ -82,6 +84,8 @@ cbor2==5.6.2
# via localstack-core
certifi==2024.2.2
# via
# httpcore
# httpx
# opensearch-py
# requests
cffi==1.16.0
Expand Down Expand Up @@ -161,14 +165,20 @@ graphql-core==3.2.3
# via moto-ext
h11==0.14.0
# via
# httpcore
# hypercorn
# wsproto
h2==4.1.0
# via
# httpx
# hypercorn
# localstack-twisted
hpack==4.0.0
# via h2
httpcore==1.0.4
# via httpx
httpx[http2]==0.27.0
# via localstack-core
hypercorn==0.16.0
# via
# localstack-core
Expand All @@ -181,10 +191,12 @@ identify==2.5.35
# via pre-commit
idna==3.6
# via
# anyio
# httpx
# hyperlink
# localstack-twisted
# requests
importlib-resources==6.1.3
importlib-resources==6.3.0
# via jsii
incremental==22.10.0
# via localstack-twisted
Expand Down Expand Up @@ -345,7 +357,7 @@ pyasn1==0.5.1
# via rsa
pycparser==2.21
# via cffi
pydantic==2.6.3
pydantic==2.6.4
# via aws-sam-translator
pydantic-core==2.16.3
# via pydantic
Expand Down Expand Up @@ -462,6 +474,10 @@ six==1.16.0
# python-dateutil
# requests-aws4auth
# rfc3339-validator
sniffio==1.3.1
# via
# anyio
# httpx
stevedore==5.2.0
# via
# localstack-core
Expand Down
2 changes: 1 addition & 1 deletion requirements-runtime.txt
Expand Up @@ -254,7 +254,7 @@ pyasn1==0.5.1
# via rsa
pycparser==2.21
# via cffi
pydantic==2.6.3
pydantic==2.6.4
# via aws-sam-translator
pydantic-core==2.16.3
# via pydantic
Expand Down
20 changes: 18 additions & 2 deletions requirements-test.txt
Expand Up @@ -14,6 +14,8 @@ annotated-types==0.6.0
# via pydantic
antlr4-python3-runtime==4.13.1
# via localstack-core
anyio==4.3.0
# via httpx
apispec==6.5.0
# via localstack-core
argparse==1.4.0
Expand Down Expand Up @@ -80,6 +82,8 @@ cbor2==5.6.2
# via localstack-core
certifi==2024.2.2
# via
# httpcore
# httpx
# opensearch-py
# requests
cffi==1.16.0
Expand Down Expand Up @@ -144,14 +148,20 @@ graphql-core==3.2.3
# via moto-ext
h11==0.14.0
# via
# httpcore
# hypercorn
# wsproto
h2==4.1.0
# via
# httpx
# hypercorn
# localstack-twisted
hpack==4.0.0
# via h2
httpcore==1.0.4
# via httpx
httpx[http2]==0.27.0
# via localstack-core (pyproject.toml)
hypercorn==0.16.0
# via
# localstack-core
Expand All @@ -162,10 +172,12 @@ hyperlink==21.0.0
# via localstack-twisted
idna==3.6
# via
# anyio
# httpx
# hyperlink
# localstack-twisted
# requests
importlib-resources==6.1.3
importlib-resources==6.3.0
# via jsii
incremental==22.10.0
# via localstack-twisted
Expand Down Expand Up @@ -306,7 +318,7 @@ pyasn1==0.5.1
# via rsa
pycparser==2.21
# via cffi
pydantic==2.6.3
pydantic==2.6.4
# via aws-sam-translator
pydantic-core==2.16.3
# via pydantic
Expand Down Expand Up @@ -415,6 +427,10 @@ six==1.16.0
# python-dateutil
# requests-aws4auth
# rfc3339-validator
sniffio==1.3.1
# via
# anyio
# httpx
stevedore==5.2.0
# via
# localstack-core
Expand Down
32 changes: 24 additions & 8 deletions requirements-typehint.txt
Expand Up @@ -14,6 +14,8 @@ annotated-types==0.6.0
# via pydantic
antlr4-python3-runtime==4.13.1
# via localstack-core
anyio==4.3.0
# via httpx
apispec==6.5.0
# via localstack-core
argparse==1.4.0
Expand Down Expand Up @@ -58,7 +60,7 @@ boto3==1.34.59
# aws-sam-translator
# localstack-core
# moto-ext
boto3-stubs[acm,acm-pca,amplify,apigateway,apigatewayv2,appconfig,appconfigdata,application-autoscaling,appsync,athena,autoscaling,backup,batch,ce,cloudcontrol,cloudformation,cloudfront,cloudtrail,cloudwatch,codecommit,cognito-identity,cognito-idp,dms,docdb,dynamodb,dynamodbstreams,ec2,ecr,ecs,efs,eks,elasticache,elasticbeanstalk,elbv2,emr,emr-serverless,es,events,firehose,fis,glacier,glue,iam,identitystore,iot,iot-data,iotanalytics,iotwireless,kafka,kinesis,kinesisanalytics,kinesisanalyticsv2,kms,lakeformation,lambda,logs,managedblockchain,mediaconvert,mediastore,mq,mwaa,neptune,opensearch,organizations,pi,pipes,qldb,qldb-session,rds,rds-data,redshift,redshift-data,resource-groups,resourcegroupstaggingapi,route53,route53resolver,s3,s3control,sagemaker,sagemaker-runtime,secretsmanager,serverlessrepo,servicediscovery,ses,sesv2,sns,sqs,ssm,sso-admin,stepfunctions,sts,timestream-query,timestream-write,transcribe,wafv2,xray]==1.34.60
boto3-stubs[acm,acm-pca,amplify,apigateway,apigatewayv2,appconfig,appconfigdata,application-autoscaling,appsync,athena,autoscaling,backup,batch,ce,cloudcontrol,cloudformation,cloudfront,cloudtrail,cloudwatch,codecommit,cognito-identity,cognito-idp,dms,docdb,dynamodb,dynamodbstreams,ec2,ecr,ecs,efs,eks,elasticache,elasticbeanstalk,elbv2,emr,emr-serverless,es,events,firehose,fis,glacier,glue,iam,identitystore,iot,iot-data,iotanalytics,iotwireless,kafka,kinesis,kinesisanalytics,kinesisanalyticsv2,kms,lakeformation,lambda,logs,managedblockchain,mediaconvert,mediastore,mq,mwaa,neptune,opensearch,organizations,pi,pipes,qldb,qldb-session,rds,rds-data,redshift,redshift-data,resource-groups,resourcegroupstaggingapi,route53,route53resolver,s3,s3control,sagemaker,sagemaker-runtime,secretsmanager,serverlessrepo,servicediscovery,ses,sesv2,sns,sqs,ssm,sso-admin,stepfunctions,sts,timestream-query,timestream-write,transcribe,wafv2,xray]==1.34.61
# via localstack-core (pyproject.toml)
botocore==1.34.59
# via
Expand All @@ -69,7 +71,7 @@ botocore==1.34.59
# localstack-snapshot
# moto-ext
# s3transfer
botocore-stubs==1.34.60
botocore-stubs==1.34.61
# via boto3-stubs
build==1.1.1
# via
Expand All @@ -86,6 +88,8 @@ cbor2==5.6.2
# via localstack-core
certifi==2024.2.2
# via
# httpcore
# httpx
# opensearch-py
# requests
cffi==1.16.0
Expand Down Expand Up @@ -165,14 +169,20 @@ graphql-core==3.2.3
# via moto-ext
h11==0.14.0
# via
# httpcore
# hypercorn
# wsproto
h2==4.1.0
# via
# httpx
# hypercorn
# localstack-twisted
hpack==4.0.0
# via h2
httpcore==1.0.4
# via httpx
httpx[http2]==0.27.0
# via localstack-core
hypercorn==0.16.0
# via
# localstack-core
Expand All @@ -185,10 +195,12 @@ identify==2.5.35
# via pre-commit
idna==3.6
# via
# anyio
# httpx
# hyperlink
# localstack-twisted
# requests
importlib-resources==6.1.3
importlib-resources==6.3.0
# via jsii
incremental==22.10.0
# via localstack-twisted
Expand Down Expand Up @@ -301,7 +313,7 @@ mypy-boto3-ce==1.34.52
# via boto3-stubs
mypy-boto3-cloudcontrol==1.34.0
# via boto3-stubs
mypy-boto3-cloudformation==1.34.55
mypy-boto3-cloudformation==1.34.61
# via boto3-stubs
mypy-boto3-cloudfront==1.34.0
# via boto3-stubs
Expand All @@ -323,7 +335,7 @@ mypy-boto3-dynamodb==1.34.57
# via boto3-stubs
mypy-boto3-dynamodbstreams==1.34.0
# via boto3-stubs
mypy-boto3-ec2==1.34.58
mypy-boto3-ec2==1.34.61
# via boto3-stubs
mypy-boto3-ecr==1.34.0
# via boto3-stubs
Expand Down Expand Up @@ -367,7 +379,7 @@ mypy-boto3-iotanalytics==1.34.0
# via boto3-stubs
mypy-boto3-iotwireless==1.34.0
# via boto3-stubs
mypy-boto3-kafka==1.34.0
mypy-boto3-kafka==1.34.61
# via boto3-stubs
mypy-boto3-kinesis==1.34.0
# via boto3-stubs
Expand Down Expand Up @@ -445,7 +457,7 @@ mypy-boto3-sns==1.34.44
# via boto3-stubs
mypy-boto3-sqs==1.34.0
# via boto3-stubs
mypy-boto3-ssm==1.34.47
mypy-boto3-ssm==1.34.61
# via boto3-stubs
mypy-boto3-sso-admin==1.34.0
# via boto3-stubs
Expand Down Expand Up @@ -541,7 +553,7 @@ pyasn1==0.5.1
# via rsa
pycparser==2.21
# via cffi
pydantic==2.6.3
pydantic==2.6.4
# via aws-sam-translator
pydantic-core==2.16.3
# via pydantic
Expand Down Expand Up @@ -658,6 +670,10 @@ six==1.16.0
# python-dateutil
# requests-aws4auth
# rfc3339-validator
sniffio==1.3.1
# via
# anyio
# httpx
stevedore==5.2.0
# via
# localstack-core
Expand Down
23 changes: 23 additions & 0 deletions tests/integration/aws/test_app.py
@@ -1,6 +1,7 @@
import json
import threading

import httpx
import pytest
import requests
import websocket
Expand Down Expand Up @@ -257,3 +258,25 @@ def _echo_websocket_handler(request: WebSocketRequest, param: str):
socket.connect(url)
assert socket.connected
assert socket.recv() == "hello world"


class TestHTTP2Support:
@pytest.fixture(autouse=True)
def _fix_proxy(self, monkeypatch):
# on linux it also includes [::1], somehow leading to weird URL parsing issues in httpx
monkeypatch.setenv("no_proxy", "localhost.localstack.cloud,localhost,127.0.0.1")

def test_http2_http(self):
host = config.internal_service_url(host="localhost.localstack.cloud", protocol="http")
with httpx.Client(http1=False, http2=True) as client:
assert client.get(f"{host}/_localstack/health").status_code == 200

def test_http2_https(self):
host = config.internal_service_url(host="localhost.localstack.cloud", protocol="https")
with httpx.Client(http1=False, http2=True) as client:
assert client.get(f"{host}/_localstack/health").status_code == 200

def test_http2_https_localhost(self):
host = config.internal_service_url(host="localhost", protocol="https")
with httpx.Client(http1=False, http2=True, verify=False) as client:
assert client.get(f"{host}/_localstack/health").status_code == 200

0 comments on commit ed1ec1c

Please sign in to comment.