XSEDE / amieclient

It's a python library for the AMIE REST API. (I'm not shouting at you, it's just a lot of acronyms all in a row.)
Apache License 2.0
0 stars 5 forks source link

The library is munging certain requests #8

Closed phpHavok closed 3 years ago

phpHavok commented 3 years ago

The library mysteriously appears to munge certain requests. As a concrete example, we generated a request_person_merge scenario. The two RACs that come in as a result have different usernames, as can be verified by a raw CURL request to the AMIE endpoint (see below).

$ curl \
-i \
-H "XA-Site: $site_name" \
-H "XA-API-Key: $api_key" \
-X GET \
"$amie_url/packets/$site_name"

HTTP/1.1 200 OK
Date: Thu, 11 Feb 2021 17:57:29 GMT
Server: Apache
[... snipped ...]
Status: 200 OK

{"message":null,"result":[{"DATA_TYPE":"Packet","type":"data_project_create","header":{"expected_reply_list":[{"type":"inform_transaction_complete","timeout":30240}],"packet_id":2,"trans_rec_id":87665259,"transaction_id":23,"remote_site_name":"UKY","local_site_name":"TGCDB","originating_site_name":"TGCDB","outgoing_flag":1,"packet_rec_id":175767215,"client_state":null,"packet_state":"in-progress","client_json":null,"transaction_state":"in-progress"},"body":{"DnList":["/C=US/O=National Center for Supercomputing Applications/CN=adiba zahin","/C=US/O=Pittsburgh Supercomputing Center/CN=adiba zahin","/DC=EDU/DC=UTEXAS/DC=TACC/O=MYPROXY/CN=tg828139"],"ProjectID":"7","PersonID":"11","GlobalID":"32671"}},{"DATA_TYPE":"Packet","type":"request_account_create","header":{"expected_reply_list":[{"type":"notify_account_create","timeout":30240}],"packet_id":1,"trans_rec_id":87665260,"transaction_id":24,"remote_site_name":"UKY","local_site_name":"TGCDB","originating_site_name":"TGCDB","outgoing_flag":1,"packet_rec_id":175767216,"client_state":null,"packet_state":"in-progress","client_json":null,"transaction_state":"in-progress"},"body":{"ProjectID":"7","GrantNumber":"CHM213889","UserPasswordAccessEnable":"1","ResourceList":["test-resource1.uky.xsede"],"UserRequestedLoginList":[""],"AllocatedResource":"test-resource1.uky.xsede","UserGlobalID":"52766","UserBusinessPhoneNumber":"8087728977","UserEmail":"joshuair@hawaii.edu","UserCity":"Honolulu","UserStreetAddress":"2540 Dole Street, Holmes Hall 383","UserZip":"96822","UserState":"HI","UserCountry":"9US","UserFirstName":"Joshua Lelemia","UserMiddleName":"","UserLastName":"Irvine","UserDepartment":"Civil and Environmental Engineering","UserTitle":"","UserOrganization":"University of Hawaii, Manoa","UserOrgCode":"0016105","NsfStatusCode":"GS","UserDnList":["/C=US/O=National Center for Supercomputing Applications/CN=Joshua Lelemia Irvine","/C=US/O=Pittsburgh Supercomputing Center/CN=Joshua Lelemia Irvine","/DC=EDU/DC=UTEXAS/DC=TACC/O=MYPROXY/CN=jirvine"],"SitePersonId":[{"Site":"XD-ALLOCATIONS","PersonID":"lelemia"},{"Site":"TACC","PersonID":"843580"},{"Site":"X-PORTAL","PersonID":"lelemia"}],"AcademicDegree":[{"Degree":"PhD","Field":"Civil and Environmental Engineering"}]}},{"DATA_TYPE":"Packet","type":"request_account_create","header":{"expected_reply_list":[{"type":"notify_account_create","timeout":30240}],"packet_id":1,"trans_rec_id":87665261,"transaction_id":25,"remote_site_name":"UKY","local_site_name":"TGCDB","originating_site_name":"TGCDB","outgoing_flag":1,"packet_rec_id":175767217,"client_state":null,"packet_state":"in-progress","client_json":null,"transaction_state":"in-progress"},"body":{"ProjectID":"7","GrantNumber":"CHM213889","UserPasswordAccessEnable":"1","ResourceList":["test-resource1.uky.xsede"],"AllocatedResource":"test-resource1.uky.xsede","UserGlobalID":"91192","UserFirstName":"Joshua Lelemia","UserMiddleName":"","UserLastName":"Irvine","UserDepartment":"Civil and Environmental Engineering","UserTitle":"","UserOrganization":"University of Hawaii, Manoa","UserOrgCode":"0016105","NsfStatusCode":"GS","UserDnList":["/C=US/O=National Center for Supercomputing Applications/CN=Joshua Lelemia Irvine 1","/C=US/O=Pittsburgh Supercomputing Center/CN=Joshua Lelemia Irvine 1"],"SitePersonId":[{"Site":"XD-ALLOCATIONS","PersonID":"lelemia428"}]}}]}

