Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 07d19bdf authored by Paul Arthur's avatar Paul Arthur
Browse files

Make test data more readable, fix PEP8 issues

parent af81e791
include CHANGELOG.md
include COPYING
include VERSION
include tests/data/*
include version.sh
[
{
"dn": "cn=testgroup,ou=User Groups,ou=Groups,dc=umich,dc=edu",
"naming": null,
"displayName": "testgroup",
"email": null,
"displayTitle": null,
"title": null,
"affiliation": null,
"description": null,
"member": false,
"owner": false,
"moderator": false,
"person": false,
"group": true,
"external": false,
"securityEquals": null,
"groupMembership": null,
"role": null
}
]
[
{
"dn": "cn=testgroup2,ou=User Groups,ou=Groups,dc=umich,dc=edu",
"naming": null,
"displayName": "testgroup2",
"email": null,
"displayTitle": null,
"title": null,
"affiliation": null,
"description": null,
"member": false,
"owner": false,
"moderator": false,
"person": false,
"group": true,
"external": false,
"securityEquals": null,
"groupMembership": null,
"role": null
}
]
[
{
"dn": "uid=testuser,ou=People,dc=umich,dc=edu",
"naming": "testuser",
"displayName": "Test Usersson",
"email": "testuser@umich.edu",
"displayTitle": "Application Operations System Administrator Senior",
"title": [
"Application Operations System Administrator Senior"
],
"affiliation": [
"ITS Infra Sys Application Ops - Faculty and Staff",
"ITS Infrastrc - Systems - Faculty and Staff"
],
"description": null,
"member": false,
"owner": false,
"moderator": false,
"person": true,
"group": false,
"external": false,
"securityEquals": null,
"groupMembership": null,
"role": null
},
{
"dn": "cn=testuser-group,ou=User Groups,ou=Groups,dc=umich,dc=edu",
"naming": null,
"displayName": "testuser-group",
"email": null,
"displayTitle": null,
"title": null,
"affiliation": null,
"description": null,
"member": false,
"owner": false,
"moderator": false,
"person": false,
"group": true,
"external": false,
"securityEquals": null,
"groupMembership": null,
"role": null
},
{
"dn": "cn=testuser-dev,ou=User Groups,ou=Groups,dc=umich,dc=edu",
"naming": null,
"displayName": "testuser-dev",
"email": null,
"displayTitle": null,
"title": null,
"affiliation": null,
"description": null,
"member": false,
"owner": false,
"moderator": false,
"person": false,
"group": true,
"external": false,
"securityEquals": null,
"groupMembership": null,
"role": null
},
{
"dn": "cn=test-testuser,ou=User Groups,ou=Groups,dc=umich,dc=edu",
"naming": null,
"displayName": "test-testuser",
"email": null,
"displayTitle": null,
"title": null,
"affiliation": null,
"description": null,
"member": false,
"owner": false,
"moderator": false,
"person": false,
"group": true,
"external": false,
"securityEquals": null,
"groupMembership": null,
"role": null
}
]
[
{
"dn": "uid=testuser2,ou=People,dc=umich,dc=edu",
"naming": "testuser2",
"displayName": "Test Usersson Jr.",
"email": "testuser2@umich.edu",
"displayTitle": "Application Operations System Administrator Senior",
"title": [
"Application Operations System Administrator Senior"
],
"affiliation": [
"ITS Infra Sys Application Ops - Faculty and Staff",
"ITS Infrastrc - Systems - Faculty and Staff"
],
"description": null,
"member": false,
"owner": false,
"moderator": false,
"person": true,
"group": false,
"external": false,
"securityEquals": null,
"groupMembership": null,
"role": null
}
]
{
"dn": "uid=testuser,ou=People,dc=umich,dc=edu",
"naming": "testuser",
"displayName": "Test Usersson",
"email": "testuser@umich.edu",
"displayTitle": "Application Operations System Administrator Senior",
"title": [
"Application Operations System Administrator Senior"
],
"affiliation": [
"ITS Infra Sys Application Ops - Faculty and Staff",
"ITS Infrastrc - Systems - Faculty and Staff"
],
"description": null,
"member": false,
"owner": false,
"moderator": false,
"person": true,
"group": false,
"external": false,
"securityEquals": null,
"groupMembership": null,
"role": null
}
{
"group": [
{
"objectClass": [
"top",
"groupofnames",
"umichgroup",
"rfc822mailgroup",
"umichexpire",
"dirxml-entitlementrecipient",
"posixgroup",
"ndsloginproperties"
],
"dn": "cn=testgroup,ou=user groups,ou=groups,dc=umich,dc=edu",
"name": "testgroup",
"description": null,
"aliases": [
"alias1",
"alias2",
"alias3"
],
"memberDn": [
"uid=testuser,ou=people,dc=umich,dc=edu"
],
"ownerDn": [
"uid=testuser,ou=people,dc=umich,dc=edu",
"cn=controller-group,ou=user groups,ou=groups,dc=umich,dc=edu"
],
"owners": [
{
"dn": "uid=testuser,ou=people,dc=umich,dc=edu",
"naming": "testuser",
"displayName": "Test Usersson",
"email": "testuser@umich.edu",
"displayTitle": "Application Operations System Administrator Senior",
"title": [
"Application Operations System Administrator Senior"
],
"affiliation": [
"ITS Infra Sys Application Ops - Faculty and Staff",
"ITS Infrastrc - Systems - Faculty and Staff"
],
"description": null,
"member": false,
"owner": false,
"moderator": false,
"person": true,
"group": false,
"external": false,
"securityEquals": null,
"groupMembership": null,
"role": null
}
],
"expiredDate": "02/05/2020",
"email": "testgroup",
"isSpamBlocked": true,
"isEmailWarningSuppressed": true,
"isJoinable": false,
"externalSystems": [
"Box",
"Google"
],
"isPrivate": true,
"isEmailableByMembersOnly": false,
"xmlAssociations": null,
"moderatorRaw": null,
"moderator": null,
"memberGroupDn": null,
"groupMemberDnRaw": null,
"memberExternalRaw": null,
"memberExternal": null,
"renewAuthority": null,
"disabled": false,
"disabledBy": null,
"disabledMessage": null,
"disabledDate": null,
"purgeDate": null,
"notice": null,
"acl": null,
"equivalentToMe": null,
"descriptionLevel": "PUBLIC",
"noticeLevel": "PUBLIC",
"urlLevel": "PUBLIC",
"errorsTo": null,
"errorsToExternalRaw": null,
"errorsToExternal": null,
"requestTo": null,
"requestToExternalRaw": null,
"requestToExternal": null,
"gidNumber": "2280774",
"editable": false,
"urlLinks": null,
"labeledUri": null,
"authenticatedUserRole": null,
"authenticatedUserRoles": null,
"renewable": true,
"moderated": false
}
],
"error": null
}
#!/usr/bin/env python
import json
import os
from flask import Flask
app = Flask(__name__)
def get_testdata(base, name):
fname = os.path.join(os.path.dirname(__file__), 'data/{}_{}.json'.format(base, name))
if os.path.exists(fname):
with open(fname, 'r') as f:
return f.read()
else:
return '{}'
@app.route("/iamGroups/create", methods=['POST'])
@app.route("/iamGroups/delete/<dn>", methods=['GET'])
@app.route("/iamGroups/renew/<dn>", methods=['GET'])
......@@ -13,26 +24,22 @@ app = Flask(__name__)
def return_success(attrib=False, dn=False):
return '{"status": "success"}'
@app.route("/iamGroups/profile/dn/<dn>", methods=['GET'])
def get_group(dn):
return '{"group":[{"objectClass":["top","groupofnames","umichgroup","rfc822mailgroup","umichexpire","dirxml-entitlementrecipient","posixgroup","ndsloginproperties"],"dn":"cn=testgroup,ou=user groups,ou=groups,dc=umich,dc=edu","name":"testgroup","description":null,"aliases":["alias1","alias2","alias3"],"memberDn":["uid=testuser,ou=people,dc=umich,dc=edu"],"ownerDn":["uid=testuser,ou=people,dc=umich,dc=edu","cn=controller-group,ou=user groups,ou=groups,dc=umich,dc=edu"],"owners":[{"dn":"uid=testuser,ou=people,dc=umich,dc=edu","naming":"testuser","displayName":"Test Usersson","email":"testuser@umich.edu","displayTitle":"Application Operations System Administrator Senior","title":["Application Operations System Administrator Senior"],"affiliation":["ITS Infra Sys Application Ops - Faculty and Staff","ITS Infrastrc - Systems - Faculty and Staff"],"description":null,"member":false,"owner":false,"moderator":false,"person":true,"group":false,"external":false,"securityEquals":null,"groupMembership":null,"role":null}],"expiredDate":"02/05/2020","email":"testgroup","isSpamBlocked":true,"isEmailWarningSuppressed":true,"isJoinable":false,"externalSystems":["Box","Google"],"isPrivate":true,"isEmailableByMembersOnly":false,"xmlAssociations":null,"moderatorRaw":null,"moderator":null,"memberGroupDn":null,"groupMemberDnRaw":null,"memberExternalRaw":null,"memberExternal":null,"renewAuthority":null,"disabled":false,"disabledBy":null,"disabledMessage":null,"disabledDate":null,"purgeDate":null,"notice":null,"acl":null,"equivalentToMe":null,"descriptionLevel":"PUBLIC","noticeLevel":"PUBLIC","urlLevel":"PUBLIC","errorsTo":null,"errorsToExternalRaw":null,"errorsToExternal":null,"requestTo":null,"requestToExternalRaw":null,"requestToExternal":null,"gidNumber":"2280774","editable":false,"urlLinks":null,"labeledUri":null,"authenticatedUserRole":null,"authenticatedUserRoles":null,"renewable":true,"moderated":false}],"error":null}'
cn = dn.split(',')[0].split('=')[1]
return get_testdata('profile', cn)
@app.route("/iamGroups/find/both/<name>", methods=['GET'])
def get_both(name):
if name == 'testuser':
return '[{"dn":"uid=testuser,ou=People,dc=umich,dc=edu","naming":"testuser","displayName":"Test Usersson","email":"testuser@umich.edu","displayTitle":"Application Operations System Administrator Senior","title":["Application Operations System Administrator Senior"],"affiliation":["ITS Infra Sys Application Ops - Faculty and Staff","ITS Infrastrc - Systems - Faculty and Staff"],"description":null,"member":false,"owner":false,"moderator":false,"person":true,"group":false,"external":false,"securityEquals":null,"groupMembership":null,"role":null},{"dn":"cn=testuser-group,ou=User Groups,ou=Groups,dc=umich,dc=edu","naming":null,"displayName":"testuser-group","email":null,"displayTitle":null,"title":null,"affiliation":null,"description":null,"member":false,"owner":false,"moderator":false,"person":false,"group":true,"external":false,"securityEquals":null,"groupMembership":null,"role":null},{"dn":"cn=testuser-dev,ou=User Groups,ou=Groups,dc=umich,dc=edu","naming":null,"displayName":"testuser-dev","email":null,"displayTitle":null,"title":null,"affiliation":null,"description":null,"member":false,"owner":false,"moderator":false,"person":false,"group":true,"external":false,"securityEquals":null,"groupMembership":null,"role":null},{"dn":"cn=test-testuser,ou=User Groups,ou=Groups,dc=umich,dc=edu","naming":null,"displayName":"test-testuser","email":null,"displayTitle":null,"title":null,"affiliation":null,"description":null,"member":false,"owner":false,"moderator":false,"person":false,"group":true,"external":false,"securityEquals":null,"groupMembership":null,"role":null}]'
elif name == 'testuser2':
return '[{"dn":"uid=testuser2,ou=People,dc=umich,dc=edu","naming":"testuser2","displayName":"Test Usersson Jr.","email":"testuser2@umich.edu","displayTitle":"Application Operations System Administrator Senior","title":["Application Operations System Administrator Senior"],"affiliation":["ITS Infra Sys Application Ops - Faculty and Staff","ITS Infrastrc - Systems - Faculty and Staff"],"description":null,"member":false,"owner":false,"moderator":false,"person":true,"group":false,"external":false,"securityEquals":null,"groupMembership":null,"role":null}]'
elif name =='testgroup':
return '[{"dn":"cn=testgroup,ou=User Groups,ou=Groups,dc=umich,dc=edu","naming":null,"displayName":"testgroup","email":null,"displayTitle":null,"title":null,"affiliation":null,"description":null,"member":false,"owner":false,"moderator":false,"person":false,"group":true,"external":false,"securityEquals":null,"groupMembership":null,"role":null}]'
elif name =='testgroup2':
return '[{"dn":"cn=testgroup2,ou=User Groups,ou=Groups,dc=umich,dc=edu","naming":null,"displayName":"testgroup2","email":null,"displayTitle":null,"title":null,"affiliation":null,"description":null,"member":false,"owner":false,"moderator":false,"person":false,"group":true,"external":false,"securityEquals":null,"groupMembership":null,"role":null}]'
else:
return {}
return get_testdata('find_both', name)
@app.route("/iamGroups/find/person/<uid>", methods=['GET'])
def get_user(uid):
return '{"dn":"uid=testuser,ou=People,dc=umich,dc=edu","naming":"testuser","displayName":"Test Usersson","email":"testuser@umich.edu","displayTitle":"Application Operations System Administrator Senior","title":["Application Operations System Administrator Senior"],"affiliation":["ITS Infra Sys Application Ops - Faculty and Staff","ITS Infrastrc - Systems - Faculty and Staff"],"description":null,"member":false,"owner":false,"moderator":false,"person":true,"group":false,"external":false,"securityEquals":null,"groupMembership":null,"role":null}'
return get_testdata('find_person', uid)
@app.route("/iamGroups/isValidName/<name>", methods=['GET'])
def is_valid_name(name):
......@@ -41,6 +48,7 @@ def is_valid_name(name):
else:
return '{"valid": "false"}'
@app.route("/inst/oauth2/token", methods=['POST'])
def return_token():
return '{"access_token": "a1b2c3d4c5d6e7f8g9h10i11j12k13l14"}'
......
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