diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test | 10 | ||||
-rw-r--r-- | tests/test.php | 26 | ||||
-rw-r--r-- | tests/test.successful | bin | 0 -> 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 Binary files differnew file mode 100644 index 0000000..128aea6 --- /dev/null +++ b/tests/test.successful |