Skip to content

Commit 90f88a6

Browse files
committed
Fixed clone test
Added first pass check, then return default credentials for all other occurences. The credentials will pass back the credentials we want it to, then pass back a default credentials set for all other occurences. Thus stopping the credentials cb loop.
1 parent 4a9cfa9 commit 90f88a6

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

test/tests/clone.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,28 @@ describe("Clone", function() {
151151
});
152152
});
153153

154-
it("will not segfault when accessing a url without username", function() {
154+
it.only("will not segfault when accessing a url without username", function(){
155155
var url = "https://github.com/nodegit/private";
156156

157+
var firstPass = true;
158+
157159
return Clone(url, clonePath, {
158160
fetchOpts: {
159161
callbacks: {
160162
certificateCheck: function() {
161163
return 1;
162164
},
163165
credentials: function() {
164-
return NodeGit.Cred.userpassPlaintextNew("fake-token",
165-
"x-oauth-basic");
166+
if (firstPass) {
167+
firstPass = false;
168+
return NodeGit.Cred.userpassPlaintextNew("fake-token",
169+
"x-oauth-basic");
170+
} else {
171+
return NodeGit.Cred.defaultNew();
172+
}
166173
}
167174
}
168175
}
169-
}).catch(function unhandledError() { });
176+
}).catch(function(reason) { });
170177
});
171178
});

test/tests/remote.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,16 @@ describe("Remote", function() {
194194
var firstPass = true;
195195
var options = {
196196
callbacks: {
197-
credentials:function(url, userName) {
197+
credentials: function(url, userName) {
198198
if (firstPass) {
199+
firstPass = false;
199200
if (url.indexOf("https") === -1) {
200201
return NodeGit.Cred.sshKeyFromAgent(userName);
201202
} else {
202-
return NodeGit.Cred.defaultNew();
203+
return NodeGit.Cred.userpassPlaintextNew(userName, "");
203204
}
205+
} else {
206+
return NodeGit.Cred.defaultNew();
204207
}
205208
},
206209
certificateCheck: function() {

0 commit comments

Comments
 (0)