Skip to content

Commit

Permalink
Execute CRT integration tests, black-format tests
Browse files Browse the repository at this point in the history
  • Loading branch information
WillChilds-Klein committed Jun 5, 2024
1 parent 8084133 commit bdb1ab5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
55 changes: 33 additions & 22 deletions tests/ci/integration/python_tests/test_crt.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
import awscrt.auth
import awscrt.http
import datetime

import awscrt
import awscrt.auth
import awscrt.http
import boto3
import botocore
import awscrt

AWS_ACCESS_KEY_ID = 'AKIDEXAMPLE'
AWS_SECRET_ACCESS_KEY = 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY'
AWS_ACCESS_KEY_ID = "AKIDEXAMPLE"
AWS_SECRET_ACCESS_KEY = "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"
AWS_SESSION_TOKEN = None

AWS_REGION = 'us-east-1'
SERVICE = 'service'
AWS_REGION = "us-east-1"
SERVICE = "service"
DATE = datetime.datetime(
year=2015,
month=8,
day=30,
hour=12,
minute=36,
second=0,
tzinfo=datetime.timezone.utc)
tzinfo=datetime.timezone.utc,
)

credentials_provider = awscrt.auth.AwsCredentialsProvider.new_static(
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN)

AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
)


def test_awscrt_sigv4():
signing_config = awscrt.auth.awssigningconfig(
algorithm=awscrt.auth.awssigningalgorithm.v4,
signature_type=awscrt.auth.awssignaturetype.http_request_headers,
signing_config = awscrt.auth.AwsSigningConfig(
algorithm=awscrt.auth.AwsSigningAlgorithm.V4,
signature_type=awscrt.auth.AwsSignatureType.HTTP_REQUEST_HEADERS,
credentials_provider=credentials_provider,
region=aws_region,
service=service,
date=date)
region=AWS_REGION,
service=SERVICE,
date=DATE,
)

http_request = awscrt.http.HttpRequest(
method='GET',
path='/',
headers=awscrt.http.HttpHeaders([('Host', 'example.amazonaws.com')]))
method="GET",
path="/",
headers=awscrt.http.HttpHeaders([("Host", "example.amazonaws.com")]),
)

signing_result = awscrt.auth.aws_sign_request(http_request, signing_config).result()
assert signing_result is not None
Expand All @@ -50,14 +53,22 @@ def test_boto3():
# nonsense, but that's OK because we sign and make a request over the network
# to determine that.
client = boto3.client(
's3',
"s3",
aws_access_key_id=AWS_ACCESS_KEY_ID,
aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
aws_session_token=AWS_SESSION_TOKEN
aws_session_token=AWS_SESSION_TOKEN,
)
try:
client.list_buckets()
assert False, "ListBuckets succeeded when it shouldn't have"
except botocore.exceptions.ClientError as e:
# expect it to fail due to nonsense creds
assert 'InvalidAccessKeyId' in e.response['Error']['Code']
assert "InvalidAccessKeyId" in e.response["Error"]["Code"]


if __name__ == "__main__":
# discover test functions defined in __main__'s scope and execute them.
for test in [test + "()" for test in globals() if test.startswith("test_")]:
print(f"running {test}...")
eval(test)
print("done.")
4 changes: 3 additions & 1 deletion tests/ci/integration/python_tests/test_cryptography.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
assert sys.version_info.major == 3, 'Only python 3 supported'

assert sys.version_info.major == 3, "Only python 3 supported"
if sys.version_info.minor >= 13:
print("Fernet import currently broken on python release candidates >= 3.13")
print("Returning early for now, need to check in on this post-release")
Expand All @@ -17,3 +18,4 @@

version = cryptography.hazmat.backends.openssl.backend.openssl_version_text()
assert "OpenSSL" in version, f"PyCA didn't link OpenSSL: {version}"
assert "AWS-LC" not in version, f"PyOpenSSL linked AWS-LC: {version}"
3 changes: 2 additions & 1 deletion tests/ci/integration/python_tests/test_pyopenssl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
assert sys.version_info.major == 3, 'Only python 3 supported'

assert sys.version_info.major == 3, "Only python 3 supported"
if sys.version_info.minor >= 13:
print("PyOpenSSL import currently broken on mainline python >= 3.13.")
sys.exit()
Expand Down

0 comments on commit bdb1ab5

Please sign in to comment.