Skip to content

Commit

Permalink
Implemented tests for the Authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed May 20, 2017
1 parent 43f934f commit 2f02c2b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/tests/authentication.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var webdav = require('../../lib/index.js'),
Client = require('webdav-fs');

module.exports = (test, options, index) => test('authentication', isValid =>
{
var server = new webdav.WebDAVServer();
server.start(options.port + index);
isValid = isValid.multiple(2, server);
const _ = (e, cb) => {
if(e)
isValid(false, e);
else
cb();
}

server.userManager.addUser('usernameX', 'password');

const url = 'http://127.0.0.1:' + (options.port + index);

const wfs = Client(url, 'usernameX', 'password');

server.rootResource.addChild(new webdav.VirtualFolder('test'), e => _(e, () => {
wfs.stat('/test', (e, stat) => {
isValid(!e);
})

const wfs2 = Client(url, 'invalidUsername', 'password');

wfs2.stat('/test', (e, stat) => {
isValid(!!e);
})
}))
})

0 comments on commit 2f02c2b

Please sign in to comment.