diff --git a/autopush/router/apnsrouter.py b/autopush/router/apnsrouter.py index 78863ad5..d2cdcb41 100644 --- a/autopush/router/apnsrouter.py +++ b/autopush/router/apnsrouter.py @@ -36,7 +36,7 @@ def _connect(self, rel_channel, load_connections=True): """ default_topic = "com.mozilla.org." + rel_channel - cert_info = self._config[rel_channel] + cert_info = self.router_conf[rel_channel] return APNSClient( cert_file=cert_info.get("cert"), key_file=cert_info.get("key"), @@ -61,11 +61,11 @@ def __init__(self, ap_settings, router_conf, metrics, """ self.ap_settings = ap_settings - self._config = router_conf + self.router_conf = router_conf self.metrics = metrics self._base_tags = ["platform:apns"] self.apns = dict() - for rel_channel in self._config: + for rel_channel in router_conf: self.apns[rel_channel] = self._connect(rel_channel, load_connections) self.ap_settings = ap_settings diff --git a/autopush/router/fcm.py b/autopush/router/fcm.py index eaa36ed9..01b5112e 100644 --- a/autopush/router/fcm.py +++ b/autopush/router/fcm.py @@ -104,7 +104,7 @@ class FCMRouter(object): def __init__(self, ap_settings, router_conf, metrics): """Create a new FCM router and connect to FCM""" self.ap_settings = ap_settings - self.config = router_conf + self.router_conf = router_conf self.metrics = metrics self.min_ttl = router_conf.get("ttl", 60) self.dryRun = router_conf.get("dryrun", False) @@ -165,7 +165,7 @@ def _route(self, notification, router_data): # Payload data is optional. The endpoint handler validates that the # correct encryption headers are included with the data. if notification.data: - mdata = self.config.get('max_data', 4096) + mdata = self.router_conf.get('max_data', 4096) if notification.data_length > mdata: raise self._error("This message is intended for a " + "constrained device and is limited " + diff --git a/autopush/router/gcm.py b/autopush/router/gcm.py index 98e10dc1..1144b5a6 100644 --- a/autopush/router/gcm.py +++ b/autopush/router/gcm.py @@ -22,7 +22,7 @@ class GCMRouter(object): def __init__(self, ap_settings, router_conf, metrics): """Create a new GCM router and connect to GCM""" self.ap_settings = ap_settings - self.config = router_conf + self.router_conf = router_conf self.metrics = metrics self.min_ttl = router_conf.get("ttl", 60) self.dryRun = router_conf.get("dryrun", False) @@ -82,7 +82,7 @@ def _route(self, notification, uaid_data): # Payload data is optional. The endpoint handler validates that the # correct encryption headers are included with the data. if notification.data: - mdata = self.config.get('max_data', 4096) + mdata = self.router_conf.get('max_data', 4096) if notification.data_length > mdata: raise self._error("This message is intended for a " + "constrained device and is limited " + diff --git a/autopush/router/webpush.py b/autopush/router/webpush.py index 014cfed8..36810be0 100644 --- a/autopush/router/webpush.py +++ b/autopush/router/webpush.py @@ -48,7 +48,7 @@ class WebPushRouter(object): def __init__(self, ap_settings, router_conf, db, agent): """Create a new Router""" self.ap_settings = ap_settings - self.conf = router_conf + self.router_conf = router_conf self.db = db self.agent = agent self.waker = None @@ -153,15 +153,15 @@ def route_notification(self, notification, uaid_data): returnValue(self.delivered_response(notification)) else: ret_val = self.stored_response(notification) - if self.udp is not None and "server" in self.conf: + if self.udp is not None and "server" in self.router_conf: # Attempt to send off the UDP wake request. try: yield deferToThread( requests.post( - self.conf["server"], + self.router_conf["server"], data=urlencode(self.udp["data"]), - cert=self.conf.get("cert"), - timeout=self.conf.get("server_timeout", 3))) + cert=self.router_conf.get("cert"), + timeout=self.router_conf.get("server_timeout", 3))) except Exception as exc: self.log.debug("Could not send UDP wake request: {exc}", exc=exc) diff --git a/autopush/tests/test_main.py b/autopush/tests/test_main.py index e28d83b5..954714a2 100644 --- a/autopush/tests/test_main.py +++ b/autopush/tests/test_main.py @@ -360,9 +360,9 @@ def test_settings(self, *args): app = EndpointApplication(settings) # verify that the hostname is what we said. eq_(settings.hostname, self.TestArg.hostname) - eq_(app.routers["gcm"].config['collapsekey'], "collapse") - eq_(app.routers["apns"]._config['firefox']['cert'], "cert.file") - eq_(app.routers["apns"]._config['firefox']['key'], "key.file") + eq_(app.routers["gcm"].router_conf['collapsekey'], "collapse") + eq_(app.routers["apns"].router_conf['firefox']['cert'], "cert.file") + eq_(app.routers["apns"].router_conf['firefox']['key'], "key.file") eq_(settings.wake_timeout, 10) def test_bad_senders(self): diff --git a/autopush/tests/test_router.py b/autopush/tests/test_router.py index 080b7690..9cb402a9 100644 --- a/autopush/tests/test_router.py +++ b/autopush/tests/test_router.py @@ -1128,8 +1128,8 @@ def test_route_udp(self, request_mock): router_data = dict(node_id="http://somewhere", uaid=dummy_uaid, udp=udp_data) self.router_mock.get_uaid.return_value = router_data - self.router.conf = {'server': 'http://example.com', - 'idle': 1, 'cert': 'test.pem'} + self.router.router_conf = {'server': 'http://example.com', + 'idle': 1, 'cert': 'test.pem'} d = self.router.route_notification(self.notif, router_data)