forked from octokit/octokit.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAuthenticationTest.js
73 lines (62 loc) · 2.2 KB
/
AuthenticationTest.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* Copyright 2010 Ajax.org B.V.
*
* This product includes software developed by
* Ajax.org B.V. (http://www.ajax.org/).
*
* Author: Fabian Jaokbs <[email protected]>
*/
"use strict";
var assert = require("assert");
var GitHubApi = require("../github").GitHubApi;
var username = "fjakobstest";
var token = "b98166e45acf66df70a992e2de56b92a";
var repo = "o3";
var test = module.exports = {
setUp: function() {
this.github = new GitHubApi(true);
this.userApi = this.github.getUserApi();
},
"test: show user without authentification should have no 'plan'" : function(finished) {
test.userApi.show(username, function(err, user) {
assert.equal(user.plan, undefined);
finished();
});
},
"test: show user with authentification should have a 'plan'" : function(finished) {
test.github.authenticateToken(username, token);
test.userApi.show(username, function(err, user) {
assert.ok(user.plan !== undefined);
finished();
});
},
/*
// test disabled because I don't want to see my password on github :-)
"test: authenticate using username and password" : function(finished) {
test.github.authenticatePassword("fjakobs", "xxxx");
test.userApi.show("fjakobs", function(err, user) {
assert.ok(user.plan !== undefined);
console.log(user)
test.github.getRepoApi().getUserRepos("fjakobs", null, function(err, repos) {
console.log(repos)
finished();
})
});
},
*/
"test: authenticate using username and wrong password" : function(finished) {
test.github.authenticatePassword(username, "1234");
test.userApi.show(username, function(err, user) {
assert.ok(err !== undefined);
finished();
});
},
"test: authenticate with bad token" : function(finished) {
test.github.authenticateToken(username, "bad-token");
test.userApi.show(username, function(err, user) {
assert.ok(err !== undefined);
finished();
});
}
};
!module.parent && require("asyncjs").test.testcase(module.exports).exec();