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

🎨 Replace SseListeners used in app #700

Merged
merged 33 commits into from
Mar 22, 2024
Merged

Conversation

ff137
Copy link
Collaborator

@ff137 ff137 commented Mar 19, 2024

The cloudapi app logic should not need to listen for SSE events. All records can be queried from ACA-Py directly.
So, this PR replaces the few remaining cases of waiting for SSE events to instead query connection/transaction records as needed.

This removes a manual endorsement call in the issuer onboarding process, and adds an additional case to the endorser such that ATTRIB transaction types are now also automatically endorsed.

Copy link

Coverage

Coverage Report
FileStmtsMissCoverMissing
app
   main.py802668%73–76, 100, 102, 104, 108, 115, 141–146, 151–181
app/dependencies
   acapy_clients.py24292%36, 52
   auth.py561966%31, 37–38, 41, 52–55, 62–63, 68, 74–79, 83–86, 90–91, 96
   role.py34197%56
app/exceptions
   handle_acapy_call.py241633%40–68
app/models
   issuer.py47296%34, 43
   tenants.py751580%93, 96, 105–115, 122, 125, 144–152
   verifier.py54885%30, 38–42, 79, 87–91
app/routes
   connections.py603935%26–42, 58–70, 84–100, 116–130, 149–160
   definitions.py1889251%72–129, 162–163, 230–246, 259–265, 281–290, 313–314, 331–333, 368–416, 440–441, 480–550, 558–577
   issuer.py1733878%66, 97, 129–131, 164, 194–196, 204, 221, 320–330, 361–372, 405–436, 477, 490, 522
   jsonld.py624921%29–92, 103–141
   messaging.py21957%31–36, 56–63
   oob.py493235%26–65, 76–88, 112–122
   sse.py321553%37–43, 66–72, 99–107, 136–142, 173–184
   verifier.py1453278%58–60, 65, 103–105, 110, 152, 160–162, 167, 201–205, 214–216, 245–247, 253, 286–288, 293, 323–325, 359–361
   webhooks.py16475%30–34, 53–57
   websocket_endpoint.py18667%17–18, 27–28, 38–41
app/routes/admin
   tenants.py15012020%46–156, 165–189, 197–214, 224–234, 243–255, 265–305
app/routes/wallet
   credentials.py795432%32–41, 50–62, 71–81, 90–102, 113–125, 137–146, 155–165, 174–184
   dids.py752271%24–33, 50–51, 71–72, 84–91, 99–105
   jws.py422736%35–57, 73–96
   sd_jws.py422736%36–58, 75–98
app/services
   acapy_ledger.py691874%49–50, 76–78, 117–118, 131–150, 203–204
   acapy_wallet.py40490%61–62, 96–97
   revocation_registry.py1301092%342, 350–352, 382–386, 408–414
   sse.py715523%20–24, 36–49, 62–75, 91–108, 125–142, 160–183
   webhooks.py271833%14–24, 31–39
   websocket.py443423%19–22, 29–36, 45–79
app/services/event_handling
   sse_listener.py41880%50–55, 79–84
   websocket_manager.py753257%32–38, 63–67, 86–89, 96–107, 114–124, 138
app/services/issuer
   acapy_issuer_v1.py901386%32, 59–82, 163–164
   acapy_issuer_v2.py1022179%48–51, 71–105, 143, 189–190, 213
app/services/onboarding
   issuer.py38684%98–100, 117–119
   tenants.py624823%26–92, 102–132
   verifier.py36392%66, 82–86
app/services/onboarding/util
   register_issuer_did.py61789%85–87, 178–180, 195
   set_endorser_metadata.py693746%26–28, 46–48, 70–72, 103–120, 132–141, 153–164, 177–189
app/services/trust_registry
   actors.py107992%94–99, 109, 208–209, 211–216, 281–284
   schemas.py49492%56–61, 91–96
app/services/trust_registry/util
   actor.py31294%26–27
   issuer.py23483%39–40, 48–49
