Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add process response tests #86

Merged
merged 1 commit into from
Nov 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion castle/test/core/process_response_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down