generated from jCloud/repository-template
Remove unnecessary field expected_exception at the tests for integrations.gitea.middlewares.signature.GiteaSignatureMiddleware
This commit is contained in:
+10
-23
@@ -55,49 +55,41 @@ def make_signature(body: bytes, secret: bytes) -> str:
|
|||||||
return f'sha256={signature}'
|
return f'sha256={signature}'
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.parametrize('body,secret,expected_exception', [
|
@pytest.mark.parametrize('body,secret', [
|
||||||
(
|
(
|
||||||
b'{"event":"push"}',
|
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',
|
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'{"event":"push"}',
|
b'{"event":"push"}',
|
||||||
b'',
|
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',
|
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'',
|
b'',
|
||||||
b'',
|
b''
|
||||||
None
|
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
b'',
|
b'',
|
||||||
b'\x42',
|
b'\x42'
|
||||||
None
|
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
b'',
|
b'',
|
||||||
b'\x42',
|
b'\x42'
|
||||||
None
|
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
b'',
|
b'',
|
||||||
b'\x04\x02',
|
b'\x04\x02'
|
||||||
None
|
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
b'',
|
b'',
|
||||||
b'\x04\x02',
|
b'\x04\x02'
|
||||||
None
|
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
async def test_GiteaSignatureMiddleware_valid_signature(body, secret, expected_exception):
|
async def test_GiteaSignatureMiddleware_valid_signature(body, secret):
|
||||||
middleware = GiteaSignatureMiddleware(app = None, secret = secret)
|
middleware = GiteaSignatureMiddleware(app = None, secret = secret)
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
@@ -109,10 +101,5 @@ async def test_GiteaSignatureMiddleware_valid_signature(body, secret, expected_e
|
|||||||
headers
|
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)
|
res = await middleware.dispatch(req, call_next)
|
||||||
assert hasattr(res, 'called')
|
assert hasattr(res, 'called')
|
||||||
pass
|
|
||||||
Reference in New Issue
Block a user