Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various tests #236

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix OVER_HEROKU test logic
kyluca committed Oct 16, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 997d9a6578856f124fd6f0edf3a084b0a38bee6e
4 changes: 3 additions & 1 deletion pep8speaks/utils.py
Original file line number Diff line number Diff line change
@@ -68,7 +68,9 @@ def update_dict(base, head):

def match_webhook_secret(request):
"""Match the webhook secret sent from GitHub"""
if os.environ.get("OVER_HEROKU", False):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug was due to the fact that the string "False" actually evaluates as True when tested as a boolean, only the empty string "" gives a False value.

Fixed by accounting for all varieties of a "True" env var.

heroku_flag = os.environ.get("OVER_HEROKU", False)

if heroku_flag in (True, "True", "TRUE"):
if ('X-Hub-Signature' in request.headers and
request.headers.get('X-Hub-Signature') is not None):
header_signature = request.headers.get('X-Hub-Signature', None)
2 changes: 1 addition & 1 deletion tests/local/pep8speaks/test_utils.py
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ def test_match_webhook_secret(self, monkeypatch):

assert match_webhook_secret(mock_request) is True

monkeypatch.setenv('OVER_HEROKU', False)
monkeypatch.setenv('OVER_HEROKU', True)

mock_request.headers = {'Header1': True}
with pytest.raises(werkzeug.exceptions.Forbidden):