mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-03 13:19:58 -05:00
Squashing config rework.
This commit is contained in:
parent
5425142adb
commit
08065155cf
38 changed files with 1046 additions and 633 deletions
|
|
@ -19,8 +19,8 @@ bp = get_blueprint('OTP', '/api/otp')
|
|||
body=schema.EncryptOTPRequest,
|
||||
)
|
||||
@validate(schema.EncryptOTPRequest)
|
||||
async def post_encrypt_otp(_: Request, data: dict):
|
||||
data = lib.encrypt_otp(data['otp'], data['plaintext'])
|
||||
async def post_encrypt_otp(_: Request, body: schema.EncryptOTPRequest):
|
||||
data = lib.encrypt_otp(body.otp, body.plaintext)
|
||||
return response.json(data)
|
||||
|
||||
|
||||
|
|
@ -30,8 +30,8 @@ async def post_encrypt_otp(_: Request, data: dict):
|
|||
body=schema.DecryptOTPRequest,
|
||||
)
|
||||
@validate(schema.DecryptOTPRequest)
|
||||
async def post_decrypt_otp(_: Request, data: dict):
|
||||
data = lib.decrypt_otp(data['otp'], data['ciphertext'])
|
||||
async def post_decrypt_otp(_: Request, body: schema.DecryptOTPRequest):
|
||||
data = lib.decrypt_otp(body.otp, body.ciphertext)
|
||||
return response.json(data)
|
||||
|
||||
|
||||
|
|
|
|||
29
modules/otp/test/test_api.py
Normal file
29
modules/otp/test/test_api.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import json
|
||||
from http import HTTPStatus
|
||||
|
||||
|
||||
def test_encrypt(test_client):
|
||||
body = dict(otp='asdf', plaintext='asdf')
|
||||
request, response = test_client.post('/api/otp/encrypt_otp', content=json.dumps(body))
|
||||
assert response.status_code == HTTPStatus.OK
|
||||
assert response.json == dict(
|
||||
ciphertext='AAGK',
|
||||
otp='ASDF',
|
||||
plaintext='ASDF',
|
||||
)
|
||||
|
||||
|
||||
def test_decrypt(test_client):
|
||||
body = dict(otp='asdf', ciphertext='aagk')
|
||||
request, response = test_client.post('/api/otp/decrypt_otp', content=json.dumps(body))
|
||||
assert response.status_code == HTTPStatus.OK
|
||||
assert response.json == dict(
|
||||
ciphertext='AAGK',
|
||||
otp='ASDF',
|
||||
plaintext='ASDF',
|
||||
)
|
||||
|
||||
|
||||
def test_get_pdf(test_client):
|
||||
request, response = test_client.get('/api/otp/pdf')
|
||||
assert response.status_code == HTTPStatus.OK
|
||||
Loading…
Add table
Add a link
Reference in a new issue