def testEnumerateUsers_NoInexactMatch(self): session = Session() account = model.Account(loginname='john', password=u'jane') session.add(account) plugin = EuphorieAccountPlugin('plugin') self.assertEqual( plugin.enumerateUsers(login='******', exact_match=False), [])
def test_authenticate_login_not_case_sensitive(self): session = Session() account = model.Account(loginname='john', password=u'jane') session.add(account) plugin = EuphorieAccountPlugin('plugin') credentials = {'login': '******', 'password': u'jane'} self.assertTrue(plugin._authenticate_login(credentials) is not None)
def test_authenticate_login_not_case_sensitive(self): session = Session() account = model.Account(loginname="john", password="******") session.add(account) plugin = EuphorieAccountPlugin("plugin") credentials = {"login": "******", "password": "******"} self.assertTrue(plugin._authenticate_login(credentials) is not None)
def test_extraction_with_token_header(self): import mock plugin = EuphorieAccountPlugin('plugin') request = mock.Mock() request.getHeader.return_value = 'the-token' self.assertEqual(plugin.extractCredentials(request), {'api-token': 'the-token'})
def test_authenticate_token_call_cms_authenticate(self): plugin = EuphorieAccountPlugin("plugin") with mock.patch( "euphorie.client.authentication.authenticate_cms_token", return_value="result", ): self.assertEqual(plugin._authenticate_token({"api-token": "y"}), "result")
def test_authenticate_login_valid_login(self): session = Session() account = model.Account(loginname='john', password=u'jane') session.add(account) plugin = EuphorieAccountPlugin('plugin') credentials = {'login': '******', 'password': u'jane'} self.assertTrue(plugin._authenticate_login(credentials) is not None)
def test_extraction_with_token_header(self): import mock plugin = EuphorieAccountPlugin('plugin') request = mock.Mock() request.getHeader.return_value = 'the-token' self.assertEqual( plugin.extractCredentials(request), {'api-token': 'the-token'})
def test_authenticate_token_call_cms_authenticate(self): import mock plugin = EuphorieAccountPlugin('plugin') with mock.patch( 'euphorie.client.authentication.authenticate_cms_token', return_value='result'): self.assertEqual(plugin._authenticate_token({'api-token': 'y'}), 'result')
def test_EnumerateUsers_search_by_login(self): session = Session() account = model.Account(loginname='john', password=u'jane') session.add(account) plugin = EuphorieAccountPlugin('plugin') self.assertEqual( plugin.enumerateUsers(login='******', exact_match=True), [{'id': '1', 'login': '******'}])
def test_authenticate_token_call_cms_authenticate(self): import mock plugin = EuphorieAccountPlugin('plugin') with mock.patch( 'euphorie.client.authentication.authenticate_cms_token', return_value='result'): self.assertEqual( plugin._authenticate_token({'api-token': 'y'}), 'result')
def testCreateUser_ValidAccount(self): session = Session() account = model.Account(loginname="john", password="******") session.add(account) request = MockRequest(ACTUAL_URL="http://www.example.com/client") directlyProvides(request, IClientSkinLayer) plugin = EuphorieAccountPlugin("plugin") plugin.REQUEST = request self.assertTrue(plugin.createUser("1", "john") is account)
def test_EnumerateUsers_search_by_id(self): session = Session() account = model.Account(loginname='john', password=u'jane') session.add(account) plugin = EuphorieAccountPlugin('plugin') info = plugin.enumerateUsers(id='1', exact_match=True) self.assertEqual(info, [{'id': '1', 'login': '******'}]) self.assertTrue(isinstance(info[0]['id'], str)) self.assertTrue(isinstance(info[0]['login'], str))
def test_EnumerateUsers_search_by_login(self): session = Session() account = model.Account(loginname='john', password=u'jane') session.add(account) plugin = EuphorieAccountPlugin('plugin') self.assertEqual(plugin.enumerateUsers(login='******', exact_match=True), [{ 'id': '1', 'login': '******' }])
def test_Challenge_with_query_string(self): from euphorie.client.interfaces import IClientSkinLayer from zope.interface import directlyProvides request = MockRequest(ACTUAL_URL='http://www.example.com/client', QUERY_STRING='one=1') directlyProvides(request, IClientSkinLayer) response = MockResponse() plugin = EuphorieAccountPlugin('plugin') self.assertEqual(plugin.challenge(request, response), True) self.assertEqual( response.redirect_url, 'http://www.example.com/base/@@login?' 'came_from=http%3A%2F%2Fwww.example.com%2Fclient%3Fone%3D1')
def test_EnumerateUsers_search_by_login_and_id(self): session = Session() account = model.Account(loginname="john", password="******") session.add(account) request = MockRequest(ACTUAL_URL="http://www.example.com/client") directlyProvides(request, IClientSkinLayer) plugin = EuphorieAccountPlugin("plugin") plugin.REQUEST = request self.assertEqual( plugin.enumerateUsers(id="1", login="******", exact_match=True), [{"id": "1", "login": "******"}], )
def test_Challenge_no_query_string(self): request = MockRequest(ACTUAL_URL="http://www.example.com/client") directlyProvides(request, IClientSkinLayer) response = MockResponse() plugin = EuphorieAccountPlugin("plugin") self.assertEqual(plugin.challenge(request, response), True) self.assertEqual( response.redirect_url, "http://www.example.com/base/@@login?" "came_from=http%3A%2F%2Fwww.example.com%2Fclient", ) self.assertEqual(bool(response.redirect_lock), True)
def test_Challenge_require_IClientSkinLayer(self): request = MockRequest(ACTUAL_URL="http://www.example.com/client") response = MockResponse() plugin = EuphorieAccountPlugin("plugin") self.assertEqual(plugin.challenge(request, response), False)
def test_EnumerateUsers_unknown_account(self): plugin = EuphorieAccountPlugin("plugin") self.assertEqual(plugin.enumerateUsers(id="1", exact_match=False), [])
def test_Challenge_require_IClientSkinLayer(self): request = MockRequest(ACTUAL_URL='http://www.example.com/client') response = MockResponse() plugin = EuphorieAccountPlugin('plugin') self.assertEqual(plugin.challenge(request, response), False)
def testCreateUser_ValidAccount(self): session = Session() account = model.Account(loginname='john', password=u'jane') session.add(account) plugin = EuphorieAccountPlugin('plugin') self.assertTrue(plugin.createUser('1', 'john') is account)
def test_authenticate_login_wrong_credential_type(self): plugin = EuphorieAccountPlugin("plugin") self.assertEqual(plugin._authenticate_login({"cookie": "yummie"}), None)
def test_authenticate_token_no_token(self): plugin = EuphorieAccountPlugin("plugin") self.assertEqual(plugin._authenticate_token({}), None)
def test_extraction_no_token_header(self): import mock plugin = EuphorieAccountPlugin('plugin') request = mock.Mock() request.getHeader.return_value = None self.assertEqual(plugin.extractCredentials(request), {})
def test_authenticate_token_no_token(self): plugin = EuphorieAccountPlugin('plugin') self.assertEqual(plugin._authenticate_token({}), None)
def test_authenticate_login_wrong_credential_type(self): plugin = EuphorieAccountPlugin('plugin') self.assertEqual( plugin._authenticate_login({'cookie': 'yummie'}), None)
def test_authenticate_login_unknown_account(self): plugin = EuphorieAccountPlugin('plugin') credentials = {'login': '******', 'password': u'secret'} self.assertEqual( plugin._authenticate_login(credentials), None)
def test_extraction_no_token_header(self): plugin = EuphorieAccountPlugin("plugin") request = mock.Mock() request.getHeader.return_value = None self.assertEqual(plugin.extractCredentials(request), {})
def test_authenticate_login_wrong_credential_type(self): plugin = EuphorieAccountPlugin('plugin') self.assertEqual(plugin._authenticate_login({'cookie': 'yummie'}), None)
def test_EnumerateUsers_unknown_account(self): plugin = EuphorieAccountPlugin('plugin') self.assertEqual( plugin.enumerateUsers(id='1', exact_match=False), [])
def test_authenticate_login_unknown_account(self): plugin = EuphorieAccountPlugin('plugin') credentials = {'login': '******', 'password': u'secret'} self.assertEqual(plugin._authenticate_login(credentials), None)
def test_authenticate_login_unknown_account(self): plugin = EuphorieAccountPlugin("plugin") credentials = {"login": "******", "password": "******"} self.assertEqual(plugin._authenticate_login(credentials), None)
def test_CreateUser_unknown_account(self): plugin = EuphorieAccountPlugin('plugin') self.assertEqual(plugin.createUser('1', 'john'), None)
def test_CreateUser_unknown_account(self): plugin = EuphorieAccountPlugin("plugin") self.assertEqual(plugin.createUser("1", "john"), None)