2022-02-16 21:57:27 -07:00
|
|
|
import json
|
|
|
|
|
from http import HTTPStatus
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
import pytest
|
2022-02-16 21:57:27 -07:00
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_encrypt(async_client):
|
2022-02-16 21:57:27 -07:00
|
|
|
body = dict(otp='asdf', plaintext='asdf')
|
2025-10-29 22:16:33 -06:00
|
|
|
request, response = await async_client.post('/api/otp/encrypt_otp', content=json.dumps(body))
|
2022-02-16 21:57:27 -07:00
|
|
|
assert response.status_code == HTTPStatus.OK
|
|
|
|
|
assert response.json == dict(
|
|
|
|
|
ciphertext='AAGK',
|
|
|
|
|
otp='ASDF',
|
|
|
|
|
plaintext='ASDF',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_decrypt(async_client):
|
2022-02-16 21:57:27 -07:00
|
|
|
body = dict(otp='asdf', ciphertext='aagk')
|
2025-10-29 22:16:33 -06:00
|
|
|
request, response = await async_client.post('/api/otp/decrypt_otp', content=json.dumps(body))
|
2022-02-16 21:57:27 -07:00
|
|
|
assert response.status_code == HTTPStatus.OK
|
|
|
|
|
assert response.json == dict(
|
|
|
|
|
ciphertext='AAGK',
|
|
|
|
|
otp='ASDF',
|
|
|
|
|
plaintext='ASDF',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_get_html(async_client):
|
|
|
|
|
request, response = await async_client.get('/api/otp/html')
|
2022-02-16 21:57:27 -07:00
|
|
|
assert response.status_code == HTTPStatus.OK
|