mirror of https://github.com/zulip/zulip.git
webhooks/beanstalk: Improve test coverage.
We shouldn't just ignore exceptions when encoding the incoming auth credentials. Even if the incoming credentials are properly encoded, it is better to know when that is the case or if something else fails.
This commit is contained in:
parent
cbb6692882
commit
185a023745
|
@ -100,7 +100,6 @@ not_yet_fully_covered = {
|
|||
'zerver/data_import/gitter.py',
|
||||
'zerver/data_import/import_util.py',
|
||||
# Webhook integrations with incomplete coverage
|
||||
'zerver/webhooks/beanstalk/view.py',
|
||||
'zerver/webhooks/bitbucket2/view.py',
|
||||
'zerver/webhooks/freshdesk/view.py',
|
||||
'zerver/webhooks/github/view.py',
|
||||
|
|
|
@ -21,7 +21,6 @@ from zerver.webhooks.github_legacy.view import build_message_from_gitlog
|
|||
def beanstalk_decoder(view_func: ViewFuncT) -> ViewFuncT:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
|
||||
try:
|
||||
auth_type, encoded_value = request.META['HTTP_AUTHORIZATION'].split() # type: str, str
|
||||
if auth_type.lower() == "basic":
|
||||
email, api_key = base64.b64decode(encoded_value).decode('utf-8').split(":")
|
||||
|
@ -29,8 +28,6 @@ def beanstalk_decoder(view_func: ViewFuncT) -> ViewFuncT:
|
|||
credentials = u"%s:%s" % (email, api_key)
|
||||
encoded_credentials = base64.b64encode(credentials.encode('utf-8')).decode('utf8') # type: str
|
||||
request.META['HTTP_AUTHORIZATION'] = "Basic " + encoded_credentials
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return view_func(request, *args, **kwargs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue