Skip to content

Commit

Permalink
Coverage for multisig grant
Browse files Browse the repository at this point in the history
Signed-off-by: pfeairheller <[email protected]>
  • Loading branch information
pfeairheller committed Nov 29, 2023
1 parent d0df6e0 commit e5f14b2
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/keria/app/ipexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def on_post(req, rep, name):
case "/ipex/grant":
IpexGrantCollectionEnd.sendGrant(agent, hab, ked, sigs, rec)
case "/multisig/exn":
IpexGrantCollectionEnd.sendMultisigExn(agent, hab, ked, atc, rec)
IpexGrantCollectionEnd.sendMultisigExn(agent, hab, ked, sigs, atc, rec)

rep.status = falcon.HTTP_202
rep.data = json.dumps(ked).encode("utf-8")
Expand Down
53 changes: 53 additions & 0 deletions tests/app/test_ipexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,56 @@ def test_ipex_grant(helpers, mockHelpingNowIso8601, seeder):
res = client.simulate_post(path="/identifiers/legal-entity/ipex/grant", body=data)
assert res.status_code == 202
assert res.json == exn.ked
assert len(agent.exchanges) == 1
assert len(agent.grants) == 1

ims = eventing.messagize(serder=exn, sigers=[coring.Siger(qb64=sigs[0])])
# Test sending embedded admit in multisig/exn message
exn, end = exchanging.exchange(route="/multisig/exn",
payload=dict(),
sender=le['i'],
embeds=dict(exn=ims),
date=helping.nowIso8601())

# Bad recipient
body = dict(
exn=exn.ked,
sigs=sigs,
atc=dict(exn=end.decode("utf-8")),
rec=["EZ-i0d8JZAoTNZH3ULaU6JR2nmwyvYAfSVPzhzS6b5CM"]
)

data = json.dumps(body).encode("utf-8")
res = client.simulate_post(path="/identifiers/legal-entity/ipex/grant", body=data)
assert res.status_code == 400
assert res.json == {'description': 'attempt to send to unknown '
'AID=EZ-i0d8JZAoTNZH3ULaU6JR2nmwyvYAfSVPzhzS6b5CM',
'title': '400 Bad Request'}

# Bad attachments
body = dict(
exn=exn.ked,
sigs=sigs,
atc=dict(bad=end.decode("utf-8")),
rec=[pre1]
)

data = json.dumps(body).encode("utf-8")
res = client.simulate_post(path="/identifiers/legal-entity/ipex/grant", body=data)
assert res.status_code == 400
assert res.json == {'description': 'attachment missing for ACDC, unable to process request.',
'title': '400 Bad Request'}

body = dict(
exn=exn.ked,
sigs=sigs,
atc=dict(exn=end.decode("utf-8")),
rec=[pre1]
)

data = json.dumps(body).encode("utf-8")
res = client.simulate_post(path="/identifiers/legal-entity/ipex/grant", body=data)

assert res.status_code == 202
assert len(agent.exchanges) == 3
assert len(agent.grants) == 2

0 comments on commit e5f14b2

Please sign in to comment.