app/services/verifier
   acapy_verifier_v1.py1336849%36, 59–63, 74, 96–100, 105, 113, 137–141, 146, 159–169, 174–176, 182–196, 200–219, 223–235, 239–259
   acapy_verifier_v2.py1407447%40–45, 65–69, 81–86, 108–112, 117, 130–135, 149–153, 158, 171–183, 188–192, 198–212, 216–235, 239–253, 257–277
app/tests/e2e
   conftest.py22577%39–47
   test_jsonld.py641675%133–168
   test_tenants.py3021595%153, 197–198, 226, 596, 630–631, 640–641, 650–651, 663–664, 673–674
   test_wallet_dids.py671085%92–107
app/tests/e2e/verifier
   test_verifier.py360199%1068
app/tests/services
   test_onboarding.py86199%263
   test_revocation_registry.py135299%73, 106
app/tests/services/issuer
   test_issuer.py161299%293–296
app/tests/services/verifier
   utils.py1438938%174–188, 195–214, 226–263, 271–274, 280–291, 297–306, 311–364, 375–427, 440–466, 479–517, 531–569, 583–604, 615–631, 644–650, 664–680, 694–720
app/tests/util
   credentials.py60198%149
   ecosystem_connections.py1352780%284–303, 320–340, 348–387
   ledger.py491080%34, 42, 54, 62–66, 76, 82
   member_acapy_clients.py36683%47–50, 65–66, 73–74
   trust_registry.py41393%26, 29–30
   webhooks.py25292%13, 61
app/util
   acapy_issuer_utils.py18194%22
   acapy_verifier_utils.py1348239%40, 48–126, 157, 164–183, 187, 194–198, 206–210, 214–218, 225–255, 261–264
   credentials.py10460%8, 12–15
   extract_validation_error.py9722%5–11
   retry_method.py352043%9–30, 68–71, 90–97
   tenants.py251348%12–17, 32–33, 40–47
endorser
   main.py33391%59–62
endorser/services
   endorsement_processor.py1381391%148–158, 191–195, 207, 219, 237–238, 247–251
endorser/services/dependency_injection
   container.py14193%54
endorser/util
   endorsement.py531081%56–57, 60–61, 64–65, 68–72, 76–80
   transaction_record.py691381%51–52, 78–82, 95, 105–106, 113–121
   trust_registry.py34488%51–52, 63–67
trustregistry
   crud.py17615214%15–30, 34–46, 50–62, 66–78, 82–141, 145–161, 165–194, 200–214, 218–228, 232–252, 256–283, 287–302
   db.py29969%11–15, 19–23
   list_type.py11464%11–14, 17
   main.py411563%23–32, 54–59, 64
trustregistry/registry
   registry_actors.py825829%19–22, 27–38, 45–65, 72–82, 89–99, 106–116, 121–127
   registry_schemas.py654038%24–27, 34–51, 58–92, 97–108, 113–119
webhooks/models
   conversions.py63690%70, 83, 89, 110, 145, 163
webhooks/services
   acapy_events_processor.py1601491%151–161, 209–213, 241, 269–270, 294–298, 310–314
   sse_manager.py2263684%153, 155–168, 202–212, 241–242, 255–269, 324–328, 334–337, 339–342, 367–368, 411–413, 447, 458–459
   webhooks_redis_serivce.py991486%61–64, 67, 122–123, 206–207, 267, 273–274, 288–294
webhooks/services/dependency_injection
   container.py18194%61
webhooks/tests
   test_sse_manager.py161398%212–213, 219
webhooks/tests/e2e
   test_sse.py81495%121, 147–150
webhooks/web
   main.py42393%77–80
webhooks/web/routers
   sse.py16813718%34–38, 61–96, 121–154, 173–238, 260–301, 324–376
   webhooks.py301453%27–36, 50–63
TOTAL10156200180% 

Tests Skipped Failures Errors Time
332 2 💤 0 ❌ 0 🔥 10m 28s ⏱️

