summaryrefslogtreecommitdiff
path: root/tests/scrypt.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/scrypt.go')
-rw-r--r--tests/scrypt.go56
1 files changed, 31 insertions, 25 deletions
diff --git a/tests/scrypt.go b/tests/scrypt.go
index 0a9f599..2158e64 100644
--- a/tests/scrypt.go
+++ b/tests/scrypt.go
@@ -309,7 +309,7 @@ func test_usage() {
usage("xxx", &w)
expected := g.Heredoc(`
- Usage: xxx PASSWORD SALT
+ Usage: xxx [-c]
`)
g.TAssertEqual(w.String(), expected)
})
@@ -319,7 +319,7 @@ func test_getopt() {
g.TestStart("getopt()")
usage := g.Heredoc(`
- Usage: $0 PASSWORD SALT
+ Usage: $0 [-c]
`)
g.Testing("we suppress the default error message", func() {
@@ -341,17 +341,28 @@ func test_getopt() {
g.TAssertEqual(rc, 2)
})
- g.Testing("the args have the input data", func() {
+ g.Testing("the args have the strings untouched", func() {
w := strings.Builder{}
argv := []string{"$0", "abcdef", "aaaabbbbccccdddd"}
args, rc := getopt(argv, &w)
expected := argsT{
allArgs: []string{"$0", "abcdef", "aaaabbbbccccdddd"},
- input: HashInputT{
- Password: []byte("abcdef"),
- Salt: []byte("aaaabbbbccccdddd"),
- },
+ isCheck: false,
+ }
+
+ g.TAssertEqual(args, expected)
+ g.TAssertEqual(rc, 0)
+ })
+
+ g.Testing("isCheck is true", func() {
+ w := strings.Builder{}
+ argv := []string{"$0", "-c", "aaaabbbbccccdddd"}
+ args, rc := getopt(argv, &w)
+
+ expected := argsT{
+ allArgs: []string{"$0", "-c", "aaaabbbbccccdddd"},
+ isCheck: true,
}
g.TAssertEqual(args, expected)
@@ -365,39 +376,34 @@ func test_run() {
g.Testing("a small salt returns 1", func() {
w := strings.Builder{}
env := envT{
- args: argsT{
- input: HashInputT{
- Salt: []byte("a salt"),
- },
- },
+ in: strings.NewReader("612073616C74\naa\n"),
err: &w,
}
rc := run(env)
- g.TAssertEqual(rc, 1)
+ g.TAssertEqual(rc, 2)
g.TAssertEqual(w.String(), "scrypt: salt is too small\n")
})
g.Testing("return of 0 and output otherwise", func() {
- w := strings.Builder{}
+ out := strings.Builder{}
+ err := strings.Builder{}
env := envT{
- args: argsT{
- input: HashInputT{
- Salt: []byte(
- "eeeeffffgggghhhh" +
- "iiiijjjjjkkkkllll",
- ),
- Password: []byte("password"),
- },
- },
- out: &w,
+ in: strings.NewReader(
+ "70617373776F7264\n" +
+ "6565656566666666676767676868686869" +
+ "6969696A6A6A6A6A6B6B6B6B6C6C6C6C\n",
+ ),
+ out: &out,
+ err: &err,
}
const expected =
"9073ca9ad51942a30b20af1747e98195" +
"960e76fd8f20b246821692ce82c2d6f7\n"
rc := run(env)
- g.TAssertEqual(w.String(), expected)
+ g.TAssertEqual(out.String(), expected)
+ g.TAssertEqual(err.String(), "")
g.TAssertEqual(rc, 0)
})
}