Skip to content

Commit

Permalink
Merge pull request #2591 from usingtechnology/issue-2583-oob-goal-code
Browse files Browse the repository at this point in the history
Goal and Goal Code in invitation URL.
  • Loading branch information
swcurran authored Nov 2, 2023
2 parents db50c10 + d85035d commit 85475e1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aries_cloudagent/protocols/out_of_band/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,12 @@ async def create_invitation(
routing_keys=routing_keys,
)
]
invi_url = invi_msg.to_url()
if goal and goal_code:
invi_msg.goal_code = goal_code
invi_msg.goal = goal

invi_url = invi_msg.to_url()

# Update connection record
if conn_rec:
async with self.profile.session() as session:
Expand Down
45 changes: 45 additions & 0 deletions aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Test OOB Manager."""

import base64
import json
from copy import deepcopy
from datetime import datetime, timedelta, timezone
Expand Down Expand Up @@ -850,6 +851,50 @@ async def test_create_invitation_x_public_metadata(self):
context.exception
)

async def test_create_invitation_goal_code(self):
self.profile.context.update_settings({"public_invites": True})
with mock.patch.object(
InMemoryWallet, "get_public_did", autospec=True
) as mock_wallet_get_public_did:
mock_wallet_get_public_did.return_value = DIDInfo(
TestConfig.test_did,
TestConfig.test_verkey,
None,
method=SOV,
key_type=ED25519,
)
goal = "To issue a Faber College Graduate credential"
goal_code = "issue-vc"
my_label = "Invitation to Barry"

invi_rec = await self.manager.create_invitation(
public=False,
my_label=my_label,
protocol_version="1.1",
alias="Test Alias",
service_accept=["didcomm/aip1", "didcomm/aip2;env=rfc19"],
hs_protos=[test_module.HSProto.RFC23],
goal=goal,
goal_code=goal_code,
)
assert isinstance(invi_rec, InvitationRecord)
assert invi_rec.invitation.handshake_protocols
assert invi_rec.invitation.label == my_label
assert invi_rec.invitation.goal == goal
assert invi_rec.invitation.goal_code == goal_code
assert invi_rec.invitation_url

base64_message = invi_rec.invitation_url.split("=", maxsplit=1)[1]
base64_bytes = base64_message.encode("ascii")
message_bytes = base64.b64decode(base64_bytes)
data = message_bytes.decode("ascii")
assert data
invite_json = json.loads(data)
assert invite_json
assert invite_json["label"] == my_label
assert invite_json["goal"] == goal
assert invite_json["goal_code"] == goal_code

async def test_wait_for_conn_rec_active_retrieve_by_id(self):
with mock.patch.object(
ConnRecord,
Expand Down

0 comments on commit 85475e1

Please sign in to comment.