forked from simonepri/phc-argon2
-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
b86ef77
commit 18d1627
Showing
4 changed files
with
60 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,86 @@ | ||
import test from 'ava'; | ||
|
||
import m from '..'; | ||
import m from '../index.js'; | ||
|
||
test("should throw an error if the 'iterations' option is not a number", async (t) => { | ||
const err = await t.throwsAsync(async () => { | ||
const error = await t.throwsAsync(async () => { | ||
await m.hash('password', {iterations: 'iterations'}); | ||
}); | ||
t.is(err.message, "The 'iterations' option must be an integer"); | ||
t.is(error.message, "The 'iterations' option must be an integer"); | ||
}); | ||
|
||
test("should throw an error if the 'iterations' option is out of range", async (t) => { | ||
let err = await t.throwsAsync(async () => { | ||
let error = await t.throwsAsync(async () => { | ||
await m.hash('password', {iterations: -1}); | ||
}); | ||
t.regex(err.message, /The 'iterations' option must be in the range/); | ||
t.regex(error.message, /The 'iterations' option must be in the range/); | ||
|
||
err = await t.throwsAsync(async () => { | ||
error = await t.throwsAsync(async () => { | ||
await m.hash('password', {iterations: 2 ** 32}); | ||
}); | ||
t.regex(err.message, /The 'iterations' option must be in the range/); | ||
t.regex(error.message, /The 'iterations' option must be in the range/); | ||
}); | ||
|
||
test("should throw an error if the 'memory' option is not a number", async (t) => { | ||
const err = await t.throwsAsync(async () => { | ||
const error = await t.throwsAsync(async () => { | ||
await m.hash('password', {memory: 'memory'}); | ||
}); | ||
t.is(err.message, "The 'memory' option must be an integer"); | ||
t.is(error.message, "The 'memory' option must be an integer"); | ||
}); | ||
|
||
test("should throw an error if the 'memory' option is out of range", async (t) => { | ||
let err = await t.throwsAsync(async () => { | ||
let error = await t.throwsAsync(async () => { | ||
await m.hash('password', {memory: -1}); | ||
}); | ||
t.regex(err.message, /The 'memory' option must be in the range/); | ||
t.regex(error.message, /The 'memory' option must be in the range/); | ||
|
||
err = await t.throwsAsync(async () => { | ||
error = await t.throwsAsync(async () => { | ||
await m.hash('password', {memory: 2 ** 32}); | ||
}); | ||
t.regex(err.message, /The 'memory' option must be in the range/); | ||
t.regex(error.message, /The 'memory' option must be in the range/); | ||
}); | ||
|
||
test("should throw an error if the 'parallelism' option is not a number", async (t) => { | ||
const err = await t.throwsAsync(async () => { | ||
const error = await t.throwsAsync(async () => { | ||
await m.hash('password', {parallelism: 'parallelism'}); | ||
}); | ||
t.is(err.message, "The 'parallelism' option must be an integer"); | ||
t.is(error.message, "The 'parallelism' option must be an integer"); | ||
}); | ||
|
||
test("should throw an error if the 'parallelism' option is out of range", async (t) => { | ||
let err = await t.throwsAsync(async () => { | ||
let error = await t.throwsAsync(async () => { | ||
await m.hash('password', {parallelism: -1}); | ||
}); | ||
t.regex(err.message, /The 'parallelism' option must be in the range/); | ||
t.regex(error.message, /The 'parallelism' option must be in the range/); | ||
|
||
err = await t.throwsAsync(async () => { | ||
error = await t.throwsAsync(async () => { | ||
await m.hash('password', {parallelism: 2 ** 24}); | ||
}); | ||
t.regex(err.message, /The 'parallelism' option must be in the range/); | ||
t.regex(error.message, /The 'parallelism' option must be in the range/); | ||
}); | ||
|
||
test("should throw an error if the 'variant' option is not a string", async (t) => { | ||
const err = await t.throwsAsync(async () => { | ||
const error = await t.throwsAsync(async () => { | ||
await m.hash('password', {variant: 1}); | ||
}); | ||
t.is(err.message, "The 'variant' option must be a string"); | ||
t.is(error.message, "The 'variant' option must be a string"); | ||
}); | ||
|
||
test("should throw an error if the 'variant' option is unsupported", async (t) => { | ||
const err = await t.throwsAsync(async () => { | ||
const error = await t.throwsAsync(async () => { | ||
await m.hash('password', {variant: 's'}); | ||
}); | ||
t.regex(err.message, /The 'variant' option must be one of:/); | ||
t.regex(error.message, /The 'variant' option must be one of:/); | ||
}); | ||
|
||
test("should throw an error if the 'saltSize' option is out of range", async (t) => { | ||
let err = await t.throwsAsync(async () => { | ||
let error = await t.throwsAsync(async () => { | ||
await m.hash('password', {saltSize: -1}); | ||
}); | ||
t.regex(err.message, /The 'saltSize' option must be in the range/); | ||
t.regex(error.message, /The 'saltSize' option must be in the range/); | ||
|
||
err = await t.throwsAsync(async () => { | ||
error = await t.throwsAsync(async () => { | ||
await m.hash('password', {saltSize: 1025}); | ||
}); | ||
t.regex(err.message, /The 'saltSize' option must be in the range/); | ||
t.regex(error.message, /The 'saltSize' option must be in the range/); | ||
}); |
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