parameter secret_token (#1173)

* Added secret token validation
This commit is contained in:
sheldy 2023-06-25 00:40:04 +03:00 committed by GitHub
parent 5b20f81654
commit a890622e40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 1 deletions

View file

@ -189,8 +189,24 @@ class TestSimpleRequestHandler:
result = await resp.json()
assert not result
async def test_verify_secret(self, bot: MockedBot, aiohttp_client):
app = Application()
dp = Dispatcher()
handler = SimpleRequestHandler(
dispatcher=dp, bot=bot, handle_in_background=False, secret_token="vasya228"
)
handler.register(app, path="/webhook")
client: TestClient = await aiohttp_client(app)
resp = await self.make_reqest(client=client)
assert resp.status == 401
class TestTokenBasedRequestHandler:
async def test_verify_secret(self, bot: MockedBot):
dispatcher = Dispatcher()
handler = TokenBasedRequestHandler(dispatcher=dispatcher)
assert handler.verify_secret("petro328", bot)
async def test_register(self):
dispatcher = Dispatcher()
app = Application()