From 4ce56b28be2e4cd020fda26f765365293cb5c496 Mon Sep 17 00:00:00 2001 From: Daniel Axelrod Date: Wed, 21 Oct 2015 18:13:46 -0400 Subject: [PATCH] Define GIT_SSH_MEMORY_CREDENTIALS for libgit2 Compile libgit2 with GIT_SSH_MEMORY_CREDENTIALS defined to allow sshKeyMemoryNew to work. Fixes #760 --- test/tests/cred.js | 18 ++++++++++++++++++ vendor/libgit2.gyp | 1 + 2 files changed, 19 insertions(+) diff --git a/test/tests/cred.js b/test/tests/cred.js index 7500dc303..6f0bb46ad 100644 --- a/test/tests/cred.js +++ b/test/tests/cred.js @@ -1,5 +1,6 @@ var assert = require("assert"); var path = require("path"); +var fs = require("fs"); var local = path.join.bind(path, __dirname); describe("Cred", function() { @@ -23,6 +24,23 @@ describe("Cred", function() { assert.ok(cred instanceof NodeGit.Cred); }); + it("can create ssh credentials using passed keys in memory", function() { + var publicKeyContents = fs.readFileSync(sshPublicKey, { + encoding: "ascii" + }); + var privateKeyContents = fs.readFileSync(sshPrivateKey, { + encoding: "ascii" + }); + + return NodeGit.Cred.sshKeyMemoryNew( + "username", + publicKeyContents, + privateKeyContents, + "").then(function(cred) { + assert.ok(cred instanceof NodeGit.Cred); + }); + }); + it("can create credentials using plaintext", function() { var plaintextCreds = NodeGit.Cred.userpassPlaintextNew ("username", "password"); diff --git a/vendor/libgit2.gyp b/vendor/libgit2.gyp index 8880a2438..cccaa388c 100644 --- a/vendor/libgit2.gyp +++ b/vendor/libgit2.gyp @@ -16,6 +16,7 @@ "defines": [ "GIT_THREADS", "GIT_SSH", + "GIT_SSH_MEMORY_CREDENTIALS", # Node's util.h may be accidentally included so use this to guard # against compilation error. "SRC_UTIL_H_",