Example #1
0
def set_smsgateway(identifier,
                   providermodule,
                   description=None,
                   options=None,
                   headers=None):
    """
    Set an SMS Gateway configuration

    If the identifier already exist, the SMS Gateway is updated. Otherwise a
    new one is created.

    :param identifier: The unique identifier name of the SMS Gateway
    :param providermodule: The python module of the SMS Gateway
    :type providermodule: basestring
    :param description: A description of this gateway definition
    :param options: Options and Parameter for this module
    :param headers: Headers for this module
    :type options: dict
    :type headers: dict
    :return: The id of the event.
    """
    smsgateway = SMSGateway(identifier,
                            providermodule,
                            description=description,
                            options=options,
                            headers=headers)
    create_sms_instance(identifier).check_configuration()
    return smsgateway.id
Example #2
0
    def test_20_add_update_delete_smsgateway(self):
        name = "myGateway"
        provider_module = "privacyidea.lib.smsprovider.httpbla"
        provider_module2 = "module2"
        gw = SMSGateway(name, provider_module, options={"k": "v"})

        self.assertTrue(gw)

        self.assertEqual(gw.identifier, name)
        self.assertEqual(gw.providermodule, provider_module)

        # update SMS gateway, key "k" should not exist anymore!
        SMSGateway(name, provider_module2, options={"k1": "v1"})
        self.assertEqual(gw.providermodule, provider_module2)
        self.assertEqual(gw.ref_option_list[0].Key, "k1")
        self.assertEqual(gw.ref_option_list[0].Value, "v1")

        # Delete gateway
        gw.delete()
Example #3
0
    def test_20_add_update_delete_smsgateway(self):
        name = "myGateway"
        provider_module = "privacyidea.lib.smsprovider.httpbla"
        provider_module2 = "module2"
        gw = SMSGateway(name, provider_module, options={"k": "v"})

        self.assertTrue(gw)

        self.assertEqual(gw.identifier, name)
        self.assertEqual(gw.providermodule, provider_module)

        # update SMS gateway, key "k" should not exist anymore!
        SMSGateway(name, provider_module2,
                   options={"k1": "v1"})
        self.assertEqual(gw.providermodule, provider_module2)
        self.assertEqual(gw.ref_option_list[0].Key, "k1")
        self.assertEqual(gw.ref_option_list[0].Value, "v1")

        # Delete gateway
        gw.delete()