18
18
# Set the log level to include all messages.
19
19
logger .setLevel (logging .DEBUG )
20
20
21
- @pytest .fixture (scope = 'session' )
21
+
22
+ @pytest .fixture (scope = "session" )
22
23
def start_gunicorn ():
23
24
# Start Gunicorn server in a separate thread
24
- server = simple_server .make_server (' 0.0.0.0' , 8000 , service .app )
25
+ server = simple_server .make_server (" 0.0.0.0" , 8000 , service .app )
25
26
server_thread = threading .Thread (target = server .serve_forever )
26
27
server_thread .start ()
27
28
# Give it some time to start up
@@ -30,16 +31,19 @@ def start_gunicorn():
30
31
# Stop Gunicorn server after tests have finished
31
32
server .shutdown ()
32
33
server_thread .join ()
33
-
34
- @pytest .mark .manual
34
+
35
+
36
+ @pytest .mark .manual
35
37
def test_service_integration (start_gunicorn ):
36
38
logger .info ("Running test_local so that you can debug the server" )
37
39
while True :
38
40
time .sleep (1 )
39
41
40
- #currently needs a pre-loaded vlei-verifier populated per signify-ts vlei-verifier test
42
+
43
+ # TODO use this test as a basis for an integration test (rather than simulated unit test)
44
+ # currently needs a pre-loaded vlei-verifier populated per signify-ts vlei-verifier test
41
45
@pytest .mark .manual
42
- def test_ends ( ):
46
+ def test_ends_integration ( start_gunicorn ):
43
47
# AID and SAID should be the same as what is in credential.cesr for the ECR credential
44
48
# see https://trustoverip.github.io/tswg-acdc-specification/#top-level-fields to understand the fields/values
45
49
AID = "EP4kdoVrDh4Mpzh2QbocUYIv4IjLZLDU367UO0b40f6x"
@@ -63,22 +67,26 @@ def test_ends():
63
67
64
68
app = service .falcon_app ()
65
69
client = falcon .testing .TestClient (app )
66
-
70
+
67
71
result = client .simulate_get (f"/ping" , headers = headers )
68
72
assert result .status == falcon .HTTP_200
69
73
assert result .text == "Pong"
70
-
74
+
71
75
# result = client.simulate_get(f"/checklogin/{AID}", headers=headers)
72
76
# assert result.status == falcon.HTTP_200
73
-
74
- with open (f"./data/credential.cesr" , 'r' ) as cfile :
77
+
78
+ with open (f"./data/credential.cesr" , "r" ) as cfile :
75
79
vlei_ecr = cfile .read ()
76
- headers ['Content-Type' ] = 'application/json+cesr'
77
- result = client .simulate_post (f"/login" , json = {"said" : SAID , "vlei" : vlei_ecr }, headers = headers )
80
+ headers ["Content-Type" ] = "application/json+cesr"
81
+ result = client .simulate_post (
82
+ f"/login" , json = {"said" : SAID , "vlei" : vlei_ecr }, headers = headers
83
+ )
78
84
assert result .status == falcon .HTTP_202
79
-
85
+
80
86
result = client .simulate_get (f"/checklogin/{ AID } " , headers = headers )
81
87
assert result .status == falcon .HTTP_200
82
-
88
+
83
89
result = client .simulate_get (f"/status/{ AID } " , headers = headers )
84
- assert result .status == falcon .HTTP_401 # fail because this signature should not verify
90
+ assert (
91
+ result .status == falcon .HTTP_401
92
+ ) # fail because this signature should not verify
0 commit comments