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

Commit

Permalink
refactor: path_args/kwargs -> args/kwargs
Browse files Browse the repository at this point in the history
more accurately reflects what's happening now and cyclone's
path_args/kwargs are exactly the same as its calling args/kwargs
anyway

issue #695
  • Loading branch information
pjenvey committed Apr 13, 2017
1 parent 21a8200 commit 8276f2c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 35 deletions.
46 changes: 23 additions & 23 deletions autopush/tests/test_web_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ def _make_fut(self):
schema.context["log"] = Mock()
return schema

def _make_test_data(self, headers=None, body="", path_args=None,
path_kwargs=None, arguments=None):
def _make_test_data(self, headers=None, body="", args=None, kwargs=None,
arguments=None):
return dict(
headers=headers or {},
body=body,
path_args=path_args or [],
path_kwargs=path_kwargs or {},
args=args or [],
kwargs=kwargs or {},
arguments=arguments or {},
)

Expand Down Expand Up @@ -291,13 +291,13 @@ def _make_fut(self):
schema.context["log"] = Mock()
return schema

def _make_test_data(self, headers=None, body="", path_args=None,
path_kwargs=None, arguments=None):
def _make_test_data(self, headers=None, body="", args=None, kwargs=None,
arguments=None):
return dict(
headers=headers or {},
body=body,
path_args=path_args or [],
path_kwargs=path_kwargs or {},
args=args or [],
kwargs=kwargs or {},
arguments=arguments or {},
)

Expand Down Expand Up @@ -784,13 +784,13 @@ def _make_fut(self):
settings.fernet = self.fernet_mock = Mock()
return schema

def _make_test_data(self, headers=None, body="", path_args=None,
path_kwargs=None, arguments=None):
def _make_test_data(self, headers=None, body="", args=None, kwargs=None,
arguments=None):
return dict(
headers=headers or {},
body=body,
path_args=path_args or [],
path_kwargs=path_kwargs or {"api_ver": "v2", "token": "xxx"},
args=args or [],
kwargs=kwargs or {"api_ver": "v2", "token": "xxx"},
arguments=arguments or {},
)

