From 34426038d99d558b25ee6edd52d31c09f6ab5b15 Mon Sep 17 00:00:00 2001 From: shockrah Date: Tue, 27 Apr 2021 13:27:39 -0700 Subject: [PATCH] * Fixing busted invite test in api client tester + Adding some more invite status checks + Adding a verbose invite usage check for sanity reasons - Removing run-api-tests script as it now goes into the /scripts/ directory + Adding the wss-hmac setup from the command line arg It was literally just 1 if statement that I forgot to write in --- json-api/client-tests/main.py | 5 ++++- json-api/client-tests/request.py | 3 ++- json-api/run-api-tests.sh | 24 ------------------------ json-api/run-client.sh | 3 +++ json-api/src/main.rs | 3 +++ 5 files changed, 12 insertions(+), 26 deletions(-) delete mode 100644 json-api/run-api-tests.sh create mode 100644 json-api/run-client.sh diff --git a/json-api/client-tests/main.py b/json-api/client-tests/main.py index fd3215d..63f7a8d 100644 --- a/json-api/client-tests/main.py +++ b/json-api/client-tests/main.py @@ -59,7 +59,6 @@ def req(admin: Admin, method: str, path: str, qs: dict, hope: int, headers: dict def make_and_receive_invite(admin: Admin) -> (Request, Request): make_inv_req = req(admin, 'post', '/invite/create', {}, 200, verbose=True) - user_inv_req = req(admin , 'get' , '/invite/join', new_invite_body, 200, verbose=True) # Fire the first request and do some safety checks in case the request fails make_inv_req.fire() @@ -67,7 +66,10 @@ def make_and_receive_invite(admin: Admin) -> (Request, Request): return (make_inv_req, user_inv_req) # Setup to fire the second request, .fire() is safe to blindly use at this point + print('Response text from /join ', make_inv_req.response.text) new_invite_body = make_inv_req.response.json()['invite'] + code = new_invite_body['id'] + user_inv_req = req(admin , 'get' , '/join', {'code': code}, 200, verbose=True) user_inv_req.fire() return (make_inv_req, user_inv_req) @@ -112,6 +114,7 @@ if __name__ == '__main__': req(admin, 'get', '/members/me', {}, 200), req(admin, 'get', '/members/get_online', {}, 200), req(admin, 'post', '/members/me/nickname', {'nick': f'randy-{time()}'}, 200), + req(admin , 'get', '/invite/join', {'code': 123}, 404) ]) # add this after fire the generic tests diff --git a/json-api/client-tests/request.py b/json-api/client-tests/request.py index 2c68ef8..45b3152 100644 --- a/json-api/client-tests/request.py +++ b/json-api/client-tests/request.py @@ -38,7 +38,8 @@ class Request: self.response = requests.delete(self.url, headers=self.headers, params=self.qs) return self.response - except: + except Exception as e: + print(e) return None diff --git a/json-api/run-api-tests.sh b/json-api/run-api-tests.sh deleted file mode 100644 index a9c41d7..0000000 --- a/json-api/run-api-tests.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# First the rtc server -pushd ../rtc-server/ - node main.js& - rtc_pid=$! -popd - -# Next the json api -cargo run --release -- -s& -json_pid=$! -sleep 2 - -# Next come back and startup the rest test client -source ./client-tests/bin/activate -python3 client-tests/main.py - -# catch errors that may occur and kill off process group -trap "kill $json_pid $rtc_pid" exit INT TERM - -# Normal exit (for the most part) -kill -9 $json_pid $rtc_pid - -echo Done diff --git a/json-api/run-client.sh b/json-api/run-client.sh new file mode 100644 index 0000000..0c1d626 --- /dev/null +++ b/json-api/run-client.sh @@ -0,0 +1,3 @@ +#!/bin/bash +source ./client-tests/bin/activate +python3 client-tests/main.py diff --git a/json-api/src/main.rs b/json-api/src/main.rs index 296fe42..cd5b611 100644 --- a/json-api/src/main.rs +++ b/json-api/src/main.rs @@ -259,6 +259,9 @@ async fn main() -> Result<(), u16>{ if let Some(hmac) = args.value_of("hmac") { std::env::set_var("HMAC_PATH", hmac); } + if let Some(wss_hmac) = args.value_of("wss-hmac") { + std::env::set_var("WSS_HMAC_PATH", wss_hmac); + } if args.is_present("server") { if main_ret == NO_ERR {