forked from bankonme/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.auth.js
More file actions
41 lines (33 loc) · 979 Bytes
/
test.auth.js
File metadata and controls
41 lines (33 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
var test = require('tape'); //jshint ignore:line
var Github = require("../");
var test_user = require('./user.json');
test("Basic Auth - Pass", function(t) {
var timeout = setTimeout(function () { t.fail(); }, 10000);
var github = new Github({
username: test_user.USERNAME,
password: test_user.PASSWORD,
auth: "basic"
});
var user = github.getUser();
user.notifications(function(err) {
t.error(err, 'user is authd');
});
clearTimeout(timeout);
t.end();
});
test("Basic Auth - Fail", function(t) {
var timeout = setTimeout(function () { t.fail(); }, 10000);
var github = new Github({
username: test_user.USERNAME,
password: 'fake124',
auth: "basic"
});
var user = github.getUser();
user.notifications(function(err) {
t.ok(err, 'user is not authd');
t.equals(JSON.parse(err.request.responseText).message, 'Bad credentials', 'confirm error');
});
clearTimeout(timeout);
t.end();
});