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

Bugfix: pemEncoded must not produce empty lines #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ehealthexperts-rk
Copy link

As described in #30 the encoded pem could contain an empty line at the end of the payload which rendered the data invalid. This is fixed and tests regarding the function pemEncode werde added.
In order to test the internal pemEncode function "rewire" was used as a replacement for require.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling b90195f on ehealthexperts-rk:master into ee1a1fd on johncrisostomo:master.

@@ -157,6 +157,24 @@
"lodash.get": "^4.4.2"
}
},
"@types/color-name": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert the lockfile changes.

mockPemEncodedCert = require('./mocks/mock.pem'),
mockBase64EncodedRawBuffer = require('./mocks/base64buffer.txt'),
getSSLCertificate = require('../index');
getSSLCertificate = rewire('../index');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

@DanielRuf
Copy link
Contributor

"rewire" was used as a replacement for require.

I'm unsure if this is really needed. Is it because the method is private?

@DanielRuf
Copy link
Contributor

I think the PR would be good for https://github.com/DanielRuf/get-ssl-certificate-next - can you provide it there too (without the lockfile changes)?

Regarding rewire, wouldn't it be better if we also export the pemEncode method for users or should we keep the method private and switch to rewire?

@ehealthexperts-rk
Copy link
Author

I'm unsure if this is really needed. Is it because the method is private?

Yes, I found rewire as a solution to test private methods. The lockfile changes come from rewire. Exporting this tiny helper just for testing feels wrong as you would end up exporting all internal functions. Another solution could be to extract pemEncode to a separate file, add tests to it and import it. For a change like this I am a little short of time. Another obvious workaround would be to just apply the fix " && i < str.length" and leave out the new tests. There were no tests present in the first place.

@DanielRuf
Copy link
Contributor

The lockfile changes come from rewire.

In my fork (get-ssl-certificate-next) I update the lockfile due to security reasons. And when lockfiles are changed in multiple PRs and one is merged or the file is updated on the master branch all PRs will get a conflict.

@DanielRuf
Copy link
Contributor

Tests are always good and I think so far the reasoning for rewire is ok so this could stay like this - personally I just prefer less dependencies and completely exported objects with all methods.

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