Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/1-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ kind)
ops config reset
ops config slim
ops setup devcluster
ops setup nuvolaris system-api deploy
fi
;;
k3s)
Expand Down
30 changes: 24 additions & 6 deletions tests/11-sso-mock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ MOCK_CLIENT_ID="openserverless-sso-mock-client"
MOCK_CLIENT_SECRET="mock-client-secret"
MOCK_GROUP="openserverless-users"
MOCK_ISSUER="http://${MOCK_NAME}.${NAMESPACE}.svc.cluster.local:8080/realms/mock"
SSO_LOGIN_TIMEOUT_SECONDS="${SSO_LOGIN_TIMEOUT_SECONDS:-120}"
SSO_LOGIN_RETRY_SECONDS="${SSO_LOGIN_RETRY_SECONDS:-2}"

if ! ops config sso --help >/dev/null 2>&1; then
echo "SSO command is not available in this ops build"
Expand Down Expand Up @@ -147,12 +149,28 @@ if [ -z "$APIURL" ]; then
exit 1
fi

if OPS_SSO_LOGIN_FLOW=password OPS_PASSWORD="$MOCK_PASSWORD" ops -login "$APIURL" "$MOCK_USER" | grep "Successfully logged in as $MOCK_USER."; then
echo SUCCESS SSO PASSWORD LOGIN
else
echo FAIL SSO PASSWORD LOGIN
exit 1
fi
LOGIN_DEADLINE=$((SECONDS + SSO_LOGIN_TIMEOUT_SECONDS))
while true; do
if LOGIN_OUTPUT="$(OPS_SSO_LOGIN_FLOW=password OPS_PASSWORD="$MOCK_PASSWORD" ops -login "$APIURL" "$MOCK_USER" 2>&1)" && \
grep -Fq "Successfully logged in as $MOCK_USER." <<<"$LOGIN_OUTPUT"; then
printf '%s\n' "$LOGIN_OUTPUT"
echo SUCCESS SSO PASSWORD LOGIN
break
fi

printf '%s\n' "$LOGIN_OUTPUT"
if ! grep -Eq 'OIDC password login failed \((502|503)\)' <<<"$LOGIN_OUTPUT"; then
echo FAIL SSO PASSWORD LOGIN
exit 1
fi
if (( SECONDS >= LOGIN_DEADLINE )); then
echo "FAIL SSO PASSWORD LOGIN timed out after ${SSO_LOGIN_TIMEOUT_SECONDS}s"
exit 1
fi

echo "admin-api ingress not ready; retrying SSO password login in ${SSO_LOGIN_RETRY_SECONDS}s"
sleep "$SSO_LOGIN_RETRY_SECONDS"
done

ops util kube waitfor FOR=condition=ready OBJ="wsku/$MOCK_USER" TIMEOUT=120

Expand Down
5 changes: 5 additions & 0 deletions tests/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
set -o pipefail

TYPE="${1:?test type}"
TYPE="$(echo $TYPE | awk -F- '{print $1}')"

Expand Down Expand Up @@ -45,12 +47,14 @@ esac

cd "$SCRIPT_DIR"
rm -f _results _log
FAILED=0
collect() {
if "$@" 2>&1 | tee _log
then
echo SUCCESS "$1" >> _results
else
echo FAIL "$1" >> _results
FAILED=1
fi
}

Expand Down Expand Up @@ -154,3 +158,4 @@ collect ./14-runtime-testing.sh $TYPE

echo "============================================"
cat _results
exit "$FAILED"