Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #881 from mozilla-services/fix/880
Browse files Browse the repository at this point in the history
fix: revert registration's strict critical failure check
  • Loading branch information
bbangert authored Apr 25, 2017
2 parents 0ef8563 + caf2ed8 commit 3882ef7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 36 deletions.
29 changes: 4 additions & 25 deletions autopush/tests/test_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,31 +570,6 @@ def restore(*args, **kwargs):
chid=str(dummy_chid))
return self.finish_deferred

def test_post_uaid_critical_failure(self, *args):
self.reg.request.body = json.dumps(dict(
type="webpush",
channelID=str(dummy_chid),
data={},
))
self.settings.router.get_uaid = Mock()
self.settings.router.get_uaid.return_value = {
"critical_failure": "Client is unreachable due to a configuration "
"error."
}
self.fernet_mock.configure_mock(**{
'encrypt.return_value': 'abcd123',
})

def handle_finish(value):
self._check_error(410, 105, "")

self.finish_deferred.addCallback(handle_finish)
self.reg.request.headers["Authorization"] = self.auth
self._post(router_type="simplepush",
uaid=dummy_uaid.hex,
chid=str(dummy_chid))
return self.finish_deferred

def test_post_nochid(self):
self.reg.request.body = json.dumps(dict(
type="simplepush",
Expand Down Expand Up @@ -684,6 +659,10 @@ def handle_finish(value):
app_id='',
uri=self.reg.request.uri
)
user_data = self.router_mock.register_user.call_args[0][0]
eq_(user_data['uaid'], dummy_uaid.hex)
eq_(user_data['router_type'], 'test')
eq_(user_data['router_data']['token'], 'some_token')

def restore(*args, **kwargs):
uuid.uuid4 = old_func
Expand Down
12 changes: 1 addition & 11 deletions autopush/web/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,10 @@ def extract_data(self, req):
chid = req['path_kwargs'].get('chid', router_data.get("channelID"))
if uaid:
try:
u_uuid = uuid.UUID(uaid)
uuid.UUID(uaid)
except (ValueError, TypeError):
raise InvalidRequest("Invalid Request UAID",
status_code=401, errno=109)
# Check if the UAID has a 'critical error' which means that it's
# probably invalid and should be reset/re-registered
try:
record = self.context['settings'].router.get_uaid(u_uuid.hex)
if record.get('critical_failure'):
raise InvalidRequest("Invalid Request UAID",
status_code=410, errno=105)
except ItemNotFound:
pass

if chid:
try:
uuid.UUID(chid)
Expand Down

0 comments on commit 3882ef7

Please sign in to comment.