示例#1
0
 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), [])
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
 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'})
示例#5
0
 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")
示例#6
0
 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), [])
示例#7
0
 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)
示例#8
0
 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'})
示例#9
0
 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')
示例#10
0
 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': '******'}])
示例#11
0
 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')
示例#12
0
 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)
示例#13
0
 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))
示例#14
0
 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))
示例#15
0
 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': '******'
                      }])
示例#16
0
 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')
示例#17
0
 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": "******"}],
     )
示例#18
0
 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)
示例#19
0
 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')
示例#20
0
 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)
示例#21
0
 def test_EnumerateUsers_unknown_account(self):
     plugin = EuphorieAccountPlugin("plugin")
     self.assertEqual(plugin.enumerateUsers(id="1", exact_match=False), [])
示例#22
0
 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)
示例#23
0
 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)
示例#24
0
 def test_authenticate_login_wrong_credential_type(self):
     plugin = EuphorieAccountPlugin("plugin")
     self.assertEqual(plugin._authenticate_login({"cookie": "yummie"}), None)
示例#25
0
 def test_authenticate_token_no_token(self):
     plugin = EuphorieAccountPlugin("plugin")
     self.assertEqual(plugin._authenticate_token({}), None)
示例#26
0
 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), {})
示例#27
0
 def test_authenticate_token_no_token(self):
     plugin = EuphorieAccountPlugin('plugin')
     self.assertEqual(plugin._authenticate_token({}), None)
示例#28
0
 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)
示例#29
0
 def test_authenticate_login_wrong_credential_type(self):
     plugin = EuphorieAccountPlugin('plugin')
     self.assertEqual(
             plugin._authenticate_login({'cookie': 'yummie'}), None)
示例#30
0
 def test_authenticate_login_unknown_account(self):
     plugin = EuphorieAccountPlugin('plugin')
     credentials = {'login': '******', 'password': u'secret'}
     self.assertEqual(
             plugin._authenticate_login(credentials), None)
示例#31
0
 def test_extraction_no_token_header(self):
     plugin = EuphorieAccountPlugin("plugin")
     request = mock.Mock()
     request.getHeader.return_value = None
     self.assertEqual(plugin.extractCredentials(request), {})
示例#32
0
 def test_authenticate_login_wrong_credential_type(self):
     plugin = EuphorieAccountPlugin('plugin')
     self.assertEqual(plugin._authenticate_login({'cookie': 'yummie'}),
                      None)
示例#33
0
 def test_EnumerateUsers_unknown_account(self):
     plugin = EuphorieAccountPlugin('plugin')
     self.assertEqual(
             plugin.enumerateUsers(id='1', exact_match=False), [])
示例#34
0
 def test_authenticate_login_unknown_account(self):
     plugin = EuphorieAccountPlugin('plugin')
     credentials = {'login': '******', 'password': u'secret'}
     self.assertEqual(plugin._authenticate_login(credentials), None)
示例#35
0
 def test_authenticate_login_unknown_account(self):
     plugin = EuphorieAccountPlugin("plugin")
     credentials = {"login": "******", "password": "******"}
     self.assertEqual(plugin._authenticate_login(credentials), None)
示例#36
0
 def test_CreateUser_unknown_account(self):
     plugin = EuphorieAccountPlugin('plugin')
     self.assertEqual(plugin.createUser('1', 'john'), None)
示例#37
0
 def test_CreateUser_unknown_account(self):
     plugin = EuphorieAccountPlugin("plugin")
     self.assertEqual(plugin.createUser("1", "john"), None)
示例#38
0
 def test_CreateUser_unknown_account(self):
     plugin = EuphorieAccountPlugin('plugin')
     self.assertEqual(plugin.createUser('1', 'john'), None)