This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
184 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ | |
"yargs": "^3.32.0" | ||
}, | ||
"dependencies": { | ||
"cookie": "^0.2.3", | ||
"isomorphic-fetch": "^2.2.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
var _mocha = require('mocha'); | ||
|
||
var _chai = require('chai'); | ||
|
||
var _auth = require('../../dist/auth'); | ||
|
||
(0, _mocha.describe)('auth.check', function () { | ||
var nonExistingUsername = process.env.NON_EXISTING_USERNAME; | ||
var username = process.env.USERNAME; | ||
var password = process.env.PASSWORD; | ||
|
||
(0, _mocha.it)('should be defined and return false if parameter is not valid', function () { | ||
_chai.assert.ok(_auth.check); | ||
_chai.assert.ok(!(0, _auth.check)()); | ||
}); | ||
|
||
(0, _mocha.it)('should return a Promise if login parameter is given', function () { | ||
_chai.assert.ok((0, _auth.check)({ login: username, password: password }) instanceof Promise); | ||
}); | ||
|
||
(0, _mocha.it)('should resolve to an object with playerme_session if valid', function (done) { | ||
(0, _auth.check)({ login: username, password: password }).then(function (user) { | ||
_chai.assert.typeOf(user, 'object'); | ||
_chai.assert.ok(user.id); | ||
_chai.assert.equal(user.username, username); | ||
_chai.assert.ok(user.playerme_session); | ||
done(); | ||
}).catch(function () { | ||
done(new Error('env username and or password is incorrect')); | ||
}); | ||
}); | ||
|
||
(0, _mocha.it)('should reject with an error if not valid', function (done) { | ||
(0, _auth.check)({ login: nonExistingUsername, password: password }).then(function () { | ||
done(new Error('env non-existing user exists')); | ||
}).catch(function (error) { | ||
_chai.assert.ok(error.message); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { describe, it } from 'mocha'; | ||
import { assert } from 'chai'; | ||
|
||
import { check } from '../../dist/auth'; | ||
|
||
describe('auth.check', () => { | ||
const nonExistingUsername = process.env.NON_EXISTING_USERNAME; | ||
const username = process.env.USERNAME; | ||
const password = process.env.PASSWORD; | ||
|
||
it('should be defined and return false if parameter is not valid', () => { | ||
assert.ok(check); | ||
assert.ok(!check()); | ||
}); | ||
|
||
it('should return a Promise if login parameter is given', () => { | ||
assert.ok(check({ login: username, password }) instanceof Promise); | ||
}); | ||
|
||
it('should resolve to an object with playerme_session if valid', (done) => { | ||
check({ login: username, password }) | ||
.then((user) => { | ||
assert.typeOf(user, 'object'); | ||
assert.ok(user.id); | ||
assert.equal(user.username, username); | ||
assert.ok(user.playerme_session); | ||
done(); | ||
}) | ||
.catch(() => { | ||
done(new Error('env username and or password is incorrect')); | ||
}); | ||
}); | ||
|
||
it('should reject with an error if not valid', (done) => { | ||
check({ login: nonExistingUsername, password }) | ||
.then(() => { | ||
done(new Error('env non-existing user exists')); | ||
}).catch((error) => { | ||
assert.ok(error.message); | ||
done(); | ||
}); | ||
}); | ||
}); |