An initially working library.
[ga4php.git] / unittests / authtest.php
diff --git a/unittests/authtest.php b/unittests/authtest.php
new file mode 100644 (file)
index 0000000..649cc64
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+
+require_once("../lib/lib.php");
+
+// just in case
+
+unlink("/tmp/db.sqlite");
+$ga = new GoogleAuthenticator("/tmp/db.sqlite");
+
+// first lets try hotp, should be 393101, 805347 then 428248
+$ga->createUser("User1", "9732e257c94c9930818d");
+
+if($ga->authenticateUser("User1", "393101")) {
+       echo "Passed: correct\n";
+} else {
+       echo "Failed: INCORRECT\n";
+}
+
+if($ga->authenticateUser("User1", "805347")) {
+       echo "Passed: correct\n";
+} else {
+       echo "Failed: INCORRECT\n";
+}
+
+if($ga->authenticateUser("User1", "428248")) {
+       echo "Passed: correct\n";
+} else {
+       echo "Failed: INCORRECT\n";
+}
+
+if($ga->authenticateUser("User1", "234523")) {
+       echo "Passed: INCORRECT\n";
+} else {
+       echo "Failed: correct\n";
+}
+
+if($ga->authenticateUser("User1", "598723")) {
+       echo "Passed: correct\n";
+} else {
+       echo "Failed: INCORRECT\n";
+}
+
+?>
\ No newline at end of file