Skip to content

Commit 30891f7

Browse files
committed
Better auth check
1 parent 07d1dea commit 30891f7

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

test/test.auth.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,30 @@ test("Basic Auth - Pass", function(t) {
1111
});
1212
var user = github.getUser();
1313

14-
t.equals(Object.keys(user).length, 10);
15-
t.equals(Object.keys(user).indexOf('repos') > -1, true);
14+
user.notifications(function(err, res) {
15+
t.error(err, 'user is authd');
16+
});
17+
1618
clearTimeout(timeout);
1719
t.end();
1820

1921
});
2022

23+
test("Basic Auth - Fail", function(t) {
24+
var timeout = setTimeout(function () { t.fail(); }, 10000);
25+
var github = new Github({
26+
username: test_user.USERNAME,
27+
password: 'fake124',
28+
auth: "basic"
29+
});
30+
var user = github.getUser();
31+
32+
user.notifications(function(err, res) {
33+
t.ok(err, 'user is not authd');
34+
t.equals(JSON.parse(err.request.responseText).message, 'Bad credentials', 'confirm error');
35+
});
36+
37+
clearTimeout(timeout);
38+
t.end();
39+
40+
});

0 commit comments

Comments
 (0)