ソースを参照

Merge pull request #191 from arnehormann/oldpass-test

add test for scrambleOldPassword
Arne Hormann 12 年 前
コミット
97248774f0
1 ファイル変更18 行追加0 行削除
  1. 18 0
      utils_test.go

+ 18 - 0
utils_test.go

@@ -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)
+		}
+	}
 }