-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwhoami.js
More file actions
39 lines (35 loc) · 930 Bytes
/
whoami.js
File metadata and controls
39 lines (35 loc) · 930 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
const nit = require('./lib/nit')('GET /-/whoami');
const requests = require('./lib/requests');
/**
* Test coverage for the whoami route
* See: curl https://{AUTH}@registry.npmjs.org/-/whoami
*/
module.exports.auth = nit(':api with basic auth', function (opts) {
return function (done) {
requests.authed({
host: opts.registry,
username: opts.username,
password: opts.password,
path: '/-/whoami',
method: 'GET',
status: 200,
body: { username: opts.username }
}, done);
};
});
module.exports.bearerToken = nit.skip(':api with bearer token', function () {
return function () {
throw new Error('Not implemented.');
};
});
module.exports.noAuth = nit(':api with no auth', function (opts) {
return function (done) {
requests.json({
host: opts.registry,
path: '/-/whoami',
method: 'GET',
status: 401,
body: {}
}, done);
};
});