def test_05_users(self): responses.add(responses.GET, self.TOKEN_URL, status=200, content_type='application/json', body=self.BODY_ACCESSTOKEN) responses.add(responses.GET, self.USER_URL, status=200, content_type='application/json', body=self.BODY_USERS) y = SCIMResolver() y.loadConfig({ 'Authserver': self.AUTHSERVER, 'Resourceserver': self.RESOURCESERVER, 'Client': self.CLIENT, 'Secret': self.SECRET, 'Mapping': "{}" }) r = y.getUserList() self.assertEqual(len(r), 2) self.assertEqual(r[0].get("username"), "bjensen") self.assertEqual(r[1].get("username"), "jsmith")
def test_03_checkpass(self): responses.add(responses.GET, self.TOKEN_URL, status=200, content_type='application/json', body=self.BODY_ACCESSTOKEN) y = SCIMResolver() y.loadConfig({'Authserver': self.AUTHSERVER, 'Resourceserver': self.RESOURCESERVER, 'Client': self.CLIENT, 'Secret': self.SECRET, 'Mapping': "{}"}) r = y.checkPass("uid", "password") self.assertFalse(r)
def test_03_checkpass(self): responses.add(responses.GET, self.TOKEN_URL, status=200, content_type='application/json', body=self.BODY_ACCESSTOKEN) y = SCIMResolver() y.loadConfig({ 'Authserver': self.AUTHSERVER, 'Resourceserver': self.RESOURCESERVER, 'Client': self.CLIENT, 'Secret': self.SECRET, 'Mapping': "{}" }) r = y.checkPass("uid", "password") self.assertFalse(r)
def test_05_users(self): responses.add(responses.GET, self.TOKEN_URL, status=200, content_type='application/json', body=self.BODY_ACCESSTOKEN) responses.add(responses.GET, self.USER_URL, status=200, content_type='application/json', body=self.BODY_USERS) y = SCIMResolver() y.loadConfig({'Authserver': self.AUTHSERVER, 'Resourceserver': self.RESOURCESERVER, 'Client': self.CLIENT, 'Secret': self.SECRET, 'Mapping': "{}"}) r = y.getUserList() self.assertEqual(len(r), 2) self.assertEqual(r[0].get("username"), "bjensen") self.assertEqual(r[1].get("username"), "jsmith")
def test_04_single_user(self): responses.add(responses.GET, self.TOKEN_URL, status=200, content_type='application/json', body=self.BODY_ACCESSTOKEN) responses.add(responses.GET, self.USER_URL + "/bjensen", status=200, content_type='application/json', body=self.BODY_SINGLE_USER) y = SCIMResolver() y.loadConfig({ 'Authserver': self.AUTHSERVER, 'Resourceserver': self.RESOURCESERVER, 'Client': self.CLIENT, 'Secret': self.SECRET, 'Mapping': "{username: '******'}" }) r = y.getUserInfo("bjensen") self.assertEqual(r.get("username"), "bjensen") self.assertEqual(r.get("phone"), "555-555-8377") self.assertEqual(r.get("givenname"), "Barbara") self.assertEqual(r.get("surname"), "Jensen") self.assertEqual(r.get("email"), "*****@*****.**") r = y.getUsername("bjensen") self.assertEqual(r, "bjensen") r = y.getUserId("bjensen") self.assertEqual(r, "bjensen")
def test_04_single_user(self): responses.add( responses.GET, self.TOKEN_URL, status=200, content_type="application/json", body=self.BODY_ACCESSTOKEN ) responses.add( responses.GET, self.USER_URL + "/bjensen", status=200, content_type="application/json", body=self.BODY_SINGLE_USER, ) y = SCIMResolver() y.loadConfig( { "Authserver": self.AUTHSERVER, "Resourceserver": self.RESOURCESERVER, "Client": self.CLIENT, "Secret": self.SECRET, "Mapping": "{username: '******'}", } ) r = y.getUserInfo("bjensen") self.assertEqual(r.get("username"), "bjensen") self.assertEqual(r.get("phone"), "555-555-8377") self.assertEqual(r.get("givenname"), "Barbara") self.assertEqual(r.get("surname"), "Jensen") self.assertEqual(r.get("email"), "*****@*****.**") r = y.getUsername("bjensen") self.assertEqual(r, "bjensen") r = y.getUserId("bjensen") self.assertEqual(r, "bjensen")
def test_02_load_config(self): responses.add(responses.GET, self.TOKEN_URL, status=200, content_type='application/json', body=self.BODY_ACCESSTOKEN) y = SCIMResolver() y.loadConfig({'Authserver': self.AUTHSERVER, 'Resourceserver': self.RESOURCESERVER, 'Client': self.CLIENT, 'Secret': self.SECRET, 'Mapping': "{}"}) rid = y.getResolverId() self.assertEqual(rid, self.AUTHSERVER) r = y.getResolverClassDescriptor() self.assertTrue("scimresolver" in r) r = y.getResolverDescriptor() self.assertTrue("scimresolver" in r) r = y.getResolverType() self.assertEqual("scimresolver", r)
def test_02_load_config(self): responses.add(responses.GET, self.TOKEN_URL, status=200, content_type='application/json', body=self.BODY_ACCESSTOKEN) y = SCIMResolver() y.loadConfig({ 'Authserver': self.AUTHSERVER, 'Resourceserver': self.RESOURCESERVER, 'Client': self.CLIENT, 'Secret': self.SECRET, 'Mapping': "{}" }) rid = y.getResolverId() self.assertEqual(rid, self.AUTHSERVER) r = y.getResolverClassDescriptor() self.assertTrue("scimresolver" in r) r = y.getResolverDescriptor() self.assertTrue("scimresolver" in r) r = y.getResolverType() self.assertEqual("scimresolver", r)