Mercurial > hg > AuthRPC
changeset 12:4ac14cfadc15
Improved AuthTest
author | Ben Croston <ben@croston.org> |
---|---|
date | Mon, 05 Sep 2011 12:29:08 +0100 |
parents | dbd55e6af4f6 |
children | 21eb67081c43 |
files | wibble/tests.py |
diffstat | 1 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/wibble/tests.py Mon Sep 05 12:13:45 2011 +0100 +++ b/wibble/tests.py Mon Sep 05 12:29:08 2011 +0100 @@ -56,7 +56,7 @@ ##### server ^^^ ##### ##### client vvv ##### -class NotAuthTest(unittest.TestCase): +class AuthTest(unittest.TestCase): def runTest(self): from client import ServerProxy, UnauthorisedException self.client = ServerProxy('http://localhost:1337/', @@ -66,6 +66,20 @@ with self.assertRaises(UnauthorisedException): self.assertEqual(self.client.api.mymethod(),self.client.mymethod()) + self.client = ServerProxy('http://localhost:1337/', + username='testuser', + password='wrongpassword', + user_agent='wibble_unittest') + with self.assertRaises(UnauthorisedException): + self.assertEqual(self.client.api.mymethod(),self.client.mymethod()) + + self.client = ServerProxy('http://localhost:1337/', + username='wronguser', + password='s3cr3t', + user_agent='wibble_unittest') + with self.assertRaises(UnauthorisedException): + self.assertEqual(self.client.api.mymethod(),self.client.mymethod()) + class WibbleTests(unittest.TestCase): def setUp(self): from client import ServerProxy @@ -117,7 +131,7 @@ # tests are as client suite = unittest.TestSuite() - suite.addTest(NotAuthTest()) + suite.addTest(AuthTest()) suite.addTest(IgnoreClassNameTest()) suite.addTest(ExceptionTest()) suite.addTest(BadRequestTest())