From 85522db0b517bdeb77a051b4c4e6503d327331ff Mon Sep 17 00:00:00 2001 From: marysieek Date: Fri, 13 Nov 2020 13:49:09 +0100 Subject: [PATCH] Add process response tests --- castle/test/core/process_response_test.py | 24 ++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/castle/test/core/process_response_test.py b/castle/test/core/process_response_test.py index 679dde3..41375ff 100644 --- a/castle/test/core/process_response_test.py +++ b/castle/test/core/process_response_test.py @@ -21,13 +21,35 @@ def test_response_none(self): def test_response_empty(self): self.assertEqual(CoreProcessResponse(response(body=b'')).call(), {}) - def test_response_authenticate(self): + def test_response_authenticate_allow(self): self.assertEqual( CoreProcessResponse( response(body=b'{"action":"allow","user_id":"12345"}')).call(), {"action": "allow", "user_id": "12345"} ) + def test_response_authenticate_allow_with_props(self): + self.assertEqual( + CoreProcessResponse( + response(body=b'{"action":"allow","user_id":"12345","internal":{}}')).call(), + {"action": "allow", "user_id": "12345", "internal": {}} + ) + + def test_response_authenticate_deny_without_rp(self): + self.assertEqual( + CoreProcessResponse( + response(body=b'{"action":"deny","user_id":"1","device_token":"abc"}')).call(), + {"action": "deny", "user_id": "1", "device_token": "abc"} + ) + + def test_response_authenticate_deny_with_rp(self): + self.assertEqual( + CoreProcessResponse( + response(body=b'{"action":"deny","user_id":"1","device_token":"abc","risk_policy":{"id":"123","revision_id":"abc","name":"def","type":"bot"}}')).call(), + {"action": "deny", "user_id": "1", "device_token": "abc", "risk_policy": { + "id": "123", "revision_id": "abc", "name": "def", "type": "bot"}} + ) + def test_verify_200_299(self): for status_code in range(200, 299): self.assertEqual(