diff --git a/.jshintrc b/.jshintrc index 0fd02f29b6..437878c8ce 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,8 +1,8 @@ { + "esversion": 9, "boss": true, "curly": true, "eqnull": true, - "esnext": true, "evil": true, "futurehostile": true, "globals": { @@ -16,7 +16,7 @@ "it": true }, "immed": false, - "maxlen": 80, + "maxlen": 120, "node": true, "predef": [ "Promise", diff --git a/package.json b/package.json index 70db2ef1a5..b3b80c9086 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "coveralls": "^3.0.2", "istanbul": "^0.4.5", "js-beautify": "~1.5.10", - "jshint": "^2.9.6", + "jshint": "^2.10.0", "lcov-result-merger": "^3.1.0", "mocha": "^5.2.0", "walk": "^2.3.9" diff --git a/test/tests/clone.js b/test/tests/clone.js index e69076f9d4..929f004a01 100644 --- a/test/tests/clone.js +++ b/test/tests/clone.js @@ -3,6 +3,9 @@ var assert = require("assert"); var fse = require("fs-extra"); var local = path.join.bind(path, __dirname); var _ = require("lodash"); +const util = require("util"); +const exec = util.promisify(require("child_process").exec); + const generatePathWithLength = (base, length) => { let path = `${base}/`; @@ -286,6 +289,66 @@ describe("Clone", function() { }); }); + if (process.platform === "win32") { + it("can clone with ssh using old agent with sha1 signing support only", + async function () { + var pageant = local("../../vendor/pageant.exe"); + var old_pageant = local("../../vendor/pageant_sha1.exe"); + var privateKey = local("../../vendor/private.ppk"); + var test = this; + var url = "git@github.com:nodegit/test.git"; + var opts = { + fetchOpts: { + callbacks: { + certificateCheck: () => 0, + credentials: function(url, userName) { + return NodeGit.Credential.sshKeyFromAgent(userName); + } + } + } + }; + + try { + await exec("taskkill /im pageant.exe /f /t"); + } catch (e) { + try { + await exec("taskkill /im pageant_sha1.exe /f /t"); + } catch(e) {} + try { + await exec(`powershell -command "Start-Process ${pageant} ${privateKey}`); + } catch (e) {} + return assert.fail("Cannot kill pageant"); + } + try { + await exec(`powershell -command "Start-Process ${old_pageant} ${privateKey}`); + } catch (e) { + try { + await exec(`powershell -command "Start-Process ${pageant} ${privateKey}`); + } catch (e) {} + return assert.fail("Cannot run old pageant"); + } + + try { + const repo = await Clone(url, clonePath, opts); + test.repository = repo; + } catch(e) { + return assert.fail("Clone error: " + e.message); + } + + try { + await exec("taskkill /im pageant_sha1.exe /f /t"); + } catch(e) {} + + try { + await exec(`powershell -command "Start-Process ${pageant} ${privateKey}`); + } catch (e) { + return assert.fail("Cannot run pageant"); + } + + return assert.ok(test.repository instanceof Repository); + }); + } + it("can clone with ssh", function() { var test = this; var url = "git@github.com:nodegit/test.git"; diff --git a/vendor/pageant.exe b/vendor/pageant.exe index f11c378002..a57f2a466b 100644 Binary files a/vendor/pageant.exe and b/vendor/pageant.exe differ diff --git a/vendor/pageant_sha1.exe b/vendor/pageant_sha1.exe new file mode 100644 index 0000000000..f11c378002 Binary files /dev/null and b/vendor/pageant_sha1.exe differ