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

Enhance Cipher, Decipher coverage #17449

Closed
wants to merge 11 commits into from
Closed

Enhance Cipher, Decipher coverage #17449

wants to merge 11 commits into from

Conversation

Leko
Copy link
Contributor

@Leko Leko commented Dec 4, 2017

I added those test:

Cipher
  • Call constructor withour new keyword
  • Call constructor with cipher is not string
  • Call constructor with cipher is string and password is not string
  • Call Cipher#update with data is not string
  • Call Cipher#setAuthTag with tagbuf is not string
  • Call Cipher#setAAD with aadbuf is not string
Decipher
  • Call constructor withour new keyword
  • Call constructor with cipher is not string
  • Call constructor with cipher is string and password is not string

Current coverage is here: https://coverage.nodejs.org/coverage-06e1b0386196f8f8/root/internal/crypto/cipher.js.html

Cipheriv and Decipheriv is not covered in this PR to avoid PR too large.
I'm going to write these test in another PR.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Dec 4, 2017
const Decipher = crypto.Decipher;
const instance = crypto.Decipher('aes-256-cbc', 'secret');
assert(instance instanceof Decipher, 'Decipher is expected to return a new ' +
'instance when called without `new`');
Copy link
Member

Choose a reason for hiding this comment

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

Nit: indent once more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a silly mistake.
I'll fix it soon.

@mscdex mscdex added the crypto Issues and PRs related to the crypto subsystem. label Dec 4, 2017
Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

@maclover7
Copy link
Contributor

Same deal as #17458 (comment), are we able to use the create functions here?

Copy link
Contributor

@maclover7 maclover7 left a comment

Choose a reason for hiding this comment

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

Two quick nits then LGTM

@@ -70,6 +70,81 @@ testCipher1(Buffer.from('MySecretKey123'));
testCipher2('0123456789abcdef');
testCipher2(Buffer.from('0123456789abcdef'));

{
const Cipher = crypto.Cipher;
const instance = crypto.Cipher('aes-256-cbc', 'secret');
Copy link
Contributor

Choose a reason for hiding this comment

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

createCipher

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same adobe #17458 (comment)


{
const Decipher = crypto.Decipher;
const instance = crypto.Decipher('aes-256-cbc', 'secret');
Copy link
Contributor

Choose a reason for hiding this comment

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

createDecipher

@maclover7
Copy link
Contributor

@maclover7 maclover7 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 7, 2017
@apapirovski
Copy link
Contributor

Landed in 84b7a86

@apapirovski apapirovski closed this Dec 8, 2017
apapirovski pushed a commit that referenced this pull request Dec 8, 2017
Cipher
- Call constructor withour new keyword
- Call constructor with cipher is not string
- Call constructor with cipher is string and password is not string
- Call Cipher#update with data is not string
- Call Cipher#setAuthTag with tagbuf is not string
- Call Cipher#setAAD with aadbuf is not string

Decipher
- Call constructor withour new keyword
- Call constructor with cipher is not string
- Call constructor with cipher is string and password is not string

PR-URL: #17449
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@Leko Leko deleted the add_missing_test_in_crypto_cipher branch December 8, 2017 15:48
@MylesBorins
Copy link
Contributor

These tests rely on the semver major changes in #16527
setting don't land for <=9.x

@addaleax addaleax removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.