From 6b7c70e59af7c02b329a62c07b94d1bae9e7cea1 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Fri, 23 Dec 2022 13:42:02 +0100 Subject: [PATCH] tests improved --- test/main.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/main.py b/test/main.py index aeb52e3..0711de5 100644 --- a/test/main.py +++ b/test/main.py @@ -1,3 +1,6 @@ +from uuid import uuid4 + +from jose import jwt from starlette.testclient import TestClient import importlib.util import sys @@ -11,6 +14,8 @@ spec.loader.exec_module(main) client = TestClient(main.app) +ORIGIN_REF = str(uuid4()) + def test_index(): response = client.get('/') @@ -41,14 +46,25 @@ def test_auth_v1_origin(): "host_driver_version": "host_driver_version" }, "update_pending": False, - "candidate_origin_ref": "00112233-4455-6677-8899-aabbccddeeff" + "candidate_origin_ref": ORIGIN_REF, } + response = client.post('/auth/v1/origin', json=payload) assert response.status_code == 200 + assert response.json()['origin_ref'] == ORIGIN_REF def test_auth_v1_code(): - pass + payload = { + "code_challenge": "0wmaiAMAlTIDyz4Fgt2/j0tXnGv72TYbbLs4ISRCZlY", + "origin_ref": ORIGIN_REF, + } + + response = client.post('/auth/v1/code', json=payload) + assert response.status_code == 200 + + payload = jwt.get_unverified_claims(token=response.json()['auth_code']) + assert payload['origin_ref'] == ORIGIN_REF def test_auth_v1_token():