コード例 #1
0
ファイル: test_auth.py プロジェクト: rackerlabs/otter
class WaitingAuthenticatorTests(SynchronousTestCase):
    """
    Tests for `WaitingAuthenticator`
    """

    def setUp(self):
        """
        Create WaitingAuthenticator
        """
        self.clock = Clock()
        self.mock_auth = iMock(IAuthenticator)
        self.authenticator = WaitingAuthenticator(self.clock, self.mock_auth, 5)

    def test_waits(self):
        """
        Waits before returning token
        """
        self.mock_auth.authenticate_tenant.return_value = succeed('token')
        d = self.authenticator.authenticate_tenant('t1', 'log')
        self.assertNoResult(d)
        self.clock.advance(5)
        self.assertEqual(self.successResultOf(d), 'token')
        self.mock_auth.authenticate_tenant.assert_called_once_with('t1', log='log')

    def test_no_wait_on_error(self):
        """
        Does not wait if internal auth errors
        """
        self.mock_auth.authenticate_tenant.return_value = fail(ValueError('e'))
        d = self.authenticator.authenticate_tenant('t1', 'log')
        self.failureResultOf(d, ValueError)
コード例 #2
0
ファイル: test_auth.py プロジェクト: stephamon/otter
class WaitingAuthenticatorTests(SynchronousTestCase):
    """
    Tests for `WaitingAuthenticator`
    """
    def setUp(self):
        """
        Create WaitingAuthenticator
        """
        self.clock = Clock()
        self.mock_auth = iMock(IAuthenticator)
        self.authenticator = WaitingAuthenticator(self.clock, self.mock_auth,
                                                  5)

    def test_waits(self):
        """
        Waits before returning token
        """
        self.mock_auth.authenticate_tenant.return_value = succeed('token')
        d = self.authenticator.authenticate_tenant('t1', 'log')
        self.assertNoResult(d)
        self.clock.advance(5)
        self.assertEqual(self.successResultOf(d), 'token')
        self.mock_auth.authenticate_tenant.assert_called_once_with('t1',
                                                                   log='log')

    def test_no_wait_on_error(self):
        """
        Does not wait if internal auth errors
        """
        self.mock_auth.authenticate_tenant.return_value = fail(ValueError('e'))
        d = self.authenticator.authenticate_tenant('t1', 'log')
        self.failureResultOf(d, ValueError)
コード例 #3
0
ファイル: test_auth.py プロジェクト: stephamon/otter
 def setUp(self):
     """
     Create WaitingAuthenticator
     """
     self.clock = Clock()
     self.mock_auth = iMock(IAuthenticator)
     self.authenticator = WaitingAuthenticator(self.clock, self.mock_auth,
                                               5)
コード例 #4
0
ファイル: test_auth.py プロジェクト: rackerlabs/otter
 def setUp(self):
     """
     Create WaitingAuthenticator
     """
     self.clock = Clock()
     self.mock_auth = iMock(IAuthenticator)
     self.authenticator = WaitingAuthenticator(self.clock, self.mock_auth, 5)