-
Notifications
You must be signed in to change notification settings - Fork 6
TestClient
Tom Mitchell edited this page Jun 10, 2015
·
1 revision
client.py is a python program that that constructs and sends properly formed Federation API requests to a service URL and receives and prints the result.
client.py takes "--method <method_name>" and "--url <service_url>" arguments to specify the API method name and URL of service provider.
In addition, because many Federation API calls take a list of credentials and a dictionary of options, client.py supports reading these arguments from files:
- options: from a JSON file with the argument --options_file
- credentials: wiht a list of comma-separated credential filenames Beyond that, all Federation API calls consist of sets of arguemnts of type URN, UID, STRING or INT which can be provided on the command line.
The simplest test is to run get_version
.
PYTHONPATH=/path/to/gcf/src python /path/to/client.py --cert fed-cert.pem --key fed-key.pem \
--url https://fedapi.example.com/MA --method=get_version
Results in output like (much elided):
CREDS = []
OPTIONS = {}
RESULT = { 'code': 0,
'output': '',
'value': { 'API_VERSIONS': { '2': 'https://ch-tm/MA/'},
'CREDENTIAL_TYPES': [ { 'type': 'geni_sfa',
'version': '3'},
{ 'type': 'geni_abac',
'version': '1'}],
'FIELDS': { '_GENI_MEMBER_DISPLAYNAME': { 'CREATE': 'ALLOWED',
'OBJECT': 'MEMBER',
'PROTECT': 'IDENTIFYING',
'TYPE': 'STRING',
'UPDATE': True},
'_GENI_MEMBER_PHONE_NUMBER': { 'CREATE': 'ALLOWED',
'OBJECT': 'MEMBER',
'PROTECT': 'IDENTIFYING',
'TYPE': 'STRING',
'UPDATE': True},
'_GENI_MEMBER_SSL_CERTIFICATE': { 'OBJECT': 'MEMBER',
'TYPE': 'CERTIFICATE'},
'_GENI_MEMBER_SSL_EXPIRATION': { 'OBJECT': 'MEMBER',
'TYPE': 'DATETIME'}},
'IMPLEMENTATION': { 'code_release_date': '2014-05-13 12:36:01.695184',
'code_url': 'http://trac.gpolab.bbn.com/chapi',
'code_version': '8328df7121daf4b77da9fd9f6a655874b2e6e1b8',
'site_update_date': '2014-05-13 12:36:01.695184'},
'SERVICES': ['MEMBER', 'KEY'],
'URN ': 'urn:publicid:IDN+ch-tm.gpolab.bbn.com+authority+ma',
'VERSION': '2'}}
File opts.json
:
{
"match": {"MEMBER_UID": ["41f3ba70-f066-4313-9c03-82928b99e430",
"a9d9d30a-0c41-4d9d-87f5-48863e5b5750"]},
"filter": ["_GENI_IDENTIFYING_MEMBER_UID"
]
}
Invocation:
PYTHONPATH=/usr/share/geni-ch/gcf/src python $HOME/chapi/tools/client.py --cert geni-tmitchel.pem --key geni-tmitchel.pem \
--url https://ch-tm/MA --method=lookup_identifying_member_info --options_file opts.json
Output:
CREDS = []
OPTIONS = {u'filter': [u'_GENI_IDENTIFYING_MEMBER_UID'], u'match': {u'MEMBER_UID': [u'41f3ba70-f066-4313-9c03-82928b99e430', u'a9d9d30a-0c41-4d9d-87f5-48863e5b5750']}}
RESULT = { 'code': 0,
'output': '',
'value': { 'urn:publicid:IDN+ch-tm.gpolab.bbn.com+user+ahelsing': { '_GENI_IDENTIFYING_MEMBER_UID': 'a9d9d30a-0c41-4d9d-87f5-48863e5b5750'},
'urn:publicid:IDN+ch-tm.gpolab.bbn.com+user+tmitchel': { '_GENI_IDENTIFYING_MEMBER_UID': '41f3ba70-f066-4313-9c03-82928b99e430'}}}