Suharsh Sivakumar | a76dba6 | 2014-12-22 16:00:34 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Test that tests the routes of the identityd server. |
| 4 | |
Jiri Simsa | 3540e3a | 2014-12-26 07:54:09 -0800 | [diff] [blame] | 5 | source "$(go list -f {{.Dir}} v.io/core/shell/lib)/shell_test.sh" |
Suharsh Sivakumar | a76dba6 | 2014-12-22 16:00:34 -0800 | [diff] [blame] | 6 | |
Ankur | 5dab76d | 2015-01-07 11:06:46 -0800 | [diff] [blame] | 7 | # Run the test under the security agent. |
| 8 | shell_test::enable_agent "$@" |
| 9 | |
Suharsh Sivakumar | a76dba6 | 2014-12-22 16:00:34 -0800 | [diff] [blame] | 10 | readonly WORKDIR="${shell_test_WORK_DIR}" |
| 11 | |
| 12 | build() { |
Jiri Simsa | 764efb7 | 2014-12-25 20:57:03 -0800 | [diff] [blame] | 13 | IDENTITYD_BIN="$(shell_test::build_go_binary 'v.io/core/veyron/services/identity/identityd_test')" |
| 14 | PRINCIPAL_BIN="$(shell_test::build_go_binary 'v.io/core/veyron/tools/principal')" |
Suharsh Sivakumar | a76dba6 | 2014-12-22 16:00:34 -0800 | [diff] [blame] | 15 | } |
| 16 | |
Suharsh Sivakumar | a76dba6 | 2014-12-22 16:00:34 -0800 | [diff] [blame] | 17 | # runprincipal starts the principal tool, extracts the url and curls it, to avoid the |
| 18 | # dependence the principal tool has on a browser. |
| 19 | runprincipal() { |
| 20 | local PFILE="${WORKDIR}/principalfile" |
| 21 | # Start the tool in the background. |
| 22 | "${PRINCIPAL_BIN}" seekblessings --browser=false --from=https://localhost:8125/google -v=3 2> "${PFILE}" & |
| 23 | sleep 2 |
| 24 | # Search for the url and run it. |
| 25 | cat "${PFILE}" | grep https | |
| 26 | while read url; do |
| 27 | RESULT=$(curl -L --insecure -c ${WORKDIR}/cookiejar $url); |
| 28 | # Clear out the file |
| 29 | echo $RESULT; |
| 30 | break; |
| 31 | done; |
| 32 | rm "${PFILE}"; |
| 33 | } |
| 34 | |
| 35 | main() { |
| 36 | cd "${WORKDIR}" |
| 37 | build |
Ankur | 5dab76d | 2015-01-07 11:06:46 -0800 | [diff] [blame] | 38 | |
Suharsh Sivakumar | a76dba6 | 2014-12-22 16:00:34 -0800 | [diff] [blame] | 39 | shell_test::setup_server_test || shell_test::fail "line ${LINENO} failed to setup server test" |
Suharsh Sivakumar | a76dba6 | 2014-12-22 16:00:34 -0800 | [diff] [blame] | 40 | |
| 41 | # Start the identityd server in test identity server. |
Ankur | 5dab76d | 2015-01-07 11:06:46 -0800 | [diff] [blame] | 42 | shell_test::start_server "${VRUN}" "${IDENTITYD_BIN}" --host=localhost -veyron.tcp.address=127.0.0.1:0 |
Suharsh Sivakumar | a76dba6 | 2014-12-22 16:00:34 -0800 | [diff] [blame] | 43 | echo Identityd Log File: $START_SERVER_LOG_FILE |
Suharsh Sivakumar | a76dba6 | 2014-12-22 16:00:34 -0800 | [diff] [blame] | 44 | |
| 45 | # Test an initial seekblessings call, with a specified VEYRON_CREDENTIALS. |
| 46 | WANT="Received blessings" |
| 47 | GOT=$(runprincipal) |
| 48 | if [[ ! "${GOT}" =~ "${WANT}" ]]; then |
| 49 | shell_test::fail "line ${LINENO} failed first seekblessings call" |
| 50 | fi |
| 51 | # Test that a subsequent call succeed with the same credentials. This means that the blessings and principal from the first call works correctly. |
| 52 | GOT=$(runprincipal) |
| 53 | if [[ ! "${GOT}" =~ "${WANT}" ]]; then |
| 54 | shell_test::fail "line ${LINENO} failed second seekblessings call" |
| 55 | fi |
| 56 | |
| 57 | shell_test::pass |
| 58 | } |
| 59 | |
Jiri Simsa | c0a2865 | 2014-12-25 15:42:39 -0800 | [diff] [blame] | 60 | main "$@" |