@@ -6,66 +6,66 @@ WRAPPER_INSTALL_PATH='/usr/local/share/codespace-features'
66BINS_TO_CHECK=(' yarn' ' npm' ' npx' )
77
88check_path_priority () {
9- log " Checking PATH priority"
10-
11- for BIN_NAME in " ${BINS_TO_CHECK[@]} " ; do
12- if ! command -v " $BIN_NAME " & > /dev/null; then
13- log " Error: $BIN_NAME not found in PATH"
14- exit 1
15- fi
16-
17- # Check if the target binary is wrapped
18- ACTUAL_BIN_PATH=$( command -v " $BIN_NAME " )
19- EXPECTED_BIN_PATH=" $WRAPPER_INSTALL_PATH /$BIN_NAME "
20- if ! grep -q " $EXPECTED_BIN_PATH " <<< " $ACTUAL_BIN_PATH" ; then
21- log " Error: $BIN_NAME is not wrapped. We expected $EXPECTED_BIN_PATH but the actual binary path is $ACTUAL_BIN_PATH ."
22- log " Please contact Clipchamp EngProd and let them know that the feed-auth-wrapper feature is not working as expected."
23- exit 1
24- fi
25-
26- log " Success: $BIN_NAME is wrapped."
27- done
9+ echo " Checking PATH priority"
10+
11+ for BIN_NAME in " ${BINS_TO_CHECK[@]} " ; do
12+ if ! command -v " $BIN_NAME " & > /dev/null; then
13+ echo " Error: $BIN_NAME not found in PATH"
14+ exit 1
15+ fi
16+
17+ # Check if the target binary is wrapped
18+ ACTUAL_BIN_PATH=$( command -v " $BIN_NAME " )
19+ EXPECTED_BIN_PATH=" $WRAPPER_INSTALL_PATH /$BIN_NAME "
20+ if ! grep -q " $EXPECTED_BIN_PATH " <<< " $ACTUAL_BIN_PATH" ; then
21+ echo " Error: $BIN_NAME is not wrapped. We expected $EXPECTED_BIN_PATH but the actual binary path is $ACTUAL_BIN_PATH ."
22+ echo " Please contact Clipchamp EngProd and let them know that the feed-auth-wrapper feature is not working as expected."
23+ exit 1
24+ fi
25+
26+ echo " Success: $BIN_NAME is wrapped."
27+ done
2828}
2929
3030check_bin_exec () {
31- log " Checking if the wrapped binaries get executed"
32-
33- WRAPPED_BINS_DIR=$( mktemp -d)
34- BASH_BIN_DIR=$( dirname " $( command -v bash) " )
35- TEST_PATH=" $WRAPPER_INSTALL_PATH :$WRAPPER_INSTALL_PATH :$WRAPPED_BINS_DIR :$BASH_BIN_DIR "
36-
37- for BIN_NAME in " ${BINS_TO_CHECK[@]} " ; do
38- log " Checking $BIN_NAME "
39- log " Creating a temporary binary to be shadowed by the wrapper"
40- WRAPPED_BIN=" $WRAPPED_BINS_DIR /$BIN_NAME "
41- expected_stdout=" Hello from $BIN_NAME "
42- cat << EOF >"$WRAPPED_BIN "
31+ echo " Checking if the wrapped binaries get executed"
32+
33+ WRAPPED_BINS_DIR=$( mktemp -d)
34+ BASH_BIN_DIR=$( dirname " $( command -v bash) " )
35+ TEST_PATH=" $WRAPPER_INSTALL_PATH :$WRAPPER_INSTALL_PATH :$WRAPPED_BINS_DIR :$BASH_BIN_DIR "
36+
37+ for BIN_NAME in " ${BINS_TO_CHECK[@]} " ; do
38+ echo " Checking $BIN_NAME "
39+ echo " Creating a temporary binary to be shadowed by the wrapper"
40+ WRAPPED_BIN=" $WRAPPED_BINS_DIR /$BIN_NAME "
41+ expected_stdout=" Hello from $BIN_NAME "
42+ cat << EOF >"$WRAPPED_BIN "
4343#!/usr/bin/env bash
4444if [ -z "\$ ARTIFACTS_ACCESSTOKEN" ]; then
4545 echo "Error: ARTIFACTS_ACCESSTOKEN was not set! It should be set by the artifacts-helper wrapper."
4646 exit 1
4747fi
4848echo "$expected_stdout "
4949EOF
50- chmod +x " $WRAPPED_BIN "
51-
52- log " Executing $BIN_NAME to check if it wraps the temporary binary"
53- actual_stdout=$( PATH=" $TEST_PATH " " $BIN_NAME " )
54- actual_stderr=$( PATH=" $TEST_PATH " " $BIN_NAME " 2>&1 > /dev/null)
55-
56- log " Checking the output of the wrapper"
57- log " stdout: $actual_stdout "
58- log " stderr: $actual_stderr "
59- if [ " $actual_stdout " = " $expected_stdout " ]; then
60- log " Success: wrapper for $BIN_NAME executed correctly."
61- else
62- log " Error: wrapper for $BIN_NAME did not execute correctly. Expected '$expected_stdout ' but got '$actual_stdout '."
63- exit 1
64- fi
65- done
66-
67- rm -r " $WRAPPED_BINS_DIR "
68- log " Success: Wrapped binaries are executed correctly."
50+ chmod +x " $WRAPPED_BIN "
51+
52+ echo " Executing $BIN_NAME to check if it wraps the temporary binary"
53+ actual_stdout=$( PATH=" $TEST_PATH " " $BIN_NAME " )
54+ actual_stderr=$( PATH=" $TEST_PATH " " $BIN_NAME " 2>&1 > /dev/null)
55+
56+ echo " Checking the output of the wrapper"
57+ echo " stdout: $actual_stdout "
58+ echo " stderr: $actual_stderr "
59+ if [ " $actual_stdout " = " $expected_stdout " ]; then
60+ echo " Success: wrapper for $BIN_NAME executed correctly."
61+ else
62+ echo " Error: wrapper for $BIN_NAME did not execute correctly. Expected '$expected_stdout ' but got '$actual_stdout '."
63+ exit 1
64+ fi
65+ done
66+
67+ rm -r " $WRAPPED_BINS_DIR "
68+ echo " Success: Wrapped binaries are executed correctly."
6969}
7070
7171main () {
0 commit comments