Commit 28620831 authored by Bruce Timberlake's avatar Bruce Timberlake
Browse files

Some data cleanups

parent 03950ab1
...@@ -14,8 +14,8 @@ logger = logging.getLogger(__name__) ...@@ -14,8 +14,8 @@ logger = logging.getLogger(__name__)
# which may be different in your IDE, or command line. # which may be different in your IDE, or command line.
class IamGroupCRUDTests(unittest.TestCase): class IamGroupCRUDTests(unittest.TestCase):
client_id = "e06fb405-c58e-4334-b746-dd5969575bf2" client_id = "some-guid-goes-here"
secret = "G5oT3vL1uK8xS7rO5sJ4nH7bK5iB6hN5jN5dI0nL8tO5bG4tT5" secret = "secret-string-goes-here"
scope = "iamgroups" scope = "iamgroups"
token_url = "https://apigw-tst.it.umich.edu/um/inst/oauth2/token" token_url = "https://apigw-tst.it.umich.edu/um/inst/oauth2/token"
url_base = "https://apigw-tst.it.umich.edu/um/iamGroups" url_base = "https://apigw-tst.it.umich.edu/um/iamGroups"
...@@ -44,7 +44,7 @@ class IamGroupCRUDTests(unittest.TestCase): ...@@ -44,7 +44,7 @@ class IamGroupCRUDTests(unittest.TestCase):
# needs to url encode. Note the test at the bottom of the unit test. # needs to url encode. Note the test at the bottom of the unit test.
def test_2_read(self): def test_2_read(self):
api = ApiDirectory(self.client_id, self.secret, self.scope, self.token_url) api = ApiDirectory(self.client_id, self.secret, self.scope, self.token_url)
dn = "cn=iamGroupTestJB,ou=user groups,ou=groups,dc=umich,dc=edu" dn = "cn=TestGroupName,ou=user groups,ou=groups,dc=umich,dc=edu"
encoded = urllib.parse.quote(dn) encoded = urllib.parse.quote(dn)
url_endpoint = 'profile/dn' url_endpoint = 'profile/dn'
url = IamGroupCRUDTests.url_base + '/' + url_endpoint + "/" + encoded url = IamGroupCRUDTests.url_base + '/' + url_endpoint + "/" + encoded
...@@ -66,14 +66,14 @@ class IamGroupCRUDTests(unittest.TestCase): ...@@ -66,14 +66,14 @@ class IamGroupCRUDTests(unittest.TestCase):
profile = list[0] profile = list[0]
self.assertEqual(profile['dn'], dn) self.assertEqual(profile['dn'], dn)
# update. There are many update operations. I am showing how to modifiy a moderator. # update. There are many update operations. I am showing how to modify a moderator.
def test_3_update(self): def test_3_update(self):
api = ApiDirectory(self.client_id, self.secret, self.scope, self.token_url) api = ApiDirectory(self.client_id, self.secret, self.scope, self.token_url)
url_endpoint = 'update/moderator' url_endpoint = 'update/moderator'
url = IamGroupCRUDTests.url_base + '/' + url_endpoint url = IamGroupCRUDTests.url_base + '/' + url_endpoint
data = {'dn': 'cn=iamGroupTestJB,ou=user groups,ou=groups,dc=umich,dc=edu', data = {'dn': 'cn=TestGroupName,ou=user groups,ou=groups,dc=umich,dc=edu',
'moderator': [{'email': 'john.boufford@yahoo.com'}, 'moderator': [{'email': 'bjensen@umich.edu'},
{'name': 'John Boufford', 'email': 'jbouffor@yahoo.com'}]} {'name': 'Barbara Jensen', 'email': 'bjensen@umich.edu'}]}
response = requests.post( response = requests.post(
url=url, url=url,
...@@ -89,7 +89,7 @@ class IamGroupCRUDTests(unittest.TestCase): ...@@ -89,7 +89,7 @@ class IamGroupCRUDTests(unittest.TestCase):
# delete an existing group. Again the dn is part of the url so it should be encoded. # delete an existing group. Again the dn is part of the url so it should be encoded.
def test_4_delete(self): def test_4_delete(self):
api = ApiDirectory(self.client_id, self.secret, self.scope, self.token_url) api = ApiDirectory(self.client_id, self.secret, self.scope, self.token_url)
dn = "cn=iamGroupTestJB,ou=user groups,ou=groups,dc=umich,dc=edu" dn = "cn=TestGroupName,ou=user groups,ou=groups,dc=umich,dc=edu"
encoded = urllib.parse.quote(dn) encoded = urllib.parse.quote(dn)
url_endpoint = 'delete' url_endpoint = 'delete'
url = IamGroupCRUDTests.url_base + '/' + url_endpoint + "/" + encoded url = IamGroupCRUDTests.url_base + '/' + url_endpoint + "/" + encoded
...@@ -107,8 +107,8 @@ class IamGroupCRUDTests(unittest.TestCase): ...@@ -107,8 +107,8 @@ class IamGroupCRUDTests(unittest.TestCase):
# Note that I used urllib.parse.quote which converts spaces to %20. # Note that I used urllib.parse.quote which converts spaces to %20.
# the urllib.parse.quote_plus converts spaces to a plus sign. Which fails in this api. # the urllib.parse.quote_plus converts spaces to a plus sign. Which fails in this api.
def test_urlencoding(self): def test_urlencoding(self):
expected = "cn%3DiamGroupTestJB%2Cou%3Duser%20groups%2Cou%3Dgroups%2Cdc%3Dumich%2Cdc%3Dedu" expected = "cn%3DTestGroupName%2Cou%3Duser%20groups%2Cou%3Dgroups%2Cdc%3Dumich%2Cdc%3Dedu"
pre = "cn=iamGroupTestJB,ou=user groups,ou=groups,dc=umich,dc=edu" pre = "cn=TestGroupName,ou=user groups,ou=groups,dc=umich,dc=edu"
post = urllib.parse.quote(pre) post = urllib.parse.quote(pre)
print(post) print(post)
self.assertEqual(post, expected) self.assertEqual(post, expected)
...@@ -117,7 +117,7 @@ class IamGroupCRUDTests(unittest.TestCase): ...@@ -117,7 +117,7 @@ class IamGroupCRUDTests(unittest.TestCase):
# Make sure to encode the name because the name can contain spaces and other specail chars. # Make sure to encode the name because the name can contain spaces and other specail chars.
def test_isValid(self): def test_isValid(self):
api = ApiDirectory(self.client_id, self.secret, self.scope, self.token_url) api = ApiDirectory(self.client_id, self.secret, self.scope, self.token_url)
name = "iamGroupTestJB" name = "TestGroupName"
encoded = urllib.parse.quote(name) encoded = urllib.parse.quote(name)
url_endpoint = 'isValidName' url_endpoint = 'isValidName'
url = IamGroupCRUDTests.url_base + '/' + url_endpoint + "/" + encoded url = IamGroupCRUDTests.url_base + '/' + url_endpoint + "/" + encoded
...@@ -138,7 +138,7 @@ class IamGroupCRUDTests(unittest.TestCase): ...@@ -138,7 +138,7 @@ class IamGroupCRUDTests(unittest.TestCase):
# Make sure to encode the name because the name can contain spaces and other specail chars. # Make sure to encode the name because the name can contain spaces and other specail chars.
def test_isValid_failed(self): def test_isValid_failed(self):
api = ApiDirectory(self.client_id, self.secret, self.scope, self.token_url) api = ApiDirectory(self.client_id, self.secret, self.scope, self.token_url)
name = "jbouffor" name = "bjensen"
encoded = urllib.parse.quote(name) encoded = urllib.parse.quote(name)
url_endpoint = 'isValidName' url_endpoint = 'isValidName'
url = IamGroupCRUDTests.url_base + '/' + url_endpoint + "/" + encoded url = IamGroupCRUDTests.url_base + '/' + url_endpoint + "/" + encoded
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment