OLD | NEW |
1 # This file is part of the Juju GUI, which lets users view and manage Juju | 1 # This file is part of the Juju GUI, which lets users view and manage Juju |
2 # environments within a graphical interface (https://launchpad.net/juju-gui). | 2 # environments within a graphical interface (https://launchpad.net/juju-gui). |
3 # Copyright (C) 2013 Canonical Ltd. | 3 # Copyright (C) 2013 Canonical Ltd. |
4 # | 4 # |
5 # This program is free software: you can redistribute it and/or modify it under | 5 # This program is free software: you can redistribute it and/or modify it under |
6 # the terms of the GNU Affero General Public License version 3, as published by | 6 # the terms of the GNU Affero General Public License version 3, as published by |
7 # the Free Software Foundation. | 7 # the Free Software Foundation. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, but WITHOUT | 9 # This program is distributed in the hope that it will be useful, but WITHOUT |
10 # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | 10 # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 'request_id': 42, | 310 'request_id': 42, |
311 'op': 'login', | 311 'op': 'login', |
312 'user': 'user', | 312 'user': 'user', |
313 }, | 313 }, |
314 ) | 314 ) |
315 for request in requests: | 315 for request in requests: |
316 is_login = self.backend.request_is_login(request) | 316 is_login = self.backend.request_is_login(request) |
317 self.assertFalse(is_login, request) | 317 self.assertFalse(is_login, request) |
318 | 318 |
319 | 319 |
320 class TestAuthenticationTokenHandler(unittest.TestCase): | 320 class TestAuthenticationTokenHandler(LogTrapTestCase, unittest.TestCase): |
321 | 321 |
322 def setUp(self): | 322 def setUp(self): |
323 super(TestAuthenticationTokenHandler, self).setUp() | 323 super(TestAuthenticationTokenHandler, self).setUp() |
324 self.io_loop = mock.Mock() | 324 self.io_loop = mock.Mock() |
325 self.max_life = datetime.timedelta(minutes=1) | 325 self.max_life = datetime.timedelta(minutes=1) |
326 self.tokens = auth.AuthenticationTokenHandler( | 326 self.tokens = auth.AuthenticationTokenHandler( |
327 self.max_life, self.io_loop) | 327 self.max_life, self.io_loop) |
328 | 328 |
329 def test_explicit_initialization(self): | 329 def test_explicit_initialization(self): |
330 # The class accepted the explicit initialization. | 330 # The class accepted the explicit initialization. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 self.tokens.process_authentication_request(request, write_message)) | 484 self.tokens.process_authentication_request(request, write_message)) |
485 | 485 |
486 def test_process_authentication_response(self): | 486 def test_process_authentication_response(self): |
487 # It translates a normal authentication success. | 487 # It translates a normal authentication success. |
488 user = auth.User('user-admin', 'ADMINSECRET', True) | 488 user = auth.User('user-admin', 'ADMINSECRET', True) |
489 response = {'RequestId': 42, 'Response': {}} | 489 response = {'RequestId': 42, 'Response': {}} |
490 self.assertEqual( | 490 self.assertEqual( |
491 dict(RequestId=42, | 491 dict(RequestId=42, |
492 Response=dict(AuthTag=user.username, Password=user.password)), | 492 Response=dict(AuthTag=user.username, Password=user.password)), |
493 self.tokens.process_authentication_response(response, user)) | 493 self.tokens.process_authentication_response(response, user)) |
OLD | NEW |