| 1 | #!/bin/sh |
|---|
| 2 | # |
|---|
| 3 | # Test suite for the remctl command-line client. |
|---|
| 4 | # |
|---|
| 5 | # Written by Russ Allbery <rra@stanford.edu> |
|---|
| 6 | # Copyright 2006, 2007, 2009 Board of Trustees, Leland Stanford Jr. University |
|---|
| 7 | # |
|---|
| 8 | # See LICENSE for licensing terms. |
|---|
| 9 | |
|---|
| 10 | . "$SOURCE/tap/libtap.sh" |
|---|
| 11 | . "$SOURCE/tap/kerberos.sh" |
|---|
| 12 | . "$SOURCE/tap/remctl.sh" |
|---|
| 13 | cd "$SOURCE" |
|---|
| 14 | |
|---|
| 15 | # Test setup. |
|---|
| 16 | kerberos_setup |
|---|
| 17 | if [ $? != 0 ] ; then |
|---|
| 18 | skip_all "Kerberos tests not configured" |
|---|
| 19 | else |
|---|
| 20 | plan 11 |
|---|
| 21 | fi |
|---|
| 22 | remctl="$BUILD/../client/remctl" |
|---|
| 23 | if [ ! -x "$remctl" ] ; then |
|---|
| 24 | bail "can't locate remctl client binary" |
|---|
| 25 | fi |
|---|
| 26 | remctld_start "$BUILD/../server/remctld" "$SOURCE/data/conf-simple" |
|---|
| 27 | |
|---|
| 28 | # Now, we can finally run our tests. |
|---|
| 29 | ok_program "basic" 0 "hello world" \ |
|---|
| 30 | "$remctl" -s "$principal" -p 14373 localhost test test |
|---|
| 31 | ok_program "no output" 0 "" \ |
|---|
| 32 | "$remctl" -s "$principal" -p 14373 localhost test status 0 |
|---|
| 33 | ok_program "exit status 1" 1 "" \ |
|---|
| 34 | "$remctl" -s "$principal" -p 14373 localhost test status 1 |
|---|
| 35 | ok_program "exit status 2" 2 "" \ |
|---|
| 36 | "$remctl" -s "$principal" -p 14373 localhost test status 2 |
|---|
| 37 | ok_program "wrong principal" 255 "Access denied" \ |
|---|
| 38 | "$remctl" -s "$principal" -p 14373 localhost test noauth |
|---|
| 39 | ok_program "non-existent ACL" 255 "Access denied" \ |
|---|
| 40 | "$remctl" -s "$principal" -p 14373 localhost test noacl |
|---|
| 41 | ok_program "non-existent command" 255 "Cannot execute" \ |
|---|
| 42 | "$remctl" -s "$principal" -p 14373 localhost test nonexistent |
|---|
| 43 | ok_program "unknown command" 255 "Unknown command" \ |
|---|
| 44 | "$remctl" -s "$principal" -p 14373 localhost test bad-command |
|---|
| 45 | ok_program "201 arguments" 0 "201" \ |
|---|
| 46 | "$remctl" -s "$principal" -p 14373 localhost test argv \ |
|---|
| 47 | a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a \ |
|---|
| 48 | a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a \ |
|---|
| 49 | a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a \ |
|---|
| 50 | a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a \ |
|---|
| 51 | a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a \ |
|---|
| 52 | a a a a a a a a a a a a a a a a a a a a a a a a a |
|---|
| 53 | |
|---|
| 54 | # Make sure that error messages end in a newline. |
|---|
| 55 | "$remctl" -s "$principal" -p 14373 localhost test noauth \ |
|---|
| 56 | > "$BUILD/data/output" 2>&1 |
|---|
| 57 | echo 'foo' >> "$BUILD/data/output" |
|---|
| 58 | ok "error messages end in a newline" \ |
|---|
| 59 | [ "`wc -l "$BUILD/data/output" | sed 's, /.*,,'`" -eq 2 ] |
|---|
| 60 | |
|---|
| 61 | # Check refused connections. |
|---|
| 62 | "$remctl" -p 14445 localhost test noauth > "$BUILD/data/output" 2>&1 |
|---|
| 63 | output=`sed 's/):.*/)/' "$BUILD/data/output"` |
|---|
| 64 | echo "# saw: $output" |
|---|
| 65 | ok "correct connection refused error" \ |
|---|
| 66 | [ "$output" = "remctl: cannot connect to localhost (port 14445)" ] |
|---|
| 67 | |
|---|
| 68 | # Clean up. |
|---|
| 69 | rm -f "$BUILD/data/output" |
|---|
| 70 | remctld_stop |
|---|
| 71 | kerberos_cleanup |
|---|