class GenericTestCase(TestCase): fixtures = [ 'test_taxonomy.json', 'test_stations.json', 'test_programs.json', 'test_users.json', 'test_users_openid.json', ] def setUp(self): # Every test needs a client. self.client = Client() self.backend = OpenIDBackend() def test_get_user(self): user = self.backend.get_user(-1) self.failUnlessEqual(user, None) user = self.backend.get_user(2) self.failUnlessEqual(user.username, "admin") def test_authenticate_fail(self): try: user = self.backend.authenticate(openid_response=None) self.failUnlessEqual(user, None) except: pass def test_create_user_from_openid_with_sreg(self): openid_response = MockOpenIDSuccessResponse( SUCCESS, 'http://192.168.1.121:8081/u/some_identity') openid_response.addSRegValid() user = self.backend.authenticate(openid_response=openid_response) self.failUnlessEqual(user.username, 'MyNickname') def test_create_user_from_openid(self): openid_response = MockOpenIDSuccessResponse( SUCCESS, 'http://192.168.1.121:8081/u/some_identity') user = self.backend.authenticate(openid_response=openid_response) self.failUnlessEqual(user.username, 'openiduser') def test_openid_request_failure_response(self): openid_response = MockOpenIdFailureResponse( endpoint=OpenIDServiceEndpoint()) user = self.backend.authenticate(openid_response=openid_response) self.failUnlessEqual(user, None)
class GenericTestCase(TestCase): fixtures = ['test_taxonomy.json', 'test_stations.json', 'test_programs.json', 'test_users.json', 'test_users_openid.json',] def setUp(self): # Every test needs a client. self.client = Client() self.backend = OpenIDBackend() def test_get_user(self): user = self.backend.get_user(-1) self.failUnlessEqual(user, None) user = self.backend.get_user(2) self.failUnlessEqual(user.username, "admin") def test_authenticate_fail(self): try: user = self.backend.authenticate(openid_response=None) self.failUnlessEqual(user, None) except: pass def test_create_user_from_openid_with_sreg(self): openid_response = MockOpenIDSuccessResponse(SUCCESS, 'http://192.168.1.121:8081/u/some_identity') openid_response.addSRegValid() user = self.backend.authenticate(openid_response=openid_response) self.failUnlessEqual(user.username, 'MyNickname') def test_create_user_from_openid(self): openid_response = MockOpenIDSuccessResponse(SUCCESS, 'http://192.168.1.121:8081/u/some_identity') user = self.backend.authenticate(openid_response=openid_response) self.failUnlessEqual(user.username, 'openiduser') def test_openid_request_failure_response(self): openid_response = MockOpenIdFailureResponse(endpoint=OpenIDServiceEndpoint()) user = self.backend.authenticate(openid_response=openid_response) self.failUnlessEqual(user,None)
def setUp(self): # Every test needs a client. self.client = Client() self.backend = OpenIDBackend()