app/services/onboarding/util/register_issuer_did.py Dismissed Show dismissed Hide dismissed
app/services/onboarding/util/register_issuer_did.py Dismissed Show dismissed Hide dismissed
Copy link

Coverage

Coverage Report
FileStmtsMissCoverMissing
app
   main.py802668%73–76, 100, 102, 104, 108, 115, 141–146, 153–180
app/dependencies
   acapy_clients.py24292%36, 52
   auth.py561966%31, 37–38, 41, 52–55, 62–63, 68, 74–79, 83–86, 90–91, 96
   role.py34197%56
app/exceptions
   handle_acapy_call.py29776%50–51, 54–60, 66–71
   handle_model_with_validation.py15567%31–37
app/models
   issuer.py48296%35, 44
   jsonld.py35586%21, 45–50
   oob.py24196%26
   tenants.py761580%75, 78, 87–99, 106, 109, 128–138
   verifier.py651282%34, 42, 50–64, 101, 109–113
app/routes
   connections.py593836%32–48, 64–76, 113–138, 159–173, 188–198
   definitions.py1889251%76–137, 170–171, 238–254, 269–275, 296–305, 328–329, 346–348, 383–437, 464–465, 509–589, 597–616
   issuer.py1733878%92, 128, 160–162, 191, 221–223, 231, 248, 347–357, 388–399, 432–463, 504, 517, 549
   jsonld.py604722%23–90, 101–134
   messaging.py241154%32–41, 61–71
   oob.py462839%27–68, 79–92, 116–127
   sse.py321553%37–43, 66–72, 99–107, 136–142, 173–184
   verifier.py1463278%64–66, 71, 109–111, 116, 158, 166–168, 173, 207–211, 220–222, 272–274, 280, 313–315, 320, 350–352, 386–388
   webhooks.py16475%30–34, 53–57
   websocket_endpoint.py18667%17–18, 27–28, 38–41
app/routes/admin
   tenants.py15112120%51–170, 179–211, 219–243, 253–263, 272–288, 298–347
app/routes/wallet
   credentials.py775232%32–45, 54–66, 75–86, 95–109, 120–136, 148–162, 171–183, 192–203
   dids.py762271%28–37, 56–57, 79–80, 92–99, 107–115
   jws.py422736%35–57, 73–96
   sd_jws.py422736%36–58, 75–98
app/services
   acapy_ledger.py611280%110–111, 124–140, 196–197
   acapy_wallet.py39490%60–61, 97–98
   revocation_registry.py1301291%309–313, 341, 351–353, 383–387, 412–417
   sse.py715523%20–24, 36–49, 62–75, 91–108, 125–142, 160–183
   webhooks.py271833%14–24, 31–39
   websocket.py443423%19–22, 29–36, 45–79
app/services/event_handling
   sse_listener.py41880%50–55, 79–84
   websocket_manager.py753257%32–38, 63–67, 86–89, 96–107, 114–124, 138
app/services/issuer
   acapy_issuer_v1.py911386%36, 70–98, 201–202
   acapy_issuer_v2.py1062279%54–57, 81–116, 162, 224–225, 252
app/services/onboarding
   issuer.py40685%102–104, 129–131
   tenants.py634922%30–107, 117–147
   verifier.py37392%67, 83–87
app/services/onboarding/util
   register_issuer_did.py902177%100–102, 211–233, 256–278
   set_endorser_metadata.py693746%28–30, 50–52, 76–78, 109–128, 140–149, 161–172, 185–197
app/services/trust_registry
   actors.py107992%94–99, 109, 208–209, 211–216, 281–284
   schemas.py49492%56–61, 91–96
app/services/trust_registry/util
   actor.py31294%26–27
   issuer.py23483%39–40, 48–49
app/services/verifier
   acapy_verifier_v1.py1296252%39, 61–62, 70, 80, 102–103, 111, 119, 144–145, 153, 166–179, 190–191, 206–228, 234–256, 260–276, 282–302
   acapy_verifier_v2.py1366751%43–48, 68–69, 77, 90–95, 116–117, 125, 138–143, 160–161, 169, 182–194, 205–206, 221–242, 248–269, 273–289, 295–315
