Skip to content

Commit

Permalink
New test: clone with ssh using agent with no sha2 signing support
Browse files Browse the repository at this point in the history
Only for windows
  • Loading branch information
julianmesa-gitkraken committed Jan 18, 2022
1 parent 7502bd9 commit 3196a64
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"esversion": 9,
"boss": true,
"curly": true,
"eqnull": true,
"esnext": true,
"evil": true,
"futurehostile": true,
"globals": {
Expand All @@ -16,7 +16,7 @@
"it": true
},
"immed": false,
"maxlen": 80,
"maxlen": 120,
"node": true,
"predef": [
"Promise",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
63 changes: 63 additions & 0 deletions test/tests/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}/`;
Expand Down Expand Up @@ -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";
Expand Down
Binary file modified vendor/pageant.exe
Binary file not shown.
Binary file added vendor/pageant_sha1.exe
Binary file not shown.

0 comments on commit 3196a64

Please sign in to comment.