DiamondLightSource / bluesky-stomp

STOMP messaging integration for bluesky
Apache License 2.0
1 stars 0 forks source link

Prevent accidental logging by use of Pydantic Secret types, handle envVariables #23

Closed DiamondJoseph closed 2 months ago

DiamondJoseph commented 2 months ago

Required for https://github.com/DiamondLightSource/blueapi/issues/636

Current parsing of blueapi config passes a blueapi BasicAuthentication with fields username, passcode as an instance of bluesky-stomp BasicAuthentication with fields username, password. I am not certain that we would be able to pass the former as an instance of the latter even if their arguments agreed, as they are different Pydantic models. By moving the parsing of environment variables into this class, we can simply make use of this library's BasicAuthentication as part of the config of blueapi and not duplicate the logic.

We additionally noticed logging of passwords, so making the password field a Secret[str] was a sensible move. Note that type checking does not like passing a str as a Secret[str]: https://github.com/pydantic/pydantic/issues/9557

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.62%. Comparing base (578c57f) to head (d4f059f). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/bluesky_stomp/models.py 88.88% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #23 +/- ## ========================================== - Coverage 93.85% 93.62% -0.23% ========================================== Files 6 6 Lines 244 251 +7 ========================================== + Hits 229 235 +6 - Misses 15 16 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.