Jiri Simsa | a942b75 | 2014-08-08 17:55:12 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Asim Shankar | 76f431a | 2014-07-23 10:03:20 -0700 | [diff] [blame] | 2 | |
| 3 | # Test the identity command-line tool. |
| 4 | # |
| 5 | # This tests most operations of the identity command-line tool. |
| 6 | # Not the "seekblessing" command yet, since that requires |
| 7 | # starting a separate server. |
| 8 | |
Jiri Simsa | f8727f2 | 2014-09-24 19:08:49 -0700 | [diff] [blame] | 9 | source "${VEYRON_ROOT}/scripts/lib/shell_test.sh" |
Asim Shankar | 76f431a | 2014-07-23 10:03:20 -0700 | [diff] [blame] | 10 | |
Jiri Simsa | a942b75 | 2014-08-08 17:55:12 -0700 | [diff] [blame] | 11 | main() { |
| 12 | # Build binaries. |
| 13 | cd "${TMPDIR}" |
Jiri Simsa | d993b39 | 2014-09-29 21:22:00 -0700 | [diff] [blame] | 14 | veyron go build veyron.io/veyron/veyron/tools/identity || shell_test::fail "line ${LINENO}: failed to build identity" |
Asim Shankar | 76f431a | 2014-07-23 10:03:20 -0700 | [diff] [blame] | 15 | |
Jiri Simsa | a942b75 | 2014-08-08 17:55:12 -0700 | [diff] [blame] | 16 | ./identity print >/dev/null || shell_test::fail "line ${LINENO}: print failed" |
| 17 | ./identity generate >/dev/null || shell_test::fail "line ${LINENO}: generate failed" |
| 18 | ./identity generate root >root || shell_test::fail "line ${LINENO}: generate root failed" |
Asim Shankar | 76f431a | 2014-07-23 10:03:20 -0700 | [diff] [blame] | 19 | |
Jiri Simsa | a942b75 | 2014-08-08 17:55:12 -0700 | [diff] [blame] | 20 | export VEYRON_IDENTITY="root" |
| 21 | |
| 22 | # Generate an identity and get it blessed by root using "identity bless" |
| 23 | local GOT=$(./identity generate ignoreme | ./identity bless - child | ./identity print - | awk '/Name/ {print $3}') |
| 24 | local WANT="root/child" |
| 25 | if [ "${GOT}" != "${WANT}" ]; then |
Asim Shankar | 8ed43e5 | 2014-09-15 18:38:02 -0700 | [diff] [blame] | 26 | shell_test::fail "line ${LINENO}: Got ${GOT}, want ${WANT}" |
Jiri Simsa | a942b75 | 2014-08-08 17:55:12 -0700 | [diff] [blame] | 27 | fi |
| 28 | |
| 29 | # Generate an identity and get it blessed by root using "identity bless --with" |
| 30 | ./identity generate other >other || shell_test::fail |
| 31 | GOT=$(./identity generate ignoreme | ./identity bless --with=other - child | ./identity print - | awk '/Name/ {print $3}') |
| 32 | WANT="unknown/other/child" |
| 33 | if [ "${GOT}" != "${WANT}" ]; then |
Asim Shankar | 8ed43e5 | 2014-09-15 18:38:02 -0700 | [diff] [blame] | 34 | shell_test::fail "line ${LINENO}: Got ${GOT}, want ${WANT}" |
Jiri Simsa | a942b75 | 2014-08-08 17:55:12 -0700 | [diff] [blame] | 35 | fi |
| 36 | |
Asim Shankar | 8ed43e5 | 2014-09-15 18:38:02 -0700 | [diff] [blame] | 37 | # Test that previously generated identities can be interpreted |
| 38 | # (i.e., any changes to the Certificate or Signature scheme are backward compatible). |
| 39 | # To regenerate testdata: |
| 40 | # identity generate "root" >testdata/root.id |
| 41 | # identity generate "other" | VEYRON_IDENTITY=testdata/root.id identity bless - "blessed" >testdata/blessed.id |
Asim Shankar | 45c8955 | 2014-09-18 10:58:10 -0700 | [diff] [blame] | 42 | local -r TESTDATA_DIR="${VEYRON_ROOT}/veyron/go/src/veyron.io/veyron/veyron/tools/identity/testdata" |
Asim Shankar | 8ed43e5 | 2014-09-15 18:38:02 -0700 | [diff] [blame] | 43 | GOT=$(VEYRON_IDENTITY="${TESTDATA_DIR}/root.id" ./identity print | awk '/Name/ {print $3}') |
| 44 | WANT="root" |
| 45 | if [ "${GOT}" != "${WANT}" ]; then |
| 46 | shell_test::fail "line ${LINENO}: Got '${GOT}' from previously generated root.id, want '${WANT}'" |
| 47 | fi |
| 48 | GOT=$(VEYRON_IDENTITY="${TESTDATA_DIR}/root.id" ./identity print "${TESTDATA_DIR}/blessed.id" | awk '/Name/ {print $3}') |
| 49 | WANT="root/blessed" |
| 50 | if [ "${GOT}" != "${WANT}" ]; then |
| 51 | shell_test::fail "line ${LINENO}: Got '${GOT}' from previously generated blessed.id, want '${WANT}'" |
| 52 | fi |
Jiri Simsa | a942b75 | 2014-08-08 17:55:12 -0700 | [diff] [blame] | 53 | shell_test::pass |
Asim Shankar | 76f431a | 2014-07-23 10:03:20 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Jiri Simsa | a942b75 | 2014-08-08 17:55:12 -0700 | [diff] [blame] | 56 | main "$@" |