mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
starting to write tests
This commit is contained in:
parent
bdd748c6e2
commit
6c78876dcd
4 changed files with 54 additions and 0 deletions
|
@ -27,6 +27,9 @@ dependencies:
|
|||
minimatch: '*'
|
||||
through: '*'
|
||||
|
||||
devDependencies:
|
||||
galaxy: '*' # and node 0.11.2+ for testing
|
||||
|
||||
keywords: # TODO
|
||||
- private
|
||||
- repository
|
||||
|
|
12
test/config.yaml
Normal file
12
test/config.yaml
Normal file
|
@ -0,0 +1,12 @@
|
|||
storage: ./test-storage
|
||||
|
||||
users:
|
||||
test:
|
||||
password: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
|
||||
|
||||
packages:
|
||||
'*':
|
||||
allow_access: test
|
||||
allow_publish: test
|
||||
|
||||
listen: 55550
|
22
test/lib/auth.js
Normal file
22
test/lib/auth.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
var request = require('request');
|
||||
var assert = require('assert');
|
||||
|
||||
module.exports.auth = function(user, pass, cb) {
|
||||
request({
|
||||
url: 'http://localhost:55550/-/user/org.couchdb.user:'+escape(user)+'/-rev/undefined',
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
'user-agent': 'node/v0.10.8 linux x64',
|
||||
authorization: 'Basic '+(new Buffer(user+':'+pass)).toString('base64'),
|
||||
},
|
||||
json: {
|
||||
content: "doesn't matter, 'cause sinopia uses info from Authorization header anywayz",
|
||||
}
|
||||
}, function(req, res, body) {
|
||||
assert.notEqual(body.ok.indexOf('"'+user+'"'), -1);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
17
test/run.js
Executable file
17
test/run.js
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/local/bin/node --harmony
|
||||
|
||||
var galaxy = require('galaxy');
|
||||
var Auth = galaxy.star(require('./lib/auth'));
|
||||
|
||||
var sleep = galaxy.star(function(ms, cb) {
|
||||
setTimeout(cb, ms);
|
||||
});
|
||||
|
||||
process.argv = ['node', 'sinopia', '-c', './config.yaml'];
|
||||
require('../bin/sinopia');
|
||||
|
||||
galaxy.unstar(function*() {
|
||||
sleep(1000);
|
||||
yield Auth.auth('test', 'test');
|
||||
})();
|
||||
|
Loading…
Reference in a new issue