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

Fix missed error return in loadCipher #62

Merged
merged 1 commit into from
Sep 26, 2024
Merged

Fix missed error return in loadCipher #62

merged 1 commit into from
Sep 26, 2024

Conversation

qmuntal
Copy link
Member

@qmuntal qmuntal commented Sep 26, 2024

We were missing to return an error when a cipher algorithm could not be fetched. That error can only occur if there is something wrong in CNG itself or we call loadCipher with the wrong arguments, which we are not.

I haven't found a way to trigger this bug from the public API, so I'm not adding a test for it in this PR. I´ll submit a follow-up PR that simplifies all calls to loadOrStoreAlg so the caller doesn't have to do the error handling on the calling site.

@karianna karianna merged commit 3ab6b54 into main Sep 26, 2024
25 checks passed
@gdams gdams deleted the ciphererr branch September 26, 2024 08:28
@karianna
Copy link
Member

In hindsight, should this have been caught in a test?

@qmuntal
Copy link
Member Author

qmuntal commented Sep 26, 2024

In hindsight, should this have been caught in a test?

It is not possible to trigger an error in that line of code using the public API (at least without mocking CNG itself), and we normally don't test implementation details (aka black box testing). In #63 I've removed the offending lines, so this error shouldn't happen again.

Having said this, it is fine for me to add tests exercising code that is not reachable using the public API to aim for 100% of code coverage (the current coverage is 80%). We can discuss the priority of this in our weekly sync. The drawback would be less velocity, as existing code would be more difficult to refactor without breaking tests and new code would be slower to add because it would require more testing.

@karianna
Copy link
Member

In hindsight, should this have been caught in a test?

It is not possible to trigger an error in that line of code using the public API (at least without mocking CNG itself), and we normally don't test implementation details (aka black box testing). In #63 I've removed the offending lines, so this error shouldn't happen again.

Having said this, it is fine for me to add tests exercising code that is not reachable using the public API to aim for 100% of code coverage (the current coverage is 80%). We can discuss the priority of this in our weekly sync. The drawback would be less velocity, as existing code would be more difficult to refactor without breaking tests and new code would be slower to add because it would require more testing.

I'd say its low priority in that case, thanks for the context!

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.

3 participants