Skip to content

Commit f171960

Browse files
committed
Revert "Revert "fix: temporary fix for issue #53""
This reverts commit f8fc16f.
1 parent f8fc16f commit f171960

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

flaskapp/flaskapp.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ def deliveries_delete():
208208
get_cache()['deliveryQueue'] = []
209209
get_cache()['deliveryQueueCounter'] = 0
210210

211+
if 'challenge_token' in get_cache():
212+
del get_cache()['challenge_token']
213+
214+
get_cache()['deliveryQueueCounter'] = 0
215+
211216
return ''
212217

213218

@@ -579,13 +584,15 @@ def verify_post():
579584
if delivery.state == DeliveryState.AWAITING_AUTHENTICATION_SENDER:
580585
if delivery.sender == username:
581586
del get_cache()['challenge_token']
582-
patch_delivery_with_json(delivery_id, {"state": "AWAITING_PACKAGE_LOAD"})
587+
patch_delivery_with_json(delivery_id, {"state":
588+
"AWAITING_PACKAGE_LOAD"})
583589
return ''
584590

585591
if delivery.state == DeliveryState.AWAITING_AUTHENTICATION_RECEIVER:
586592
if delivery.receiver == username:
587593
del get_cache()['challenge_token']
588-
patch_delivery_with_json(delivery_id, {"state": "AWAITING_PACKAGE_RETRIEVAL"})
594+
patch_delivery_with_json(delivery_id,
595+
{"state": "AWAITING_PACKAGE_RETRIEVAL"})
589596
return ''
590597

591598
return unauthorized("You are not allowed to open the box!")

flaskapp/tests.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def test_get_instruction_batch(self):
724724
if 'token' in resjson:
725725
del resjson['token']
726726
self.assertEquals(resjson, {'instructions': data,
727-
'correction': data_correction})
727+
'correction': data_correction})
728728

729729
def test_get_instruction_batch_no_correction(self):
730730
data = self.batch_data()
@@ -756,7 +756,7 @@ def test_get_instruction_batch_limit(self):
756756
if 'token' in resjson:
757757
del resjson['token']
758758
self.assertEquals(resjson, {'instructions': data[0:2],
759-
'correction': data_correction})
759+
'correction': data_correction})
760760

761761
route = '/instructions/batch?limit=3'
762762
r = self.client.get(route)
@@ -766,7 +766,7 @@ def test_get_instruction_batch_limit(self):
766766
if 'token' in resjson:
767767
del resjson['token']
768768
self.assertEquals(resjson, {'instructions': data,
769-
'correction': data_correction})
769+
'correction': data_correction})
770770

771771
route = '/instructions/batch?limit=10'
772772
r = self.client.get(route)
@@ -776,7 +776,7 @@ def test_get_instruction_batch_limit(self):
776776
if 'token' in resjson:
777777
del resjson['token']
778778
self.assertEquals(resjson, {'instructions': data,
779-
'correction': data_correction})
779+
'correction': data_correction})
780780

781781
def test_get_instruction_batch_limit_invalid(self):
782782
data = self.batch_data()
@@ -1028,6 +1028,10 @@ def get_challenge_token(self):
10281028
self.route = '/instructions/batch'
10291029
r = self.client.get(self.route)
10301030
self.assertEquals(r.status_code, 200)
1031+
1032+
if 'token' not in r.json:
1033+
return None
1034+
10311035
token = r.json['token']
10321036
self.assertEquals(len(token), 10)
10331037
return token
@@ -1067,10 +1071,8 @@ def test_post_verify_auth_receiver(self):
10671071
def test_post_verify_error_wrong_state(self):
10681072
self.setup_delivery()
10691073
self.change_delivery_state("IN_QUEUE")
1070-
bearer = self.login("foo2", "bar2")
10711074
token = self.get_challenge_token()
1072-
r = self.execute_challenge(token, bearer)
1073-
self.assertEquals(r.status_code, 400)
1075+
self.assertEquals(token, None)
10741076

10751077
def test_post_verify_error_wrong_token(self):
10761078
self.setup_delivery()

0 commit comments

Comments
 (0)