class TestFakeTokenIdDriver(unittest.TestCase):

    def setUp(self):
        self.token_id = MagicMock()
        self.instance = FakeTokenIdDriver()

    @patch('jumpgate.identity.drivers.core')
    def test_invalid_auth_driver(self, mockIdentity):
        mockIdentity.auth_driver.return_value = SLAuthDriver()
        with self.assertRaises(InvalidTokenError):
            self.instance.token_from_id(self.token_id)

    @patch('jumpgate.identity.drivers.core')
    @patch('jumpgate.identity.drivers.sl.tokens.NoAuthDriver')
    def test_auth_failed(self, mockIdentity, mockNoAuthDriver):
        mockIdentity.auth_driver.return_value = mockNoAuthDriver
        mockNoAuthDriver.authenticate.return_value = None
        with self.assertRaises(Unauthorized):
            self.instance.token_from_id(self.token_id)
Exemple #2
0
class TestFakeTokenIdDriver(unittest.TestCase):

    def setUp(self):
        self.token_id = MagicMock()
        self.instance = FakeTokenIdDriver()

    @patch('jumpgate.identity.drivers.core')
    def test_invalid_auth_driver(self, mockIdentity):
        mockIdentity.auth_driver.return_value = SLAuthDriver()
        with self.assertRaises(InvalidTokenError):
            self.instance.token_from_id(self.token_id)

    @patch('jumpgate.identity.drivers.core')
    @patch('jumpgate.identity.drivers.sl.tokens.NoAuthDriver')
    def test_auth_failed(self, mockIdentity, mockNoAuthDriver):
        mockIdentity.auth_driver.return_value = mockNoAuthDriver
        mockNoAuthDriver.authenticate.return_value = None
        with self.assertRaises(Unauthorized):
            self.instance.token_from_id(self.token_id)
 def setUp(self):
     self.token_id = MagicMock()
     self.instance = FakeTokenIdDriver()
Exemple #4
0
 def setUp(self):
     self.token_id = MagicMock()
     self.instance = FakeTokenIdDriver()