omsf-eco-infra / ticgithub

Tools to use a GitHub repository as a support ticket system
MIT License
0 stars 0 forks source link

[WIP] Authorizables and authorization checks #53

Open dwhswenson opened 10 months ago

dwhswenson commented 10 months ago

This will introduce a new task, which checks that all the authorization is working. This is likely to be an occasional source of errors in all the automated workflows, so it is worth creating an easy tool to check it.

The main idea here is to use a abstract mix-in on the three classes that have some sort of authorization (Bot, Inbox, and SMTP). Subclasses need to define a method that raises exceptions if authorization fails, or returns True if it succeeds. They also need to define which exception classes are expected as indicators of authorization failure.

The reason to pass the exception along instead of just returning False is that the exception will usually contain more information about the nature of the failure. This is probably something we want to report to the user.

Testing is going to be a bit tricky, I think, because I want this to actually be an integration test. We'll have to skip these in cases where the necessary environment variables aren't provided.

codecov[bot] commented 10 months ago

Codecov Report

Attention: 71 lines in your changes are missing coverage. Please review.

Comparison is base (cd85036) 34.55% compared to head (722a3ff) 34.79%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #53 +/- ## ========================================== + Coverage 34.55% 34.79% +0.24% ========================================== Files 20 23 +3 Lines 848 957 +109 ========================================== + Hits 293 333 +40 - Misses 555 624 +69 ``` | [Files](https://app.codecov.io/gh/dwhswenson/ticgithub/pull/53?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+W.H.+Swenson) | Coverage Δ | | |---|---|---| | [ticgithub/tests/utils.py](https://app.codecov.io/gh/dwhswenson/ticgithub/pull/53?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+W.H.+Swenson#diff-dGljZ2l0aHViL3Rlc3RzL3V0aWxzLnB5) | `87.50% <84.61%> (-12.50%)` | :arrow_down: | | [ticgithub/inbox.py](https://app.codecov.io/gh/dwhswenson/ticgithub/pull/53?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+W.H.+Swenson#diff-dGljZ2l0aHViL2luYm94LnB5) | `41.48% <57.14%> (+0.58%)` | :arrow_up: | | [ticgithub/tasks/task.py](https://app.codecov.io/gh/dwhswenson/ticgithub/pull/53?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+W.H.+Swenson#diff-dGljZ2l0aHViL3Rhc2tzL3Rhc2sucHk=) | `41.17% <20.00%> (-1.25%)` | :arrow_down: | | [ticgithub/bot.py](https://app.codecov.io/gh/dwhswenson/ticgithub/pull/53?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+W.H.+Swenson#diff-dGljZ2l0aHViL2JvdC5weQ==) | `40.57% <54.54%> (+0.57%)` | :arrow_up: | | [ticgithub/authorizable.py](https://app.codecov.io/gh/dwhswenson/ticgithub/pull/53?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+W.H.+Swenson#diff-dGljZ2l0aHViL2F1dGhvcml6YWJsZS5weQ==) | `35.29% <35.29%> (ø)` | | | [ticgithub/tests/test\_bot.py](https://app.codecov.io/gh/dwhswenson/ticgithub/pull/53?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+W.H.+Swenson#diff-dGljZ2l0aHViL3Rlc3RzL3Rlc3RfYm90LnB5) | `48.48% <48.48%> (ø)` | | | [ticgithub/tasks/authorization\_check.py](https://app.codecov.io/gh/dwhswenson/ticgithub/pull/53?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+W.H.+Swenson#diff-dGljZ2l0aHViL3Rhc2tzL2F1dGhvcml6YXRpb25fY2hlY2sucHk=) | `0.00% <0.00%> (ø)` | |

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