Expand All @@ -816,7 +816,7 @@ def test_valid_vapid_crypto_header(self):
sha256(utils.base64url_decode(crypto_key)).digest()
info = self._make_test_data(
body="asdfasdfasdfasdf",
path_kwargs=dict(
kwargs=dict(
api_ver="v2",
token="asdfasdf",
),
Expand Down Expand Up @@ -847,7 +847,7 @@ def test_valid_vapid_crypto_header_webpush(self):
ckey = 'keyid="a1"; dh="foo";p256ecdsa="%s"' % crypto_key
info = self._make_test_data(
body="asdfasdfasdfasdf",
path_kwargs=dict(
kwargs=dict(
api_ver="v2",
token="asdfasdf",
),
Expand Down Expand Up @@ -881,7 +881,7 @@ def test_invalid_vapid_crypto_header(self, mock_jwt):
ckey = 'keyid="a1"; dh="foo";p256ecdsa="%s"' % crypto_key
info = self._make_test_data(
body="asdfasdfasdfasdf",
path_kwargs=dict(
kwargs=dict(
api_ver="v2",
token="asdfasdf",
),
Expand Down Expand Up @@ -913,7 +913,7 @@ def test_invalid_too_far_exp_vapid_crypto_header(self):
ckey = 'keyid="a1"; dh="foo";p256ecdsa="%s"' % crypto_key
info = self._make_test_data(
body="asdfasdfasdfasdf",
path_kwargs=dict(
kwargs=dict(
api_ver="v2",
token="asdfasdf",
),
Expand Down Expand Up @@ -945,7 +945,7 @@ def test_invalid_bad_exp_vapid_crypto_header(self):
ckey = 'keyid="a1"; dh="foo";p256ecdsa="%s"' % crypto_key
info = self._make_test_data(
body="asdfasdfasdfasdf",
path_kwargs=dict(
kwargs=dict(
api_ver="v2",
token="asdfasdf",
),
Expand Down Expand Up @@ -981,7 +981,7 @@ def test_invalid_encryption_header(self, mock_jwt):
ckey = 'keyid="a1"; dh="foo";p256ecdsa="%s"' % crypto_key
info = self._make_test_data(
body="asdfasdfasdfasdf",
path_kwargs=dict(
kwargs=dict(
api_ver="v2",
token="asdfasdf",
),
Expand Down Expand Up @@ -1017,7 +1017,7 @@ def test_invalid_encryption_jwt(self, mock_jwt):
ckey = 'keyid="a1"; dh="foo";p256ecdsa="%s"' % crypto_key
info = self._make_test_data(
body="asdfasdfasdfasdf",
path_kwargs=dict(
kwargs=dict(
api_ver="v2",
token="asdfasdf",
),
Expand Down Expand Up @@ -1053,7 +1053,7 @@ def test_invalid_crypto_key_header_content(self, mock_jwt):
ckey = 'keyid="a1";invalid="foo";p256ecdsa="%s"' % crypto_key
info = self._make_test_data(
body="asdfasdfasdfasdf",
path_kwargs=dict(
kwargs=dict(
api_ver="v2",
token="asdfasdf",
),
Expand Down Expand Up @@ -1086,7 +1086,7 @@ def test_expired_vapid_header(self):
sha256(utils.base64url_decode(crypto_key)).digest()
info = self._make_test_data(
body="asdfasdfasdfasdf",
path_kwargs=dict(
kwargs=dict(
api_ver="v2",
token="asdfasdf",
),
Expand Down Expand Up @@ -1120,7 +1120,7 @@ def test_missing_vapid_header(self):
ckey = 'keyid="a1"; dh="foo";p256ecdsa="%s"' % crypto_key
info = self._make_test_data(
body="asdfasdfasdfasdf",
path_kwargs=dict(
kwargs=dict(
api_ver="v2",
token="asdfasdf",
),
Expand Down Expand Up @@ -1153,7 +1153,7 @@ def test_bogus_vapid_header(self):
ckey = 'keyid="a1"; dh="foo";p256ecdsa="%s"' % crypto_key
info = self._make_test_data(
body="asdfasdfasdfasdf",
path_kwargs=dict(
kwargs=dict(
api_ver="v2",
token="asdfasdf",
),
Expand Down
4 changes: 2 additions & 2 deletions autopush/web/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def _validate_request(self, request_handler, *args, **kwargs):
data = {
"headers": request_handler.request.headers,
"body": request_handler.request.body,
"path_args": args,
"path_kwargs": kwargs,
"args": args,
"kwargs": kwargs,
"arguments": request_handler.request.arguments,
}
schema = self.schema()
Expand Down
2 changes: 1 addition & 1 deletion autopush/web/log_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LogCheckSchema(Schema):

@pre_load
def extract_data(self, req):
return dict(err_type=req['path_kwargs'].get('err_type'))
return dict(err_type=req['kwargs'].get('err_type'))


class LogCheckHandler(BaseWebHandler):
Expand Down
2 changes: 1 addition & 1 deletion autopush/web/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MessageSchema(Schema):

@pre_load
def extract_data(self, req):
message_id = req['path_kwargs'].get('message_id')
message_id = req['kwargs'].get('message_id')
if not message_id:
raise InvalidRequest("Missing Token",
status_code=400)
Expand Down
8 changes: 4 additions & 4 deletions autopush/web/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def extract_data(self, req):

# UAID and CHID may be empty. This can trigger different behaviors
# in the handlers, so we can't set default values here.
uaid = req['path_kwargs'].get('uaid')
chid = req['path_kwargs'].get('chid', router_data.get("channelID"))
uaid = req['kwargs'].get('uaid')
chid = req['kwargs'].get('chid', router_data.get("channelID"))
if uaid:
try:
u_uuid = uuid.UUID(uaid)
Expand All @@ -81,8 +81,8 @@ def extract_data(self, req):
status_code=410, errno=106)

return dict(
router_type=req['path_kwargs'].get('router_type'),
router_token=req['path_kwargs'].get('router_token'),
router_type=req['kwargs'].get('router_type'),
router_token=req['kwargs'].get('router_token'),
router_data=router_data,
uaid=uaid,
chid=chid,
Expand Down
4 changes: 2 additions & 2 deletions autopush/web/simplepush.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def validate_data(self, value):
@pre_load
def token_prep(self, d):
d["token_info"] = dict(
api_ver=d["path_kwargs"].get("api_ver"),
token=d["path_kwargs"].get("token"),
api_ver=d["kwargs"].get("api_ver"),
token=d["kwargs"].get("token"),
)
return d

Expand Down
4 changes: 2 additions & 2 deletions autopush/web/webpush.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ def validate_data(self, value):
@pre_load
def token_prep(self, d):
d["token_info"] = dict(
api_ver=d["path_kwargs"].get("api_ver"),
token=d["path_kwargs"].get("token"),
api_ver=d["kwargs"].get("api_ver"),
token=d["kwargs"].get("token"),
ckey_header=d["headers"].get("crypto-key", ""),
auth_header=d["headers"].get("authorization", ""),
)
Expand Down

0 comments on commit 8276f2c

Please sign in to comment.