blob: 471e140d275a98caee93ccef9875f491c5271850 [file] [log] [blame]
Suharsh Sivakumara76dba62014-12-22 16:00:34 -08001#!/bin/bash
2
3# Test that tests the routes of the identityd server.
4
Jiri Simsa3540e3a2014-12-26 07:54:09 -08005source "$(go list -f {{.Dir}} v.io/core/shell/lib)/shell_test.sh"
Suharsh Sivakumara76dba62014-12-22 16:00:34 -08006
Ankur5dab76d2015-01-07 11:06:46 -08007# Run the test under the security agent.
8shell_test::enable_agent "$@"
9
Suharsh Sivakumara76dba62014-12-22 16:00:34 -080010readonly WORKDIR="${shell_test_WORK_DIR}"
11
12build() {
Jiri Simsa764efb72014-12-25 20:57:03 -080013 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 Sivakumara76dba62014-12-22 16:00:34 -080015}
16
Suharsh Sivakumara76dba62014-12-22 16:00:34 -080017# runprincipal starts the principal tool, extracts the url and curls it, to avoid the
18# dependence the principal tool has on a browser.
19runprincipal() {
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
35main() {
36 cd "${WORKDIR}"
37 build
Ankur5dab76d2015-01-07 11:06:46 -080038
Suharsh Sivakumara76dba62014-12-22 16:00:34 -080039 shell_test::setup_server_test || shell_test::fail "line ${LINENO} failed to setup server test"
Suharsh Sivakumara76dba62014-12-22 16:00:34 -080040
41 # Start the identityd server in test identity server.
Ankur5dab76d2015-01-07 11:06:46 -080042 shell_test::start_server "${VRUN}" "${IDENTITYD_BIN}" --host=localhost -veyron.tcp.address=127.0.0.1:0
Suharsh Sivakumara76dba62014-12-22 16:00:34 -080043 echo Identityd Log File: $START_SERVER_LOG_FILE
Suharsh Sivakumara76dba62014-12-22 16:00:34 -080044
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 Simsac0a28652014-12-25 15:42:39 -080060main "$@"