wrolpi/modules/otp/test/test_api.py

35 lines
965 B
Python
Raw Normal View History

2022-02-16 21:57:27 -07:00
import json
from http import HTTPStatus
import pytest
2022-02-16 21:57:27 -07:00
@pytest.mark.asyncio
async def test_encrypt(async_client):
2022-02-16 21:57:27 -07:00
body = dict(otp='asdf', plaintext='asdf')
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',
)
@pytest.mark.asyncio
async def test_decrypt(async_client):
2022-02-16 21:57:27 -07:00
body = dict(otp='asdf', ciphertext='aagk')
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',
)
@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