app/tests/e2e
   conftest.py22577%39–47
   test_jsonld.py591673%133–168
   test_tenants.py3021595%153, 197–198, 226, 596, 630–631, 640–641, 650–651, 663–664, 673–674
   test_wallet_dids.py671085%92–107
app/tests/e2e/issuer
   test_save_exchange_record.py62198%140
app/tests/e2e/verifier
   test_verifier.py424199%1070
app/tests/services
   test_revocation_registry.py135299%73, 106
app/tests/services/issuer
   test_issuer.py161299%316–319
app/tests/services/verifier
   utils.py1388538%171–185, 192–229, 237–240, 246–257, 263–272, 277–330, 341–393, 406–432, 445–483, 497–535, 549–570, 581–597, 610–616, 630–646, 660–686
app/tests/util
   credentials.py60198%149
   ecosystem_connections.py1362780%291–310, 327–347, 355–394
   ledger.py491080%34, 42, 54, 62–66, 76, 82
   member_acapy_clients.py36489%47–50, 73–74
   trust_registry.py41393%26, 29–30
   webhooks.py25292%13, 61
app/util
   acapy_issuer_utils.py18194%22
   acapy_verifier_utils.py1338238%41, 51–130, 163, 170–189, 193, 200–204, 212–216, 220–224, 231–264, 270–273
   credentials.py11464%11, 15–18
   extract_validation_error.py9722%5–11
   retry_method.py362142%15–36, 76–77, 91–103
   tenants.py251348%12–17, 32–33, 40–47
endorser
   main.py33391%59–62
endorser/services
   endorsement_processor.py1381391%148–158, 191–195, 207, 219, 237–238, 247–251
endorser/services/dependency_injection
   container.py14193%54
endorser/util
   endorsement.py581279%57–58, 62–63, 71–72, 75–76, 79–80, 94–99
   transaction_record.py54787%52–53, 69–73, 77–81, 90
   trust_registry.py34488%51–52, 63–67
trustregistry
   crud.py17615214%15–30, 34–46, 50–62, 66–78, 82–141, 145–161, 165–194, 200–214, 218–228, 232–252, 256–283, 287–302
   db.py29969%11–15, 19–23
   list_type.py11464%11–14, 17
   main.py411563%23–32, 54–59, 64
trustregistry/registry
   registry_actors.py825829%19–22, 27–38, 45–65, 72–82, 89–99, 106–116, 121–127
   registry_schemas.py654038%24–27, 34–51, 58–92, 97–108, 113–119
webhooks/models
   conversions.py63690%70, 83, 89, 110, 145, 163
webhooks/services
   acapy_events_processor.py1611491%152–162, 210–214, 242, 270–271, 295–299, 311–315
   sse_manager.py2263684%153, 155–168, 202–212, 241–242, 255–269, 324–328, 334–337, 339–342, 367–368, 411–413, 447, 458–459
   webhooks_redis_serivce.py991486%61–64, 67, 122–123, 208–209, 271, 277–278, 292–298
webhooks/services/dependency_injection
   container.py18194%61
webhooks/tests
   test_sse_manager.py161398%212–213, 219
webhooks/tests/e2e
   test_sse.py81495%121, 147–150
webhooks/web
   main.py42393%77–80
webhooks/web/routers
   sse.py16813718%34–38, 61–96, 121–154, 173–238, 260–301, 324–376
   webhooks.py301453%27–36, 50–63
TOTAL10347199181% 

Tests Skipped Failures Errors Time
338 8 💤 0 ❌ 0 🔥 12m 3s ⏱️

… 204 status code change for a future release that involves a breaking change
app/routes/connections.py Dismissed Show dismissed Hide dismissed


@pytest.mark.anyio
async def test_handle_model_with_validation_error(mock_logger):

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Redefining name 'mock_logger' from outer scope (line 25) Note test

Redefining name 'mock_logger' from outer scope (line 25)
field: str

