Ouranosinc / Magpie

AuthN/AuthZ services
https://pavics-magpie.readthedocs.io
Apache License 2.0
1 stars 5 forks source link

Add supplemental regex setting to validate username #592

Closed mishaschwartz closed 1 year ago

mishaschwartz commented 1 year ago

Create an additional settings/environment variable MAGPIE_SUPPLEMENTAL_USERNAME_REGEX that acts as an additional check for whether a username is valid. This creates a further restriction on this value which is useful when there are additional limits on the username that should be enforced by Magpie.

Resolves #497

mishaschwartz commented 1 year ago

@fmigneault I'd like to add some tests to this as well.

I was unable to find the current tests that check the user creation routes. I'm probably just looking in the wrong place. Any help would be greatly appreciated.

fmigneault commented 1 year ago

@mishaschwartz

I was unable to find the current tests that check the user creation routes. I'm probably just looking in the wrong place. Any help would be greatly appreciated.

Should be in https://github.com/Ouranosinc/Magpie/blob/master/tests/interfaces.py. Classes in there are reused by https://github.com/Ouranosinc/Magpie/blob/master/tests/test_magpie_api.py and https://github.com/Ouranosinc/Magpie/blob/master/tests/test_magpie_ui.py for various local/remote admin/public testing combinations.

codecov[bot] commented 1 year ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (36208d8) 80.84% compared to head (436c7f9) 80.92%. Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #592 +/- ## ========================================== + Coverage 80.84% 80.92% +0.07% ========================================== Files 73 73 Lines 10188 10194 +6 Branches 1823 1824 +1 ========================================== + Hits 8236 8249 +13 + Misses 1630 1622 -8 - Partials 322 323 +1 ``` | [Files](https://app.codecov.io/gh/Ouranosinc/Magpie/pull/592?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ouranosinc) | Coverage Δ | | |---|---|---| | [magpie/api/management/user/user\_utils.py](https://app.codecov.io/gh/Ouranosinc/Magpie/pull/592?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ouranosinc#diff-bWFncGllL2FwaS9tYW5hZ2VtZW50L3VzZXIvdXNlcl91dGlscy5weQ==) | `97.23% <100.00%> (+0.02%)` | :arrow_up: | | [magpie/api/schemas.py](https://app.codecov.io/gh/Ouranosinc/Magpie/pull/592?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ouranosinc#diff-bWFncGllL2FwaS9zY2hlbWFzLnB5) | `99.69% <100.00%> (+<0.01%)` | :arrow_up: | ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/Ouranosinc/Magpie/pull/592/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ouranosinc)

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

fmigneault commented 1 year ago

@mishaschwartz Thanks for the PR and tests! https://github.com/Ouranosinc/Magpie/tree/3.37.0 pushed 🚀