Skip to content

Commit

Permalink
Merge pull request #805 from asfadmin/rew/standardize-qoutes
Browse files Browse the repository at this point in the history
Standardize quotes and log calls
  • Loading branch information
reweeden authored Mar 21, 2024
2 parents 81c27a1 + 20d7815 commit d468b9b
Show file tree
Hide file tree
Showing 9 changed files with 393 additions and 276 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: TrueBrain/actions-flake8@v2
with:
flake8_version: 6.0.0
plugins: flake8-isort~=6.0
plugins: flake8-isort==6.1.1 flake8-quotes==3.4.0

requirements:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ skip_gitignore = true

[flake8]
max-line-length = 120
inline-quotes = double
2 changes: 1 addition & 1 deletion tea-cli/tea_cli/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def deploy(self, session: boto3.Session):
client.create_bucket(
Bucket=self.name,
CreateBucketConfiguration={
'LocationConstraint': session.region_name
"LocationConstraint": session.region_name
}
)

Expand Down
6 changes: 3 additions & 3 deletions tests_e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def _boto3_api_host(stack_name):
client = boto3.client("apigateway")
rest_apis = client.get_rest_apis()

for api in rest_apis['items']:
if api['name'] == f"{stack_name}-EgressGateway":
for api in rest_apis["items"]:
if api["name"] == f"{stack_name}-EgressGateway":
return f"{api['id']}.execute-api.{client.meta.region_name}.amazonaws.com"

raise Exception(f"Could not find API for the given stackname {stack_name}")
Expand Down Expand Up @@ -294,4 +294,4 @@ def pytest_sessionfinish(session, exitstatus):
}

# Dump results to S3.
boto3.resource('s3').Object(s3_bucket, s3_object).put(Body=testresults, **put_args)
boto3.resource("s3").Object(s3_bucket, s3_object).put(Body=testresults, **put_args)
4 changes: 2 additions & 2 deletions tests_e2e/test_jwt_blacklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def test_validate_invalid_jwt(urls, auth_cookies, endpoint_patcher):
r = requests.get(url, cookies=auth_cookies, allow_redirects=False)

assert r.is_redirect is True
assert r.headers['Location'] is not None
assert 'oauth/authorize' in r.headers['Location']
assert r.headers["Location"] is not None
assert "oauth/authorize" in r.headers["Location"]


def test_validate_valid_jwt(urls, auth_cookies, endpoint_patcher):
Expand Down
20 changes: 10 additions & 10 deletions tests_e2e/test_protected.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def test_urs_auth_redirect_for_auth_downloads(urls, auth_cookies, urs_username):

assert r.status_code == 303
assert r.is_redirect is True
assert r.headers['Location'] is not None
assert r.headers["Location"] is not None
query_params = urllib.parse.parse_qs(
urllib.parse.urlparse(r.headers['Location']).query
urllib.parse.urlparse(r.headers["Location"]).query
)
assert query_params['A-userid'] == [urs_username]
assert 'oauth/authorize' not in r.headers['Location']
assert query_params["A-userid"] == [urs_username]
assert "oauth/authorize" not in r.headers["Location"]


def test_origin_request_header(urls, auth_cookies):
Expand All @@ -32,7 +32,7 @@ def test_origin_request_header(urls, auth_cookies):
r = requests.get(url, cookies=auth_cookies, headers=headers, allow_redirects=False)

headers = dict(r.headers)
assert headers.get('x-origin-request-id') == origin_request_value
assert headers.get("x-origin-request-id") == origin_request_value


@pytest.mark.parametrize("method", ("get", "head"))
Expand Down Expand Up @@ -80,7 +80,7 @@ def test_validate_custom_headers(urls, auth_cookies):
r = requests.get(url, cookies=auth_cookies, allow_redirects=False)

headers = dict(r.headers)
assert headers.get('x-rainheader1') is not None
assert headers.get("x-rainheader1") is not None


def test_validate_locate_handles_complex_configuration_key(api_url, auth_cookies):
Expand All @@ -94,15 +94,15 @@ def test_validate_locate_handles_complex_configuration_key(api_url, auth_cookies

def find_bearer_token(auth_cookies):
for cookie in auth_cookies:
if cookie.name == 'asf-urs':
if cookie.name == "asf-urs":
# Grab the JWT payload:
cookie_b64 = cookie.value.split(".")[1]
# Fix the padding:
cookie_b64 += '=' * (4 - (len(cookie_b64) % 4))
cookie_b64 += "=" * (4 - (len(cookie_b64) % 4))
# Decode & Load...
cookie_json = json.loads(base64.b64decode(cookie_b64))
if 'urs-access-token' in cookie_json:
return cookie_json['urs-access-token']
if "urs-access-token" in cookie_json:
return cookie_json["urs-access-token"]
return None


Expand Down
Loading

0 comments on commit d468b9b

Please sign in to comment.