Skip to content

Commit

Permalink
Fix flake8 styling
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Kurait <[email protected]>
  • Loading branch information
AndreKurait committed Oct 16, 2024
1 parent c0fedf3 commit 6eb32a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,3 @@ def execute_benchmark_workload(self, workload: str,
display_command = command.replace(f"basic_auth_password:{password_to_censor}", "basic_auth_password:********")
logger.info(f"Executing command: {display_command}")
subprocess.run(command, shell=True)

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def __init__(self, message, status_code=None):

def raise_for_aws_api_error(response: Dict) -> None:
if (
"ResponseMetadata" in response
and "HTTPStatusCode" in response["ResponseMetadata"] # noqa: W503
"ResponseMetadata" in response and
"HTTPStatusCode" in response["ResponseMetadata"] # noqa: W503
):
status_code = response["ResponseMetadata"]["HTTPStatusCode"]
else:
Expand Down Expand Up @@ -62,6 +62,8 @@ def append_user_agent_header_for_requests(headers: Optional[dict], user_agent_ex
# The SigV4AuthPlugin allows us to use boto3 with the requests library by integrating
# AWS Signature Version 4 signing. This enables the requests library to authenticate
# requests to AWS services using SigV4.


class SigV4AuthPlugin(requests.auth.AuthBase):
def __init__(self, service, region):
self.service = service
Expand All @@ -75,4 +77,4 @@ def __call__(self, r: PreparedRequest) -> PreparedRequest:
if aws_request.body is not None:
aws_request.headers['x-amz-content-sha256'] = signer.payload(aws_request)
signer.add_auth(aws_request)
return aws_request
return aws_request
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ def test_run_benchmark_executes_correctly_basic_auth_and_https(mocker):
f"basic_auth_user:{auth_details['username']},"
f"basic_auth_password:{auth_details['password']}", shell=True)


@pytest.mark.parametrize("method, endpoint, data, has_body", [
(HttpMethod.GET, "/_cluster/health", None, False),
(HttpMethod.POST, "/_search", {"query": {"match_all": {}}}, True)
Expand Down Expand Up @@ -445,7 +446,8 @@ def test_sigv4_authentication_signature(requests_mock, method, endpoint, data, h
if has_body:
# Verify that the 'x-amz-content-sha256' header is present
content_sha256 = last_request.headers.get('x-amz-content-sha256')
assert content_sha256 is not None, f"x-amz-content-sha256 header is missing. Headers: {last_request.headers}"
assert content_sha256 is not None, f"x-amz-content-sha256 header is missing. Headers: {
last_request.headers}"
# Compute the SHA256 hash of the body
body_hash = hashlib.sha256(last_request.body.encode('utf-8')).hexdigest()
assert content_sha256 == body_hash, "x-amz-content-sha256 does not match body hash"
Expand Down Expand Up @@ -475,4 +477,4 @@ def test_sigv4_authentication_signature(requests_mock, method, endpoint, data, h
assert new_signature_match is not None, "New signature not found in Authorization header"
new_signature = new_signature_match.group(1)

assert original_signature == new_signature, "Signatures do not match"
assert original_signature == new_signature, "Signatures do not match"

0 comments on commit 6eb32a8

Please sign in to comment.