diff --git a/autopush/tests/test_web_validation.py b/autopush/tests/test_web_validation.py index 6122eed4..96a978b0 100644 --- a/autopush/tests/test_web_validation.py +++ b/autopush/tests/test_web_validation.py @@ -593,7 +593,7 @@ def test_no_current_month(self): assert cm.value.status_code == 410 assert cm.value.errno == 106 - assert cm.value.message == "No such subscription" + assert cm.value.message == "Subscription elapsed" def test_old_current_month(self): schema = self._make_fut() @@ -616,7 +616,7 @@ def test_old_current_month(self): assert cm.value.status_code == 410 assert cm.value.errno == 106 - assert cm.value.message == "No such subscription" + assert cm.value.message == "Subscription expired" class TestWebPushRequestSchemaUsingVapid(unittest.TestCase): diff --git a/autopush/web/registration.py b/autopush/web/registration.py index 235a6469..b94283b4 100644 --- a/autopush/web/registration.py +++ b/autopush/web/registration.py @@ -149,7 +149,8 @@ def validate_auth(self, data): auth_type, auth_token = re.sub( r' +', ' ', auth.strip()).split(" ", 2) except ValueError: - raise InvalidRequest("Invalid Authentication", status_code=401, + raise InvalidRequest("Invalid Authentication", + status_code=401, errno=109, headers=request_pref_header) if auth_type.lower() not in AUTH_SCHEMES: @@ -483,4 +484,4 @@ def _chid_not_found_err(self, fail): self.log.debug(format="CHID not found in AWS.", status_code=410, errno=106, **self._client_info) - self._write_response(410, 106, message="Invalid endpoint.") + self._write_response(410, 106, message="Invalid endpoint for user.") diff --git a/autopush/web/webpush.py b/autopush/web/webpush.py index 2d6002fa..50294fe5 100644 --- a/autopush/web/webpush.py +++ b/autopush/web/webpush.py @@ -97,7 +97,8 @@ def validate_uaid_month_and_chid(self, d): self.context["metrics"].increment("updates.drop_user", tags=make_tags(errno=102)) self.context["db"].router.drop_user(result["uaid"]) - raise InvalidRequest("No such subscription", status_code=410, + raise InvalidRequest("No route for subscription", + status_code=410, errno=106) if (router_type in ["gcm", "fcm"] @@ -137,7 +138,8 @@ def _validate_webpush(self, d, result): uaid_record=repr(result)) metrics.increment("updates.drop_user", tags=make_tags(errno=102)) db.router.drop_user(uaid) - raise InvalidRequest("No such subscription", status_code=410, + raise InvalidRequest("Subscription elapsed", + status_code=410, errno=106) month_table = result["current_month"] @@ -147,7 +149,8 @@ def _validate_webpush(self, d, result): uaid_record=repr(result)) metrics.increment("updates.drop_user", tags=make_tags(errno=103)) db.router.drop_user(uaid) - raise InvalidRequest("No such subscription", status_code=410, + raise InvalidRequest("Subscription expired", + status_code=410, errno=106) exists, chans = db.message_tables[month_table].all_channels(uaid=uaid) @@ -155,7 +158,8 @@ def _validate_webpush(self, d, result): in map(lambda x: normalize_id(x), chans)): log.debug("Unknown subscription: {channel_id}", channel_id=channel_id) - raise InvalidRequest("No such subscription", status_code=410, + raise InvalidRequest("No such subscription for user", + status_code=410, errno=106)