Skip to content

Commit 3d2c180

Browse files
committed
verify claims in try, update test
1 parent 30a7fcd commit 3d2c180

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/sentry/integrations/jira/webhooks/installed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ def post(self, request: Request, *args, **kwargs) -> Response:
6363
)
6464
try:
6565
decoded_claims = authenticate_asymmetric_jwt(token, key_id)
66+
verify_claims(decoded_claims, request.path, request.GET, method="POST")
6667
except InvalidKeyError:
6768
lifecycle.record_halt(halt_reason="JWT contained invalid key_id (kid)")
6869
return self.respond(
6970
{"detail": "Invalid key id"}, status=status.HTTP_400_BAD_REQUEST
7071
)
7172

72-
verify_claims(decoded_claims, request.path, request.GET, method="POST")
7373
data = JiraIntegrationProvider().build_integration(state)
7474
integration = ensure_integration(self.provider, data)
7575

tests/sentry/integrations/jira/test_installed.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,15 @@ def test_without_key_id(self, mock_record_event: MagicMock) -> None:
144144
)
145145

146146
@patch("sentry.integrations.utils.metrics.EventLifecycle.record_event")
147+
@responses.activate
147148
def test_with_invalid_key_id(self, mock_record_event: MagicMock) -> None:
149+
responses.add(
150+
responses.GET,
151+
"https://connect-install-keys.atlassian.com/fake-kid",
152+
body=b"Not Found",
153+
status=404,
154+
)
155+
148156
self.get_error_response(
149157
**self.body(),
150158
extra_headers=dict(

0 commit comments

Comments
 (0)