class SmppSMSTestCase(MyTestCase): config = { 'SMSC_HOST': "192.168.1.1", 'SMSC_PORT': "1234", 'SYSTEM_ID': "privacyIDEA", 'PASSWORD': "******", 'SYSTEM_ID': "privacyIDEA", 'S_ADDR_TON': "0x5", 'S_ADDR_NPI': "0x1", 'S_ADDR': "privacyIDEA", 'D_ADDR_TON': "0x5", 'D_ADDR_NPI': "0x1" } def setUp(self): self.provider = SmppSMSProvider() self.provider.load_config(self.config) def test_01_success(self): # Here we need to send the SMS try: r = self.provider.submit_message("123456", "Hello") self.assertTrue(r) except: r = False self.assertFalse(r) def test_02_fail(self): # Here we need to send the SMS self.assertRaises(SMSError, self.provider.submit_message, "123456", "Hello") def test_08_smsgateway_success(self): identifier = "mySMS" provider_module = "privacyidea.lib.smsprovider.SmppSMSProvider" \ ".SmppSMSProvider" id = set_smsgateway(identifier, provider_module, description="test", options=self.config) self.assertTrue(id > 0) sms = create_sms_instance(identifier) try: r = sms.submit_message("123456", "Hello") self.assertTrue(r) except: r = False self.assertFalse(r)
def test_00_errors(self): # No smsgateway defined s = SmppSMSProvider() self.assertRaises(SMSError, s.submit_message, "phone", "message") # No host defined set_smsgateway("missing_host", self.provider_module, options={"SMSC_PORT": "1234"}) p = create_sms_instance(identifier="missing_host") self.assertRaises(SMSError, p.submit_message, "phone", "message") delete_smsgateway("missing_host") # No port defined set_smsgateway("missing_port", self.provider_module, options={"SMSC_HOST": "1.1.1.1"}) p = create_sms_instance(identifier="missing_port") self.assertRaises(SMSError, p.submit_message, "phone", "message") delete_smsgateway("missing_port")
def test_00_config(self): r = SmppSMSProvider.parameters() self.assertEqual(r.get("options_allowed"), False) params = r.get("parameters") self.assertEqual(params.get("SMSC_HOST").get("required"), True)
def setUp(self): self.provider = SmppSMSProvider() self.provider.load_config(self.config)