Skip to content

Commit

Permalink
test: retrieve conn by did-peer-4
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
  • Loading branch information
dbluhm committed Jul 22, 2024
1 parent 98f93b3 commit 029eefa
Showing 1 changed file with 77 additions and 9 deletions.
86 changes: 77 additions & 9 deletions aries_cloudagent/connections/models/tests/test_conn_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ def setUp(self):
self.test_target_did = "GbuDUYXaUZRfHD2jeDuQuP"
self.test_target_verkey = "9WCgWKUaAJj3VWxxtzvvMQN3AoFxoBtBDo9ntwJnVVCC"

self.test_did_peer_4_a = "did:peer:4zQmV3Hf1TT4Xn73MBVf2NAWdMwrzUabpEvwtV3RoZc17Vxr:z2pfttj3xn6tJ7wpHV9ZSwpQVMNtHC7EtM36r1mC5fDpZ25882Yitk21QPbqzuefKPrbFsexWmQtE78vYWweckXtKeu5BhuFDvCjMUf8SC5z7cMPvp8SCdcbqWnHxygjBH9zAAs9myGRnZYXuAkq6CfBdn6ZiNmdRf65TdVfE3cYfS4jNzVZDs1abwytn4jdFJ2fwVegPB3vLY8XxeUEx12a4rtjkqMhs6zBQbJvc4PVUM9rvMbPM2QeXDy7ovkkHaKLUbNUxjQrcQeiR8MTLe1iaVtUv6RpBf4z7ioqfa4VDRmAZT7isVM3NvENUceeUfDZoFbM8PZqGkCbFvfoKiK3SrmTsvPtpXaBAfR4z7w18cFjsvvLBNMZbPnARn4oZijCkYwgaNmAUthgDP4XBFetdUo8728w25FUwTWjAPc1BdSSWPWMRKwCqyAP1Q1hM8dU6otT27MQaQ1rozKncn3U48CXEi2Ef26EDBrSozEWR273ancFojNXBbZVghZG5b6xdypjQir9PgTF94dsygtu47hNxQweVKLUM1p9umqHLhjvLhpS1aGQkGZNnKUHjLDHdToigo15F7TAf8RfMaducHBThFzEp9TUJmiZFTUYQ1uaBgSPMSaWnvTfUoFmLoGbdrWj1vVEsRrARq37u1SJGLqBx7FM2SUd8n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6rU9ZYttNHbDJFgahwB8KisVBK8FBpG"
self.test_did_peer_4_short_b = (
"did:peer:4zQmQ4dEtoGcivpiH6gtWwhWJY2ENVWuZifb62uzR76HGPPw"
)

self.test_conn_record = ConnRecord(
my_did=self.test_did,
their_did=self.test_target_did,
Expand All @@ -39,9 +48,7 @@ async def test_get_enums(self):
assert ConnRecord.Role.get("Larry") is None
assert ConnRecord.State.get("a suffusion of yellow") is None

assert (
ConnRecord.Role.get(ConnRecord.Role.REQUESTER) is ConnRecord.Role.REQUESTER
)
assert ConnRecord.Role.get(ConnRecord.Role.REQUESTER) is ConnRecord.Role.REQUESTER

assert (
ConnRecord.State.get(ConnRecord.State.RESPONSE) is ConnRecord.State.RESPONSE
Expand Down Expand Up @@ -133,6 +140,71 @@ async def test_retrieve_by_did(self):
)
assert result == record

async def test_retrieve_by_did_peer_4_by_long(self):
record = ConnRecord(
my_did=self.test_did,
their_did=self.test_did_peer_4_a,
their_role=ConnRecord.Role.RESPONDER.rfc23,
state=ConnRecord.State.COMPLETED.rfc23,
)
rec_id = await record.save(self.session)
result = await ConnRecord.retrieve_by_did_peer_4(
session=self.session,
my_did=self.test_did,
their_did_long=self.test_did_peer_4_a,
their_role=ConnRecord.Role.RESPONDER.rfc160,
)
assert result == record

async def test_retrieve_by_did_peer_4_by_short(self):
record = ConnRecord(
my_did=self.test_did,
their_did=self.test_did_peer_4_short_b,
their_role=ConnRecord.Role.RESPONDER.rfc23,
state=ConnRecord.State.COMPLETED.rfc23,
)
await record.save(self.session)
result = await ConnRecord.retrieve_by_did_peer_4(
session=self.session,
my_did=self.test_did,
their_did_short=self.test_did_peer_4_short_b,
their_role=ConnRecord.Role.RESPONDER.rfc160,
)
assert result == record

async def test_retrieve_by_did_peer_4_by_either(self):
record_short = ConnRecord(
my_did=self.test_did,
their_did=self.test_did_peer_4_short_a,
their_role=ConnRecord.Role.RESPONDER.rfc23,
state=ConnRecord.State.COMPLETED.rfc23,
)
await record_short.save(self.session)
record_long = ConnRecord(
my_did=self.test_did,
their_did=self.test_did_peer_4_b,
their_role=ConnRecord.Role.RESPONDER.rfc23,
state=ConnRecord.State.COMPLETED.rfc23,
)
await record_long.save(self.session)

result = await ConnRecord.retrieve_by_did_peer_4(
session=self.session,
my_did=self.test_did,
their_did_short=self.test_did_peer_4_short_a,
their_did_long=self.test_did_peer_4_a,
their_role=ConnRecord.Role.RESPONDER.rfc160,
)
assert result == record_short
result = await ConnRecord.retrieve_by_did_peer_4(
session=self.session,
my_did=self.test_did,
their_did_short=self.test_did_peer_4_short_b,
their_did_long=self.test_did_peer_4_b,
their_role=ConnRecord.Role.RESPONDER.rfc160,
)
assert result == record_long

async def test_from_storage_with_initiator_old(self):
record = ConnRecord(my_did=self.test_did, state=ConnRecord.State.COMPLETED)
ser = record.serialize()
Expand Down Expand Up @@ -300,9 +372,7 @@ async def test_attach_retrieve_request(self):
connection_id = await record.save(self.session)

req = ConnectionRequest(
connection=ConnectionDetail(
did=self.test_did, did_doc=DIDDoc(self.test_did)
),
connection=ConnectionDetail(did=self.test_did, did_doc=DIDDoc(self.test_did)),
label="abc123",
)
await record.attach_request(self.session, req)
Expand All @@ -317,9 +387,7 @@ async def test_attach_request_abstain_on_alien_deco(self):
connection_id = await record.save(self.session)

req = ConnectionRequest(
connection=ConnectionDetail(
did=self.test_did, did_doc=DIDDoc(self.test_did)
),
connection=ConnectionDetail(did=self.test_did, did_doc=DIDDoc(self.test_did)),
label="abc123",
)
ser = req.serialize()
Expand Down

0 comments on commit 029eefa

Please sign in to comment.