-
Notifications
You must be signed in to change notification settings - Fork 15
/
test_pack_plaintext.py
108 lines (86 loc) · 3.17 KB
/
test_pack_plaintext.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import pytest
from didcomm.core.serialization import json_str_to_dict
from didcomm.pack_plaintext import pack_plaintext
from didcomm.unpack import unpack
from tests.test_vectors.didcomm_messages.messages import (
TEST_MESSAGE,
attachment_json_msg,
attachment_links_msg,
attachment_base64_msg,
minimal_msg,
attachment_multi_1_msg,
attachment_multi_2_msg,
ack_msg,
custom_headers_msg,
)
from tests.test_vectors.didcomm_messages.spec.spec_test_vectors_plaintext import (
TEST_PLAINTEXT_DIDCOMM_MESSAGE_SIMPLE,
)
from tests.test_vectors.didcomm_messages.tests.test_vectors_plaintext_positive import (
TEST_PLAINTEXT_ATTACHMENT_BASE64,
TEST_PLAINTEXT_ATTACHMENT_LINKS,
TEST_PLAINTEXT_ATTACHMENT_JSON,
TEST_PLAINTEXT_ATTACHMENT_MULTI_1,
TEST_PLAINTEXT_ATTACHMENT_MULTI_2,
TEST_PLAINTEXT_DIDCOMM_MESSAGE_MINIMAL,
TEST_PLAINTEXT_ACKS,
TEST_PLAINTEXT_DIDCOMM_MESSAGE_WITH_CUSTOM_HEADERS,
)
async def check_pack_plaintext(message, expected_json, resolvers_config_bob):
pack_result = await pack_plaintext(resolvers_config_bob, message)
assert json_str_to_dict(pack_result.packed_msg) == json_str_to_dict(expected_json)
unpack_result = await unpack(resolvers_config_bob, pack_result.packed_msg)
assert unpack_result.message == message
@pytest.mark.asyncio
async def test_pack_simple_plaintext(resolvers_config_bob):
await check_pack_plaintext(
TEST_MESSAGE, TEST_PLAINTEXT_DIDCOMM_MESSAGE_SIMPLE, resolvers_config_bob
)
@pytest.mark.asyncio
async def test_pack_plaintext_with_custom_headers(resolvers_config_bob):
await check_pack_plaintext(
custom_headers_msg(),
TEST_PLAINTEXT_DIDCOMM_MESSAGE_WITH_CUSTOM_HEADERS,
resolvers_config_bob,
)
@pytest.mark.asyncio
async def test_pack_minimal_plaintext(resolvers_config_bob):
await check_pack_plaintext(
minimal_msg(), TEST_PLAINTEXT_DIDCOMM_MESSAGE_MINIMAL, resolvers_config_bob
)
@pytest.mark.asyncio
async def test_pack_attachments_base64(resolvers_config_bob):
await check_pack_plaintext(
attachment_base64_msg(), TEST_PLAINTEXT_ATTACHMENT_BASE64, resolvers_config_bob
)
@pytest.mark.asyncio
async def test_pack_attachments_links(resolvers_config_bob):
await check_pack_plaintext(
attachment_links_msg(), TEST_PLAINTEXT_ATTACHMENT_LINKS, resolvers_config_bob
)
@pytest.mark.asyncio
async def test_pack_attachments_json(resolvers_config_bob):
await check_pack_plaintext(
attachment_json_msg(), TEST_PLAINTEXT_ATTACHMENT_JSON, resolvers_config_bob
)
@pytest.mark.asyncio
async def test_pack_attachments_multi1(resolvers_config_bob):
await check_pack_plaintext(
attachment_multi_1_msg(),
TEST_PLAINTEXT_ATTACHMENT_MULTI_1,
resolvers_config_bob,
)
@pytest.mark.asyncio
async def test_pack_attachments_multi2(resolvers_config_bob):
await check_pack_plaintext(
attachment_multi_2_msg(),
TEST_PLAINTEXT_ATTACHMENT_MULTI_2,
resolvers_config_bob,
)
@pytest.mark.asyncio
async def test_pack_acks(resolvers_config_bob):
await check_pack_plaintext(
ack_msg(),
TEST_PLAINTEXT_ACKS,
resolvers_config_bob,
)