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

test: fix require nits in some test-tls-* tests #14008

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/internet/test-tls-add-ca-cert.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ if (!common.hasCrypto) {

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tls = require('tls');

function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', `${n}.pem`);
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
}

function loadPEM(n) {
Expand Down
7 changes: 4 additions & 3 deletions test/parallel/test-tls-alert-handling.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ if (!common.hasCrypto) {
return;
}

const tls = require('tls');
const net = require('net');
const fs = require('fs');
const net = require('net');
const path = require('path');
const tls = require('tls');

function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', `${n}.pem`);
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
}

function loadPEM(n) {
Expand Down
9 changes: 5 additions & 4 deletions test/parallel/test-tls-alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

'use strict';
const common = require('../common');
const assert = require('assert');

if (!common.opensslCli) {
common.skip('node compiled without OpenSSL CLI.');
Expand All @@ -32,15 +31,17 @@ if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const tls = require('tls');

const assert = require('assert');
const { spawn } = require('child_process');
Copy link
Member

Choose a reason for hiding this comment

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

At the moment, the test writing guide says:

The require statements are sorted in ASCII order (digits, upper case, _, lower case).

It's not clear to me if this refers to the variable names or the module names. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

@sam-github? Ref: 02b9270

Since the whole paragraph's subject is modules, my intuition says sort by module name.
(also congruent with Jewish law that states you bless food according to the main ingredient and not by how you eat it 😉)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW, I think module name sorting would be more consistent here, as we can use many variable names in destructuring and only one module name. See examples.

const fs = require('fs');
const spawn = require('child_process').spawn;
const path = require('path');
const tls = require('tls');

let success = false;

function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', `${n}.pem`);
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
}

function loadPEM(n) {
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-tls-alpn-server-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ if (!process.features.tls_alpn || !process.features.tls_npn) {

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tls = require('tls');

function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', `${n}.pem`);
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
}

function loadPEM(n) {
Expand Down
7 changes: 4 additions & 3 deletions test/parallel/test-tls-client-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@

'use strict';
const common = require('../common');
const assert = require('assert');

if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const tls = require('tls');

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tls = require('tls');

const hosterr = /Hostname\/IP doesn't match certificate's altnames/;
const testCases =
Expand Down Expand Up @@ -65,7 +66,7 @@ const testCases =
];

function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', `${n}.pem`);
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
}


Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-cnnic-whitelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ if (!common.hasCrypto) {
}

const assert = require('assert');
const tls = require('tls');
const fs = require('fs');
const path = require('path');
const tls = require('tls');

function filenamePEM(n) {
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
Expand Down
10 changes: 5 additions & 5 deletions test/parallel/test-tls-npn-server-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ if (!process.features.tls_npn) {
return;
}

const assert = require('assert');
const fs = require('fs');

if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const tls = require('tls');

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tls = require('tls');

function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', `${n}.pem`);
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
}

function loadPEM(n) {
Expand Down
28 changes: 14 additions & 14 deletions test/parallel/test-tls-server-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ if (!common.opensslCli) {
return;
}

if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}

// This is a rather complex test which sets up various TLS servers with node
// and connects to them using the 'openssl s_client' command line utility
// with various keys. Depending on the certificate authority and other
Expand All @@ -35,6 +40,14 @@ if (!common.opensslCli) {
// - accepted and "unauthorized", or
// - accepted and "authorized".

const assert = require('assert');
const { spawn } = require('child_process');
const { SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION } =
require('crypto').constants;
const fs = require('fs');
const path = require('path');
const tls = require('tls');

const testCases =
[{ title: 'Do not request certs. Everyone is unauthorized.',
requestCert: false,
Expand Down Expand Up @@ -119,22 +132,9 @@ const testCases =
}
];

if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const tls = require('tls');

const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION =
require('crypto').constants.SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION;

const assert = require('assert');
const fs = require('fs');
const spawn = require('child_process').spawn;


function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', `${n}.pem`);
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
}


Expand Down
9 changes: 5 additions & 4 deletions test/parallel/test-tls-sni-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ if (!process.features.tls_sni) {
return;
}

const assert = require('assert');
const fs = require('fs');

if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tls = require('tls');

function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', `${n}.pem`);
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
}

function loadPEM(n) {
Expand Down
9 changes: 5 additions & 4 deletions test/parallel/test-tls-sni-server-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ if (!process.features.tls_sni) {
return;
}

const assert = require('assert');
const fs = require('fs');

if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tls = require('tls');

function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', `${n}.pem`);
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
}

function loadPEM(n) {
Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-tls-startcom-wosign-whitelist.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
'use strict';
const common = require('../common');
const assert = require('assert');

if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}

const tls = require('tls');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tls = require('tls');

let finished = 0;

function filenamePEM(n) {
Expand Down