Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update exchanges GET API to account for new endpoint URL. #99

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/issue-ecr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ kli saidify --file /tmp/ecr-edges.json
kli vc create --name qvi --alias qvi --private --registry-name vLEI-qvi --schema EEy9PkikFcANV1l7EHukCeXqrzT1hNZjGlUk7wuMO5jw --recipient EBcIURLpxmVwahksgrsGW6_dUw0zBhyEHYFk17eWrZfk --data @"${KERI_DEMO_SCRIPT_DIR}"/data/ecr-data.json --edges @/tmp/ecr-edges.json --rules @"${KERI_DEMO_SCRIPT_DIR}"/data/ecr-rules.json
SAID=$(kli vc list --name qvi --alias qvi --issued --said --schema EEy9PkikFcANV1l7EHukCeXqrzT1hNZjGlUk7wuMO5jw)
kli ipex grant --name qvi --alias qvi --said "${SAID}" --recipient EBcIURLpxmVwahksgrsGW6_dUw0zBhyEHYFk17eWrZfk
kli ipex list --name qvi --alias qvi --poll

kli ipex list --name qvi --alias qvi
GRANT=$(python "${KERI_SCRIPT_DIR}"/list_ipex.py)
echo "Sending admit with ${GRANT}"
python "${KERI_SCRIPT_DIR}"/send_admit.py "${GRANT}" EHMnCf8_nIemuPx-cUHaDQq8zSnQIFAurdEpwHpNbnvX
kli ipex list --name qvi --alias qvi --poll
python "${KERI_SCRIPT_DIR}"/list_person_credentials.py
2 changes: 1 addition & 1 deletion scripts/join_new_quadlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def accept_join_request(client, name, group):
if route == "/multisig/rot":
said = payload['d']

res = exchanges.get(name=name, said=said)
res = exchanges.get(said=said)
exn = res['exn']
a = exn['a']

Expand Down
2 changes: 1 addition & 1 deletion scripts/multisig-holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def create_admit(client, participant, group, said, recp):
exchanges = client.exchanges()
ipex = client.ipex()

res = exchanges.get(participant, said)
res = exchanges.get(said)
grant = coring.Serder(ked=res['exn'])
ghab = get_aid(client, group)
mhab = get_aid(client, participant)
Expand Down
3 changes: 3 additions & 0 deletions src/signify/app/credentialing.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ def grant(self, hab, recp, message, acdc, iss, anc, agree=None, dt=None):
return grant, gsigs, end

def admit(self, hab, message, grant, dt=None):
if not grant:
raise ValueError(f"invalid grant={grant}")

exchanges = self.client.exchanges()
data = dict(
m=message,
Expand Down
7 changes: 3 additions & 4 deletions src/signify/peer/exchanging.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,16 @@ def sendFromEvents(self, name, topic, exn, sigs, atc, recipients):
res = self.client.post(f"/identifiers/{name}/exchanges", json=body)
return res.json()

def get(self, name, said):
def get(self, said):
"""

Parameters:
name (str): human readable identifier alias to send from
said (str): qb64 SAID of the exn message to retrieve

Returns:
dict: exn message

"""

res = self.client.get(f"/identifiers/{name}/exchanges/{said}")
return res.json()
res = self.client.get(f"/exchanges/{said}")
return res.json()
4 changes: 2 additions & 2 deletions tests/peer/test_exchanging.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def test_exchanges_get(mockHelpingNowIso8601):
from requests import Response
mock_response = mock({'content': 'things I found'}, spec=Response, strict=True)
expect(mock_response, times=1).json().thenReturn({'content': 'an exn'})
expect(mock_client, times=1).get("/identifiers/aid1/exchanges/EEE",).thenReturn(mock_response)
expect(mock_client, times=1).get("/exchanges/EEE",).thenReturn(mock_response)

from signify.peer.exchanging import Exchanges
out = Exchanges(client=mock_client).get('aid1', 'EEE') # type: ignore
out = Exchanges(client=mock_client).get('EEE') # type: ignore

assert out == {'content': 'an exn'}

Expand Down
Loading