Skip to content

Commit ef34d8a

Browse files
authored
Merge pull request #949 from alantrrs/fix-memory-creds
Define GIT_SSH_MEMORY_CREDENTIALS for libgit2
2 parents e2ccac1 + f61f52e commit ef34d8a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

test/tests/cred.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var assert = require("assert");
22
var path = require("path");
3+
var fs = require("fs");
34
var local = path.join.bind(path, __dirname);
45

56
describe("Cred", function() {
@@ -23,6 +24,23 @@ describe("Cred", function() {
2324
assert.ok(cred instanceof NodeGit.Cred);
2425
});
2526

27+
it("can create ssh credentials using passed keys in memory", function() {
28+
var publicKeyContents = fs.readFileSync(sshPublicKey, {
29+
encoding: "ascii"
30+
});
31+
var privateKeyContents = fs.readFileSync(sshPrivateKey, {
32+
encoding: "ascii"
33+
});
34+
35+
return NodeGit.Cred.sshKeyMemoryNew(
36+
"username",
37+
publicKeyContents,
38+
privateKeyContents,
39+
"").then(function(cred) {
40+
assert.ok(cred instanceof NodeGit.Cred);
41+
});
42+
});
43+
2644
it("can create credentials using plaintext", function() {
2745
var plaintextCreds = NodeGit.Cred.userpassPlaintextNew
2846
("username", "password");

vendor/libgit2.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"defines": [
1717
"GIT_THREADS",
1818
"GIT_SSH",
19+
"GIT_SSH_MEMORY_CREDENTIALS",
1920
# Node's util.h may be accidentally included so use this to guard
2021
# against compilation error.
2122
"SRC_UTIL_H_",

0 commit comments

Comments
 (0)