@field_validator("field")
def validate_regex(cls, value):

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Method 'validate_regex' should have "self" as first argument Warning test

Method 'validate_regex' should have "self" as first argument


@pytest.mark.anyio
async def test_handle_acapy_call_with_unauthorized_exception(acapy_call, mock_logger):

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Redefining name 'acapy_call' from outer scope (line 28) Note test

Redefining name 'acapy_call' from outer scope (line 28)
@ff137 ff137 self-assigned this Mar 22, 2024
@ff137 ff137 added the enhancement New feature or request label Mar 22, 2024
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

Coverage

Coverage Report
FileStmtsMissCoverMissing
app
   main.py802668%73–76, 100, 102, 104, 108, 115, 141–146, 153–180
app/dependencies
   acapy_clients.py24292%36, 52
   auth.py561966%31, 37–38, 41, 52–55, 62–63, 68, 74–79, 83–86, 90–91, 96
   role.py34197%56
app/models
   issuer.py48296%35, 44
   jsonld.py35586%21, 45–50
   oob.py24196%26
   tenants.py761580%75, 78, 87–99, 106, 109, 128–138
   verifier.py651282%34, 42, 50–64, 101, 109–113
app/routes
   connections.py603935%32–48, 64–76, 113–138, 159–173, 188–199
   definitions.py1889251%76–137, 170–171, 238–254, 269–275, 296–305, 328–329, 346–348, 383–437, 464–465, 509–589, 597–616
   issuer.py1733878%92, 128, 160–162, 191, 221–223, 231, 248, 347–357, 388–399, 432–463, 504, 517, 549
   jsonld.py604722%23–90, 101–134
   messaging.py241154%32–41, 61–71
   oob.py462839%27–68, 79–92, 116–127
   sse.py321553%37–43, 66–72, 99–107, 136–142, 173–184
   verifier.py1463278%64–66, 71, 109–111, 116, 158, 166–168, 173, 207–211, 220–222, 272–274, 280, 313–315, 320, 350–352, 386–388
   webhooks.py16475%30–34, 53–57
   websocket_endpoint.py18667%17–18, 27–28, 38–41
app/routes/admin
   tenants.py15112120%51–170, 179–211, 219–243, 253–263, 272–288, 298–347
app/routes/wallet
   credentials.py775232%32–45, 54–66, 75–86, 95–109, 120–136, 148–162, 171–183, 192–203
   dids.py762271%28–37, 56–57, 79–80, 92–99, 107–115
   jws.py422736%35–57, 73–96
   sd_jws.py422736%36–58, 75–98
app/services
   acapy_ledger.py611280%110–111, 124–140, 196–197
   acapy_wallet.py39490%60–61, 97–98
   revocation_registry.py1301291%309–313, 341, 351–353, 383–387, 412–417
   sse.py715523%20–24, 36–49, 62–75, 91–108, 125–142, 160–183
   webhooks.py271833%14–24, 31–39
   websocket.py443423%19–22, 29–36, 45–79
app/services/event_handling
   sse_listener.py41880%50–55, 79–84
   websocket_manager.py753257%32–38, 63–67, 86–89, 96–107, 114–124, 138
app/services/issuer
   acapy_issuer_v1.py911386%36, 70–98, 201–202
   acapy_issuer_v2.py1062279%54–57, 81–116, 162, 224–225, 252
app/services/onboarding
   tenants.py634922%30–107, 117–147
   verifier.py37392%67, 83–87
app/services/onboarding/util
   register_issuer_did.py86397%100–102
   set_endorser_metadata.py693746%28–30, 50–52, 76–78, 109–128, 140–149, 161–172, 185–197
app/services/trust_registry
   actors.py107992%94–99, 109, 208–209, 211–216, 281–284
   schemas.py49492%56–61, 91–96
app/services/trust_registry/util
   actor.py31294%26–27
   issuer.py23483%39–40, 48–49
