Skip to content

Commit

Permalink
Merge pull request go-sql-driver#191 from arnehormann/oldpass-test
Browse files Browse the repository at this point in the history
add test for scrambleOldPassword
  • Loading branch information
arnehormann committed Dec 8, 2013
2 parents b1aa46e + 602a004 commit 9724877
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,23 @@ func TestLengthEncodedInteger(t *testing.T) {
t.Errorf("%v: expected %x, got %x", num, tst.encoded, encoded)
}
}
}

func TestOldPass(t *testing.T) {
scramble := []byte{9, 8, 7, 6, 5, 4, 3, 2}
vectors := []struct {
pass string
out string
}{
{" pass", "47575c5a435b4251"},
{"pass ", "47575c5a435b4251"},
{"123\t456", "575c47505b5b5559"},
{"C0mpl!ca ted#PASS123", "5d5d554849584a45"},
}
for _, tuple := range vectors {
ours := scrambleOldPassword(scramble, []byte(tuple.pass))
if tuple.out != fmt.Sprintf("%x", ours) {
t.Errorf("Failed old password %q", tuple.pass)
}
}
}

0 comments on commit 9724877

Please sign in to comment.