2020-03-25 17:02:04 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) Sapphirecode - All Rights Reserved
|
|
|
|
* This file is part of Password-Helper which is released under MIT.
|
|
|
|
* See file 'LICENSE' for full license details.
|
|
|
|
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
|
|
|
*/
|
|
|
|
|
2020-03-04 13:21:54 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const helper = require ('../index');
|
|
|
|
const test = require ('ava');
|
|
|
|
|
|
|
|
test ('create hash', async (t) => {
|
|
|
|
const hash = await helper.hash ('foo');
|
|
|
|
t.is (typeof hash, 'string');
|
|
|
|
});
|
|
|
|
|
|
|
|
test ('validate', async (t) => {
|
|
|
|
const hash = await helper.hash ('foo');
|
|
|
|
const valid = await helper.verify (hash, 'foo');
|
|
|
|
t.is (valid, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
test ('fail validation', async (t) => {
|
|
|
|
const hash = await helper.hash ('foo');
|
|
|
|
const valid = await helper.verify (hash, 'bar');
|
|
|
|
t.is (valid, false);
|
|
|
|
});
|