Skip to content

Commit 0022e22

Browse files
New test: clone with ssh using agent with no sha2 signing support
Only for windows
1 parent 7502bd9 commit 0022e22

File tree

5 files changed

+66
-3
lines changed

5 files changed

+66
-3
lines changed

.jshintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2+
"esversion": 9,
23
"boss": true,
34
"curly": true,
45
"eqnull": true,
5-
"esnext": true,
66
"evil": true,
77
"futurehostile": true,
88
"globals": {
@@ -16,7 +16,7 @@
1616
"it": true
1717
},
1818
"immed": false,
19-
"maxlen": 80,
19+
"maxlen": 120,
2020
"node": true,
2121
"predef": [
2222
"Promise",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"coveralls": "^3.0.2",
5959
"istanbul": "^0.4.5",
6060
"js-beautify": "~1.5.10",
61-
"jshint": "^2.9.6",
61+
"jshint": "^2.10.0",
6262
"lcov-result-merger": "^3.1.0",
6363
"mocha": "^5.2.0",
6464
"walk": "^2.3.9"

test/tests/clone.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ var assert = require("assert");
33
var fse = require("fs-extra");
44
var local = path.join.bind(path, __dirname);
55
var _ = require("lodash");
6+
const util = require("util");
7+
const exec = util.promisify(require("child_process").exec);
8+
69

710
const generatePathWithLength = (base, length) => {
811
let path = `${base}/`;
@@ -286,6 +289,66 @@ describe("Clone", function() {
286289
});
287290
});
288291

292+
if (process.platform === "win32") {
293+
it("can clone with ssh using old agent with sha1 signing support only",
294+
async function () {
295+
var pageant = local("../../vendor/pageant.exe");
296+
var old_pageant = local("../../vendor/pageant_sha1.exe");
297+
var privateKey = local("../../vendor/private.ppk");
298+
var test = this;
299+
var url = "git@github.com:nodegit/test.git";
300+
var opts = {
301+
fetchOpts: {
302+
callbacks: {
303+
certificateCheck: () => 0,
304+
credentials: function(url, userName) {
305+
return NodeGit.Credential.sshKeyFromAgent(userName);
306+
}
307+
}
308+
}
309+
};
310+
311+
try {
312+
await exec("taskkill /im pageant.exe /f /t");
313+
} catch (e) {
314+
try {
315+
await exec("taskkill /im pageant_sha1.exe /f /t");
316+
} catch(e) {}
317+
try {
318+
await exec(pageant, [privateKey]);
319+
} catch (e) {}
320+
return assert.fail("Cannot kill pageant");
321+
}
322+
try {
323+
await exec(`powershell -command "Start-Process ${old_pageant} ${privateKey}`);
324+
} catch (e) {
325+
try {
326+
await exec(`powershell -command "Start-Process ${pageant} ${privateKey}`);
327+
} catch (e) {}
328+
return assert.fail("Cannot run old pageant");
329+
}
330+
331+
try {
332+
const repo = await Clone(url, clonePath, opts);
333+
test.repository = repo;
334+
} catch(e) {
335+
return assert.fail("Clone error: " + e.message);
336+
}
337+
338+
try {
339+
await exec("taskkill /im pageant_sha1.exe /f /t");
340+
} catch(e) {}
341+
342+
try {
343+
await exec(`powershell -command "Start-Process ${pageant} ${privateKey}`);
344+
} catch (e) {
345+
return assert.fail("Cannot run pageant");
346+
}
347+
348+
return assert.ok(test.repository instanceof Repository);
349+
});
350+
}
351+
289352
it("can clone with ssh", function() {
290353
var test = this;
291354
var url = "git@github.com:nodegit/test.git";

vendor/pageant.exe

559 KB
Binary file not shown.

vendor/pageant_sha1.exe

144 KB
Binary file not shown.

0 commit comments

Comments
 (0)