def test_bad_fcm_senders(self): old_list = self.TestArg.fcm_creds self.TestArg.fcm_creds = json.dumps({"12345": {"foo": "abcd"}}) with pytest.raises(InvalidConfig): AutopushConfig.from_argparse(self.TestArg) self.TestArg.fcm_creds = "{}" with pytest.raises(InvalidConfig): AutopushConfig.from_argparse(self.TestArg) self.TestArg.fcm_creds = old_list
def test_bad_fcm_senders(self): old_auth = self.TestArg.fcm_auth old_senderid = self.TestArg.fcm_senderid self.TestArg.fcm_auth = "" with pytest.raises(InvalidConfig): AutopushConfig.from_argparse(self.TestArg) self.TestArg.fcm_auth = old_auth self.TestArg.fcm_senderid = "" with pytest.raises(InvalidConfig): AutopushConfig.from_argparse(self.TestArg) self.TestArg.fcm_senderid = old_senderid
def test_aws_ami_id(self, request_mock): class MockReply: content = "ami_123" request_mock.return_value = MockReply self.TestArg.no_aws = False conf = AutopushConfig.from_argparse(self.TestArg) assert conf.ami_id == "ami_123"
def __init__(self, sysargs, use_files=True): ns = self._load_args(sysargs, use_files) self._conf = conf = AutopushConfig.from_argparse(ns) conf.statsd_host = None self.db = DatabaseManager.from_config(conf) self.db.setup(conf.preflight_uaid) self._endpoint = ns.endpoint self._pp = pprint.PrettyPrinter(indent=4)
def test_conf(self, *args): conf = AutopushConfig.from_argparse(self.TestArg) app = EndpointApplication(conf) # verify that the hostname is what we said. assert conf.hostname == self.TestArg.hostname assert app.routers["gcm"].router_conf['collapsekey'] == "collapse" assert app.routers["apns"].router_conf['firefox']['cert'] == \ "cert.file" assert app.routers["apns"].router_conf['firefox']['key'] == "key.file"
def _from_argparse(cls, ns, **kwargs): # type: (Namespace, **Any) -> AutopushMultiService """Create an instance from argparse/additional kwargs""" # Add some entropy to prevent potential conflicts. postfix = os.urandom(4).encode('hex').ljust(8, '0') conf = AutopushConfig.from_argparse( ns, debug=ns.debug, preflight_uaid="deadbeef00000000deadbeef" + postfix, **kwargs) return cls(conf)
def test_conf(self, *args): self.TestArg.fcm_service_cred_path = "some/file.json" self.TestArg.fcm_project_id = "fir_testbridge" conf = AutopushConfig.from_argparse(self.TestArg) app = EndpointApplication(conf, resource=autopush.tests.boto_resource) # verify that the hostname is what we said. assert conf.hostname == self.TestArg.hostname assert app.routers["gcm"].router_conf['collapsekey'] == "collapse" assert app.routers["apns"].router_conf['firefox']['cert'] == \ "cert.file" assert app.routers["apns"].router_conf['firefox']['key'] == "key.file" assert app.routers["adm"].router_conf['dev']['app_id'] == \ "amzn1.application.StringOfStuff" assert app.routers["adm"].router_conf['dev']['client_id'] == \ "amzn1.application-oa2-client.ev4nM0reStuff" assert app.routers["adm"].router_conf['dev']['client_secret'] == \ "deadbeef0000decafbad1111" conf = AutopushConfig.from_argparse(self.TestArg) assert conf.router_conf['fcm']['version'] == 0 app = EndpointApplication(conf, resource=autopush.tests.boto_resource) assert app.routers["fcm"].router_conf["version"] == 0
def test_no_sslcontext_cache(self): conf = AutopushConfig.from_argparse(self.TestArg) assert not conf.no_sslcontext_cache self.TestArg._no_sslcontext_cache = True conf = AutopushConfig.from_argparse(self.TestArg) assert conf.no_sslcontext_cache
def test_bad_senders(self): old_list = self.TestArg.senderid_list self.TestArg.senderid_list = "{}" with pytest.raises(InvalidConfig): AutopushConfig.from_argparse(self.TestArg) self.TestArg.senderid_list = old_list
def test_client_certs_parse(self): conf = AutopushConfig.from_argparse(self.TestArg) assert conf.client_certs["1A:" * 31 + "F9"] == 'partner1' assert conf.client_certs["2B:" * 31 + "E8"] == 'partner2' assert conf.client_certs["3C:" * 31 + "D7"] == 'partner2'