RELEVANT JSON:
{"Site":"XD-ALLOCATIONS","PersonID":"lelemia"}
VERSUS
{"Site":"XD-ALLOCATIONS","PersonID":"lelemia428"}]}

However, when processing these packets through list_packets(), they are munged and share the same PersonID as well as some other fields.

PACKET:
('{"DATA_TYPE": "packet", "type": "request_account_create", "body": '
 '{"GrantNumber": "CHM213889", "ResourceList": ["test-resource1.uky.xsede"], '
 '"UserFirstName": "Joshua Lelemia", "UserLastName": "Irvine", '
 '"UserOrganization": "University of Hawaii, Manoa", "UserOrgCode": "0016105", '
 '"ProjectID": "7", "UserPasswordAccessEnable": "1", "UserRequestedLoginList": '
 '[""], "AllocatedResource": "test-resource1.uky.xsede", "UserGlobalID": '
 '"91192", "UserBusinessPhoneNumber": "8087728977", "UserEmail": '
 '"joshuair@hawaii.edu", "UserCity": "Honolulu", "UserStreetAddress": "2540 '
 'Dole Street, Holmes Hall 383", "UserZip": "96822", "UserState": "HI", '
 '"UserCountry": "9US", "UserMiddleName": "", "UserDepartment": "Civil and '
 'Environmental Engineering", "UserTitle": "", "NsfStatusCode": "GS", '
 '"UserDnList": ["/C=US/O=National Center for Supercomputing '
 'Applications/CN=Joshua Lelemia Irvine 1", "/C=US/O=Pittsburgh Supercomputing '
 'Center/CN=Joshua Lelemia Irvine 1"], "SitePersonId": [{"Site": '
 '"XD-ALLOCATIONS", "PersonID": "lelemia428"}], "AcademicDegree": [{"Degree": '
 '"PhD", "Field": "Civil and Environmental Engineering"}], "GlobalID": '
 '"32671"}, "header": {"packet_rec_id": 175767216, "packet_id": 1, '
 '"transaction_id": 175767216, "trans_rec_id": 87665260, '
 '"expected_reply_list": ["notify_account_create"], "local_site_name": '
 '"TGCDB", "remote_site_name": "UKY", "originating_site_name": "TGCDB", '
 '"outgoing_flag": "1", "transaction_state": "in-progress", "packet_state": '
 '"in-progress"}}')

 PACKET:
('{"DATA_TYPE": "packet", "type": "request_account_create", "body": '
 '{"GrantNumber": "CHM213889", "ResourceList": ["test-resource1.uky.xsede"], '
 '"UserFirstName": "Joshua Lelemia", "UserLastName": "Irvine", '
 '"UserOrganization": "University of Hawaii, Manoa", "UserOrgCode": "0016105", '
 '"ProjectID": "7", "UserPasswordAccessEnable": "1", "UserRequestedLoginList": '
 '[""], "AllocatedResource": "test-resource1.uky.xsede", "UserGlobalID": '
 '"91192", "UserBusinessPhoneNumber": "8087728977", "UserEmail": '
 '"joshuair@hawaii.edu", "UserCity": "Honolulu", "UserStreetAddress": "2540 '
 'Dole Street, Holmes Hall 383", "UserZip": "96822", "UserState": "HI", '
 '"UserCountry": "9US", "UserMiddleName": "", "UserDepartment": "Civil and '
 'Environmental Engineering", "UserTitle": "", "NsfStatusCode": "GS", '
 '"UserDnList": ["/C=US/O=National Center for Supercomputing '
 'Applications/CN=Joshua Lelemia Irvine 1", "/C=US/O=Pittsburgh Supercomputing '
 'Center/CN=Joshua Lelemia Irvine 1"], "SitePersonId": [{"Site": '
 '"XD-ALLOCATIONS", "PersonID": "lelemia428"}], "AcademicDegree": [{"Degree": '
 '"PhD", "Field": "Civil and Environmental Engineering"}], "GlobalID": '
 '"32671"}, "header": {"packet_rec_id": 175767217, "packet_id": 1, '
 '"transaction_id": 175767217, "trans_rec_id": 87665261, '
 '"expected_reply_list": ["notify_account_create"], "local_site_name": '
 '"TGCDB", "remote_site_name": "UKY", "originating_site_name": "TGCDB", '
 '"outgoing_flag": "1", "transaction_state": "in-progress", "packet_state": '
 '"in-progress"}}')
sabo commented 3 years ago

Hi, try the latest commit on the main branch. I was setting up the dictionaries that hold the data for the required and allowed fields incorrectly. As originally written they were shared between all packets with the same packet type :facepalm: If it works, let me know, but please keep the ticket open until I can get around to writing a regression test.

phpHavok commented 3 years ago

Your latest change in master seems to have fixed it, thanks! I'll leave this issue open as you requested pending the regression tests.