summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Burschka2012-10-30 02:45:21 +0100
committerChristoph Burschka2012-10-30 02:45:21 +0100
commit7fc3addf1b2796998fe0350cd4c5d7513612b1ba (patch)
treeda7b47008fc112e53aee5ab51b8a39f6be4f54f2 /tests
downloadejabberd-auth-php-7fc3addf1b2796998fe0350cd4c5d7513612b1ba.tar.gz
Initial checkin
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test10
-rw-r--r--tests/test.php26
-rw-r--r--tests/test.successfulbin0 -> 32 bytes
3 files changed, 36 insertions, 0 deletions
diff --git a/tests/test b/tests/test
new file mode 100755
index 0000000..4d68705
--- /dev/null
+++ b/tests/test
@@ -0,0 +1,10 @@
+php test.php > test.in
+php ../main.php <test.in>test.out
+if [ -z "$(diff test.out test.successful)" ]
+then
+ echo "Test successful."
+else
+ echo "Test unsuccessful. Check activity logs."
+fi
+
+rm test.in test.out \ No newline at end of file
diff --git a/tests/test.php b/tests/test.php
new file mode 100644
index 0000000..a6d6c16
--- /dev/null
+++ b/tests/test.php
@@ -0,0 +1,26 @@
+<?php
+$stderr = fopen('php://stderr', 'w');
+$in = fopen('php://stdin', 'r');
+fwrite($stderr, "Enter a valid username: ");
+$user = trim(fgets($in));
+fwrite($stderr, "Enter the password: ");
+$password = trim(fgets($in));
+
+$str = array(
+ array('isuser', $user),
+ array('isuser', '123456789'),
+ array('auth', $user, 'localhost', $password),
+ array('auth', $user, 'localhost', '123456789'),
+
+ // These should all fail cleanly.
+ array('setpass', '123456789', 'localhost', '123456789'),
+ array('tryregister', '123456789', 'localhost', '123456789'),
+ array('removeuser', '123456789', 'localhost', '123456789'),
+ array('removeuser3', '123456789', 'localhost', '123456789'),
+);
+
+foreach ($str as $command) {
+ $command = implode(':', $command);
+ print pack('n', strlen($command));
+ print $command;
+}
diff --git a/tests/test.successful b/tests/test.successful
new file mode 100644
index 0000000..128aea6
--- /dev/null
+++ b/tests/test.successful
Binary files differ