class ConnectionSettingsAuthManagerTests(TestCase): username = '******' password = '******' def setUp(self): self.connx = ConnectionSettings( domain='meaning-of-life', name='Mr. Creosote', url='https://restaurant.fr/api/', auth_type=BASIC_AUTH, username=self.username, notify_addresses_str='*****@*****.**', ) self.connx.plaintext_password = self.password self.connx.save() def tearDown(self): self.connx.delete() def test_connection_settings_auth_manager(self): auth_manager = self.connx.get_auth_manager() self.assertIsInstance(auth_manager, BasicAuthManager) self.assertEqual(auth_manager.username, self.username) self.assertEqual(auth_manager.password, self.password) self.assertNotEqual(auth_manager.password, self.connx.password) self.assertTrue(self.connx.password.startswith(f'${ALGO_AES}$'))
def connection_fixture(domain_name): connx = ConnectionSettings( domain=domain_name, name='example.com', url='https://example.com/forwarding', ) connx.save() try: yield connx finally: connx.delete()
def test_connection_settings_auth_manager(self): connx = ConnectionSettings( domain=DOMAIN, name='Mr. Creosote', url=URL, auth_type=BASIC_AUTH, username=USERNAME, password='', notify_addresses_str=ADMIN, ) connx.plaintext_password = PASSWORD connx.save() try: auth_manager = connx.get_auth_manager() self.assertIsInstance(auth_manager, BasicAuthManager) self.assertEqual(auth_manager.username, USERNAME) self.assertEqual(auth_manager.password, PASSWORD) self.assertNotEqual(auth_manager.password, connx.password) self.assertTrue(connx.password.startswith(f'${ALGO_AES}$')) finally: connx.delete()