Remove unnecessary field expected_exception at the tests for integrations.gitea.middlewares.signature.GiteaSignatureMiddleware

This commit is contained in:
2026-05-03 18:14:50 +02:00
parent 58700f2390
commit 157d054854
@@ -55,49 +55,41 @@ def make_signature(body: bytes, secret: bytes) -> str:
return f'sha256={signature}'
@pytest.mark.asyncio
@pytest.mark.parametrize('body,secret,expected_exception', [
@pytest.mark.parametrize('body,secret', [
(
b'{"event":"push"}',
b'\xa1\xd6h\x0c\xe6\xc0\x99\x82yd\x14\xfew\xcc\x8e\xb0\xf9\x8f\xe6yM\xe5\xdd4\xdc\xb5M+\xef\xc8O\x94',
None
b'\xa1\xd6h\x0c\xe6\xc0\x99\x82yd\x14\xfew\xcc\x8e\xb0\xf9\x8f\xe6yM\xe5\xdd4\xdc\xb5M+\xef\xc8O\x94'
),
(
b'{"event":"push"}',
b'',
None
b''
),
(
b'',
b'\xa1\xd6h\x0c\xe6\xc0\x99\x82yd\x14\xfew\xcc\x8e\xb0\xf9\x8f\xe6yM\xe5\xdd4\xdc\xb5M+\xef\xc8O\x94',
None
b'\xa1\xd6h\x0c\xe6\xc0\x99\x82yd\x14\xfew\xcc\x8e\xb0\xf9\x8f\xe6yM\xe5\xdd4\xdc\xb5M+\xef\xc8O\x94'
),
(
b'',
b'',
None
b''
),
(
b'',
b'\x42',
None
b'\x42'
),
(
b'',
b'\x42',
None
b'\x42'
),
(
b'',
b'\x04\x02',
None
b'\x04\x02'
),
(
b'',
b'\x04\x02',
None
b'\x04\x02'
),
])
async def test_GiteaSignatureMiddleware_valid_signature(body, secret, expected_exception):
async def test_GiteaSignatureMiddleware_valid_signature(body, secret):
middleware = GiteaSignatureMiddleware(app = None, secret = secret)
headers = {
@@ -109,10 +101,5 @@ async def test_GiteaSignatureMiddleware_valid_signature(body, secret, expected_e
headers
)
if expected_exception is not None:
with pytest.raises(HTTPException):
await middleware.dispatch(req, call_next)
else:
res = await middleware.dispatch(req, call_next)
assert hasattr(res, 'called')
pass