|
70 | 70 |
|
71 | 71 | pytest.not_json = 123456
|
72 | 72 |
|
| 73 | +pytest.self_attested_attrs_json = json.dumps({ |
| 74 | + "auto_present": "false", |
| 75 | + "connection_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 76 | + "created_at": "2021-04-08 09:04:01Z", |
| 77 | + "error_msg": "Invalid structure", |
| 78 | + "initiator": "self", |
| 79 | + "presentation": { |
| 80 | + "requested_proof": { |
| 81 | + "self_attested_attrs": { |
| 82 | + "item1": {'raw': "sth"}, |
| 83 | + "item2": {'raw': "sth"}, |
| 84 | + "item3": {'raw': "sth"}, |
| 85 | + }, |
| 86 | + }, |
| 87 | + }, |
| 88 | + "presentation_exchange_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 89 | + "presentation_proposal_dict": {}, |
| 90 | + "presentation_request": {}, |
| 91 | + "presentation_request_dict": {}, |
| 92 | + "role": "prover", |
| 93 | + "state": "verified", |
| 94 | + "thread_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 95 | + "trace": "true", |
| 96 | + "updated_at": "2021-04-08 09:04:01Z", |
| 97 | + "verified": "true" |
| 98 | + }) |
| 99 | + |
| 100 | +pytest.revealed_attrs_json = json.dumps({ |
| 101 | + "auto_present": "false", |
| 102 | + "connection_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 103 | + "created_at": "2021-04-08 09:04:01Z", |
| 104 | + "error_msg": "Invalid structure", |
| 105 | + "initiator": "self", |
| 106 | + "presentation": { |
| 107 | + "requested_proof": { |
| 108 | + "revealed_attrs": { |
| 109 | + "item1": {'raw': "sth"}, |
| 110 | + "item2": {'raw': "sth"}, |
| 111 | + "item3": {'raw': "sth"}, |
| 112 | + }, |
| 113 | + }, |
| 114 | + }, |
| 115 | + "presentation_exchange_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 116 | + "presentation_proposal_dict": {}, |
| 117 | + "presentation_request": {}, |
| 118 | + "presentation_request_dict": {}, |
| 119 | + "role": "prover", |
| 120 | + "state": "verified", |
| 121 | + "thread_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 122 | + "trace": "true", |
| 123 | + "updated_at": "2021-04-08 09:04:01Z", |
| 124 | + "verified": "true" |
| 125 | + }) |
| 126 | + |
| 127 | +pytest.unrevealed_attrs_json = json.dumps({ |
| 128 | + "auto_present": "false", |
| 129 | + "connection_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 130 | + "created_at": "2021-04-08 09:04:01Z", |
| 131 | + "error_msg": "Invalid structure", |
| 132 | + "initiator": "self", |
| 133 | + "presentation": { |
| 134 | + "requested_proof": { |
| 135 | + "unrevealed_attrs": { |
| 136 | + "item1": {'raw': "sth"}, |
| 137 | + "item2": {'raw': "sth"}, |
| 138 | + "item3": {'raw': "sth"}, |
| 139 | + }, |
| 140 | + }, |
| 141 | + }, |
| 142 | + "presentation_exchange_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 143 | + "presentation_proposal_dict": {}, |
| 144 | + "presentation_request": {}, |
| 145 | + "presentation_request_dict": {}, |
| 146 | + "role": "prover", |
| 147 | + "state": "verified", |
| 148 | + "thread_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 149 | + "trace": "true", |
| 150 | + "updated_at": "2021-04-08 09:04:01Z", |
| 151 | + "verified": "true" |
| 152 | + }) |
| 153 | + |
| 154 | +pytest.predicates_attrs_json = json.dumps({ |
| 155 | + "auto_present": "false", |
| 156 | + "connection_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 157 | + "created_at": "2021-04-08 09:04:01Z", |
| 158 | + "error_msg": "Invalid structure", |
| 159 | + "initiator": "self", |
| 160 | + "presentation": { |
| 161 | + "requested_proof": { |
| 162 | + "predicates": { |
| 163 | + "item1": {'raw': "sth"}, |
| 164 | + "item2": {'raw': "sth"}, |
| 165 | + "item3": {'raw': "sth"}, |
| 166 | + }, |
| 167 | + }, |
| 168 | + }, |
| 169 | + "presentation_exchange_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 170 | + "presentation_proposal_dict": {}, |
| 171 | + "presentation_request": {}, |
| 172 | + "presentation_request_dict": {}, |
| 173 | + "role": "prover", |
| 174 | + "state": "verified", |
| 175 | + "thread_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 176 | + "trace": "true", |
| 177 | + "updated_at": "2021-04-08 09:04:01Z", |
| 178 | + "verified": "true" |
| 179 | + }) |
| 180 | + |
| 181 | +pytest.identifiers_json = json.dumps({ |
| 182 | + "auto_present": "false", |
| 183 | + "connection_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 184 | + "created_at": "2021-04-08 09:04:01Z", |
| 185 | + "error_msg": "Invalid structure", |
| 186 | + "initiator": "self", |
| 187 | + "presentation": { |
| 188 | + "identifiers": [{ |
| 189 | + "rev_reg_id": "123456789", |
| 190 | + "cred_def_id": "123456789", |
| 191 | + "schema_id": "123456789" |
| 192 | + }, |
| 193 | + { |
| 194 | + "rev_reg_id": "987654321", |
| 195 | + "cred_def_id": "987654321", |
| 196 | + "schema_id": "987654321" |
| 197 | + }] |
| 198 | + }, |
| 199 | + "presentation_exchange_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 200 | + "presentation_proposal_dict": {}, |
| 201 | + "presentation_request": {}, |
| 202 | + "presentation_request_dict": {}, |
| 203 | + "role": "prover", |
| 204 | + "state": "verified", |
| 205 | + "thread_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", |
| 206 | + "trace": "true", |
| 207 | + "updated_at": "2021-04-08 09:04:01Z", |
| 208 | + "verified": "true" |
| 209 | + }) |
73 | 210 |
|
74 | 211 | def test_init_valid():
|
75 | 212 | pres = Presentation(pytest.valid_presentation)
|
@@ -114,3 +251,113 @@ def test_has_no_identifiers(caplog):
|
114 | 251 | match=error_msg):
|
115 | 252 | Presentation(pytest.valid_presentation).get_cred_def_ids()
|
116 | 253 | assert error_msg in caplog.text
|
| 254 | + |
| 255 | + |
| 256 | +def test_get_role(): |
| 257 | + expected = "prover" |
| 258 | + result = Presentation(pytest.valid_presentation).get_role() |
| 259 | + assert result == expected |
| 260 | + |
| 261 | + |
| 262 | +def test_get_threadid(): |
| 263 | + expected = "3fa85f64-5717-4562-b3fc-2c963f66afa6" |
| 264 | + result = Presentation(pytest.valid_presentation).get_threadid() |
| 265 | + assert result == expected |
| 266 | + |
| 267 | + |
| 268 | +def test_get_presentation_request(): |
| 269 | + expected = {} |
| 270 | + result = Presentation(pytest.valid_presentation).get_presentation_request() |
| 271 | + assert result == expected |
| 272 | + |
| 273 | + |
| 274 | +def test_get_verified_state(): |
| 275 | + expected = "verified" |
| 276 | + result = Presentation(pytest.valid_presentation).get_verified_state() |
| 277 | + assert result == expected |
| 278 | + |
| 279 | + |
| 280 | +def test_get_presxid(): |
| 281 | + expected = "3fa85f64-5717-4562-b3fc-2c963f66afa6" |
| 282 | + result = Presentation(pytest.valid_presentation).get_presxid() |
| 283 | + assert result == expected |
| 284 | + |
| 285 | + |
| 286 | +def test_get_from_conn_id(): |
| 287 | + expected = "3fa85f64-5717-4562-b3fc-2c963f66afa6" |
| 288 | + result = Presentation(pytest.valid_presentation).get_from_conn_id() |
| 289 | + assert result == expected |
| 290 | + |
| 291 | + |
| 292 | +def test_get_rev_reg_ids(): |
| 293 | + expected = '{"rev_reg_id": ["123456789", "987654321"]}' |
| 294 | + result = Presentation(pytest.identifiers_json).get_rev_reg_ids() |
| 295 | + assert result == expected |
| 296 | + |
| 297 | + |
| 298 | +def test_get_cred_def_ids(): |
| 299 | + expected = '{"cred_def_id": ["123456789", "987654321"]}' |
| 300 | + result = Presentation(pytest.identifiers_json).get_cred_def_ids() |
| 301 | + assert result == expected |
| 302 | + |
| 303 | + |
| 304 | +def test_get_schemas(): |
| 305 | + expected = '{"schema_id": ["123456789", "987654321"]}' |
| 306 | + result = Presentation(pytest.identifiers_json).get_schemas() |
| 307 | + assert result == expected |
| 308 | + |
| 309 | + |
| 310 | +def test_get_identifiers(): |
| 311 | + expected = json.dumps({'identifiers': [{ |
| 312 | + 'rev_reg_id': '123456789', |
| 313 | + 'cred_def_id': '123456789', |
| 314 | + 'schema_id': '123456789' |
| 315 | + }, |
| 316 | + { |
| 317 | + 'rev_reg_id': '987654321', |
| 318 | + 'cred_def_id': '987654321', |
| 319 | + 'schema_id': '987654321' |
| 320 | + }] |
| 321 | + }) |
| 322 | + result = Presentation(pytest.identifiers_json).get_identifiers() |
| 323 | + assert result == expected |
| 324 | + |
| 325 | + |
| 326 | +def test_get_predicates(): |
| 327 | + expected = json.dumps({ |
| 328 | + "item1": "sth", |
| 329 | + "item2": "sth", |
| 330 | + "item3": "sth", |
| 331 | + }) |
| 332 | + result = Presentation(pytest.predicates_attrs_json).get_predicates() |
| 333 | + assert expected == result |
| 334 | + |
| 335 | + |
| 336 | +def test_get_unrevealed_attrs(): |
| 337 | + expected = json.dumps({ |
| 338 | + "item1": "sth", |
| 339 | + "item2": "sth", |
| 340 | + "item3": "sth", |
| 341 | + }) |
| 342 | + result = Presentation(pytest.unrevealed_attrs_json).get_unrevealed_attrs() |
| 343 | + assert expected == result |
| 344 | + |
| 345 | + |
| 346 | +def test_get_revealed_attrs(): |
| 347 | + expected = json.dumps({ |
| 348 | + "item1": "sth", |
| 349 | + "item2": "sth", |
| 350 | + "item3": "sth", |
| 351 | + }) |
| 352 | + result = Presentation(pytest.revealed_attrs_json).get_revealed_attrs() |
| 353 | + assert expected == result |
| 354 | + |
| 355 | + |
| 356 | +def test_get_self_attested(): |
| 357 | + expected = json.dumps({ |
| 358 | + "item1": "sth", |
| 359 | + "item2": "sth", |
| 360 | + "item3": "sth", |
| 361 | + }) |
| 362 | + result = Presentation(pytest.self_attested_attrs_json).get_self_attested_attrs() |
| 363 | + assert expected == result |
0 commit comments