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

[#39] Hardened certificate admin changelist to not crash on missing physical files #40

Merged
merged 2 commits into from
May 16, 2022

Conversation

Bartvaderkin
Copy link
Contributor

Fixes #39

@codecov
Copy link

codecov bot commented May 16, 2022

Codecov Report

Merging #40 (e18ed68) into master (b179652) will increase coverage by 0.44%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #40      +/-   ##
==========================================
+ Coverage   46.17%   46.62%   +0.44%     
==========================================
  Files          36       36              
  Lines        1306     1317      +11     
  Branches      222      222              
==========================================
+ Hits          603      614      +11     
  Misses        669      669              
  Partials       34       34              
Impacted Files Coverage Δ
zgw_consumers/admin.py 86.95% <100.00%> (+4.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b179652...e18ed68. Read the comment docs.

@Bartvaderkin Bartvaderkin force-pushed the fix/39-certificate-filenotfound-listerror branch from bcf19f4 to 43e8a7a Compare May 16, 2022 15:28
@Bartvaderkin Bartvaderkin force-pushed the fix/39-certificate-filenotfound-listerror branch from 43e8a7a to bb24c9b Compare May 16, 2022 15:30
tests/test_certificates.py Outdated Show resolved Hide resolved
Comment on lines +44 to +56
def expiry_date(self, obj=None):
# alias model property to catch file not found errors
try:
return obj.expiry_date
except FileNotFoundError:
return _("file not found")

def is_valid_key_pair(self, obj=None):
# alias model method to catch file not found errors
try:
return obj.is_valid_key_pair()
except FileNotFoundError:
return _("file not found")
Copy link
Member

@sergei-maertens sergei-maertens May 16, 2022

Choose a reason for hiding this comment

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

I'd rather see this handled on the model methods/properties, since calling that code somewhere else than in the admin would still cause crashes.

I'd also like to see a logger.error(...) call if the FileNotFoundError happens, that needs to end up in Sentry imo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes but that is what we want: regular use shouldn't silently proceed when missing missing certificate/key files.

But the admin needs to be able to handle the situation so we can fix it.

@sergei-maertens
Copy link
Member

I'll merge it and we can discuss what should happen at the model layer later

@sergei-maertens sergei-maertens merged commit d1863bf into master May 16, 2022
@sergei-maertens sergei-maertens deleted the fix/39-certificate-filenotfound-listerror branch May 16, 2022 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Certificate admin crashes if cert file is missing
2 participants