Esempio n. 1
0
    def test_set_password_injects_broadsoftinstance(
            self, inject_broadsoftinstance_patch, post_patch
    ):
        d = Device(broadsoftinstance=broadsoft.requestobjects.lib.BroadsoftRequest.instance_factory(), name='dname')
        d.set_password(sip_password='******', did=6175551212)
        self.assertTrue(inject_broadsoftinstance_patch.called)
        self.assertEqual(1, len(inject_broadsoftinstance_patch.call_args_list))

        call = inject_broadsoftinstance_patch.call_args_list[0]
        args, kwargs = call
        self.assertIsInstance(kwargs['child'], GroupAccessDeviceModifyRequest)
Esempio n. 2
0
    def test_set_password_deriving_sip_user_name(
            self, device_mod_patch, post_patch
    ):
        b = BroadsoftRequest()

        # just a did
        d = Device(name='devicename')
        d.set_password(did=6175551212, sip_password='******')

        call = device_mod_patch.call_args_list[0]
        args, kwargs = call
        self.assertEqual('6175551212@' + d.broadsoftinstance.default_domain, kwargs['sip_user_name'])

        # just a sip_user_name
        d = Device(name='devicename')
        d.set_password(sip_user_name='*****@*****.**', sip_password='******')

        call = device_mod_patch.call_args_list[1]
        args, kwargs = call
        self.assertEqual('*****@*****.**', kwargs['sip_user_name'])

        # both; sip_user_name should win
        d = Device(name='devicename')
        d.set_password(did=6175551212, sip_user_name='*****@*****.**', sip_password='******')

        call = device_mod_patch.call_args_list[2]
        args, kwargs = call
        self.assertEqual('*****@*****.**', kwargs['sip_user_name'])
Esempio n. 3
0
    def test_set_password_requirements(
            self, device_mod_patch, post_patch
    ):
        # requires device name
        with self.assertRaises(ValueError):
            d = Device(name=None)
            d.set_password(sip_user_name='*****@*****.**', sip_password='******')

        # requires did or sip_user_name
        with self.assertRaises(ValueError):
            d = Device(name='dname')
            d.set_password(sip_password='******')

        # requires password
        with self.assertRaises(ValueError):
            d = Device(name='dname')
            d.set_password(sip_user_name='*****@*****.**')