def test_create_tasks_multiple_servers_multiple_endpoints(self, mock, _): server_to_writer = {'Main': 'writer_1', 'Backup': 'writer_2'} config = { 'account': { 'ikey': 'a', 'skey': 'a', 'hostname': 'a', 'endpoint_server_mappings': [ { 'endpoints': ['auth', 'telephony'], 'server': 'Main' }, { 'endpoints': ['adminaction'], 'server': 'Backup' } ], 'is_msp': False } } Config.set_config(config) create_tasks(server_to_writer) calls = [ call('adminaction', 'writer_2', 'duo_admin'), call('auth', 'writer_1', 'duo_admin'), call('telephony', 'writer_1', 'duo_admin') ] self.assertEquals(mock.call_count, 3) mock.assert_has_calls(calls, any_order=True)
def test_create_tasks_one_server_multiple_endpoints(self, mock, _): server_to_writer = {'Main': 'writer_1'} config = { 'dls_settings': { 'proxy': { 'proxy_server': 'test.com', 'proxy_port': 1234 } }, 'account': { 'ikey': 'a', 'skey': 'a', 'hostname': 'a', 'endpoint_server_mappings': [ { 'endpoints': ['adminaction', 'auth', 'telephony', 'trustmonitor'], 'server': 'Main' } ], 'is_msp': False } } Config.set_config(config) create_tasks(server_to_writer) calls = [ call('adminaction', 'writer_1', 'duo_admin'), call('auth', 'writer_1', 'duo_admin'), call('telephony', 'writer_1', 'duo_admin'), call('trustmonitor', 'writer_1', 'duo_admin') ] self.assertEquals(mock.call_count, 4) mock.assert_has_calls(calls, any_order=True)
def test_create_tasks_one_server_multiple_endpoints_msp(self, mock, mock_childaccount, mock_createadmin): server_to_writer = {'Main': 'writer_1'} config = { 'account': { 'ikey': 'a', 'skey': 'a', 'hostname': 'a', 'endpoint_server_mappings': [ { 'endpoints': ['adminaction', 'auth', 'telephony'], 'server': 'Main' } ], 'is_msp': True } } Config.set_config(config) create_tasks(server_to_writer) calls = [ call('adminaction', 'writer_1', duo_client.Accounts, '12345'), call('auth', 'writer_1', duo_client.Accounts, '12345'), call('telephony', 'writer_1', duo_client.Accounts, '12345'), call('adminaction', 'writer_1', duo_client.Accounts, '56789'), call('auth', 'writer_1', duo_client.Accounts, '56789'), call('telephony', 'writer_1', duo_client.Accounts, '56789') ] self.assertEqual(mock_childaccount.call_count, 1) self.assertEqual(mock.call_count, 6) mock.assert_has_calls(calls, any_order=True)