app/services/verifier
   acapy_verifier_v1.py1296252%39, 61–62, 70, 80, 102–103, 111, 119, 144–145, 153, 166–179, 190–191, 206–228, 234–256, 260–276, 282–302
   acapy_verifier_v2.py1366751%43–48, 68–69, 77, 90–95, 116–117, 125, 138–143, 160–161, 169, 182–194, 205–206, 221–242, 248–269, 273–289, 295–315
app/tests/e2e
   conftest.py22577%39–47
   test_jsonld.py591673%133–168
   test_tenants.py3021595%153, 197–198, 226, 596, 630–631, 640–641, 650–651, 663–664, 673–674
   test_wallet_dids.py671085%92–107
app/tests/e2e/issuer
   test_save_exchange_record.py62198%140
app/tests/e2e/verifier
   test_verifier.py424199%1070
app/tests/exception_handling
   test_handle_model_with_validation.py23196%22
app/tests/services
   test_revocation_registry.py135299%73, 106
app/tests/services/issuer
   test_issuer.py161299%316–319
app/tests/services/verifier
   utils.py1388538%171–185, 192–229, 237–240, 246–257, 263–272, 277–330, 341–393, 406–432, 445–483, 497–535, 549–570, 581–597, 610–616, 630–646, 660–686
app/tests/util
   credentials.py60198%149
   ecosystem_connections.py1362780%291–310, 327–347, 355–394
   ledger.py491080%34, 42, 54, 62–66, 76, 82
   member_acapy_clients.py36489%47–50, 73–74
   trust_registry.py41393%26, 29–30
   webhooks.py25292%13, 61
app/util
   acapy_issuer_utils.py18194%22
   acapy_verifier_utils.py1338238%41, 51–130, 163, 170–189, 193, 200–204, 212–216, 220–224, 231–264, 270–273
   credentials.py11464%11, 15–18
   retry_method.py362142%15–36, 76–77, 91–103
   tenants.py251348%12–17, 32–33, 40–47
endorser
   main.py33391%59–62
endorser/services
   endorsement_processor.py1381391%148–158, 191–195, 207, 219, 237–238, 247–251
endorser/services/dependency_injection
   container.py14193%54
endorser/util
   endorsement.py58690%57–58, 62–63, 94–99
   transaction_record.py54394%52–53, 90
   trust_registry.py34488%51–52, 63–67
trustregistry
   crud.py17615214%15–30, 34–46, 50–62, 66–78, 82–141, 145–161, 165–194, 200–214, 218–228, 232–252, 256–283, 287–302
   db.py29969%11–15, 19–23
   list_type.py11464%11–14, 17
   main.py411563%23–32, 54–59, 64
trustregistry/registry
   registry_actors.py825829%19–22, 27–38, 45–65, 72–82, 89–99, 106–116, 121–127
   registry_schemas.py654038%24–27, 34–51, 58–92, 97–108, 113–119
webhooks/models
   conversions.py63690%70, 83, 89, 110, 145, 163
webhooks/services
   acapy_events_processor.py1611491%152–162, 210–214, 242, 270–271, 295–299, 311–315
   sse_manager.py2263684%153, 155–168, 202–212, 241–242, 255–269, 324–328, 334–337, 339–342, 367–368, 411–413, 447, 458–459
   webhooks_redis_serivce.py991486%61–64, 67, 122–123, 208–209, 271, 277–278, 292–298
webhooks/services/dependency_injection
   container.py18194%61
webhooks/tests
   test_sse_manager.py161398%212–213, 219
webhooks/tests/e2e
   test_sse.py81495%121, 147–150
webhooks/web
   main.py42393%77–80
webhooks/web/routers
   sse.py16813718%34–38, 61–96, 121–154, 173–238, 260–301, 324–376
   webhooks.py301453%27–36, 50–63
TOTAL10590194082% 

Tests Skipped Failures Errors Time
364 8 💤 0 ❌ 0 🔥 11m 54s ⏱️

Copy link
Collaborator

@cl0ete cl0ete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ff137 ff137 merged commit f0aa62d into development Mar 22, 2024
44 checks passed
@ff137 ff137 deleted the art/remove-listeners branch March 22, 2024 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants