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

Goal and Goal Code in invitation URL. #2591

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 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