Skip to content

Commit cc5d24b

Browse files
authored
extended failover response with policy action (#112)
1 parent d3ec5c9 commit cc5d24b

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

castle/failover/prepare_response.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def __init__(self, user_id, strategy=None, reason=None):
99

1010
def call(self):
1111
return dict(
12+
policy={'action': self.strategy},
1213
action=self.strategy,
1314
user_id=self.user_id,
1415
failover=True,

castle/test/client_test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ def test_authenticate_tracked_true(self):
116116
@responses.activate
117117
def test_authenticate_tracked_true_status_500(self):
118118
response_text = {
119+
'policy': {'action': Verdict.ALLOW.value},
120+
119121
'action': Verdict.ALLOW.value,
120122
'user_id': '1234',
121123
'failover': True,
@@ -133,6 +135,8 @@ def test_authenticate_tracked_true_status_500(self):
133135

134136
def test_authenticate_tracked_false(self):
135137
response_text = {
138+
'policy': {'action': Verdict.ALLOW.value},
139+
136140
'action': Verdict.ALLOW.value,
137141
'user_id': '1234',
138142
'failover': True,
@@ -183,6 +187,9 @@ def test_filter_tracked_true(self):
183187
@responses.activate
184188
def test_filter_tracked_true_status_500(self):
185189
response_text = {
190+
191+
'policy': {'action': Verdict.ALLOW.value},
192+
186193
'action': Verdict.ALLOW.value,
187194
'user_id': '1234',
188195
'failover': True,
@@ -205,6 +212,8 @@ def test_filter_tracked_true_status_500(self):
205212

206213
def test_filter_tracked_false(self):
207214
response_text = {
215+
'policy': {'action': Verdict.ALLOW.value},
216+
208217
'action': Verdict.ALLOW.value,
209218
'user_id': '1234',
210219
'failover': True,
@@ -265,6 +274,8 @@ def test_risk_tracked_true(self):
265274
@responses.activate
266275
def test_risk_tracked_true_status_500(self):
267276
response_text = {
277+
'policy': {'action': Verdict.ALLOW.value},
278+
268279
'action': Verdict.ALLOW.value,
269280
'user_id': '1234',
270281
'failover': True,
@@ -287,6 +298,9 @@ def test_risk_tracked_true_status_500(self):
287298

288299
def test_risk_tracked_false(self):
289300
response_text = {
301+
302+
'policy': {'action': Verdict.ALLOW.value},
303+
290304
'action': Verdict.ALLOW.value,
291305
'user_id': '1234',
292306
'failover': True,
@@ -327,6 +341,8 @@ def test_failover_strategy_not_throw(self):
327341
self.assertEqual(
328342
Client.failover_response_or_raise(options.get('user_id'), Exception()),
329343
{
344+
'policy': {'action': Verdict.ALLOW.value},
345+
330346
'action': Verdict.ALLOW.value,
331347
'user_id': '1234',
332348
'failover': True,

castle/test/failover/prepare_response_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def test_call(self):
2828
self.assertDictEqual(
2929
failover_response.call(),
3030
{
31+
'policy': {'action': configuration.failover_strategy},
3132
'action': configuration.failover_strategy,
3233
'user_id': user_id(),
3334
'failover': True,

0 commit comments

Comments
 (0)