3 # ============LICENSE_START=======================================================
4 # Copyright (C) 2022 Nordix Foundation.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
21 INGRESS_HOST=$(minikube ip)
22 INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
26 TEST_TS=$(date +%F-%T)
34 url="http://192.168.49.2:31560/auth/realms"
35 TOKEN=$(curl -s -X POST $url/provider/protocol/openid-connect/token -H \
36 "Content-Type: application/x-www-form-urlencoded" -d client_secret=OwTCeahULA21G5TfEVMLG1iMloGiyH3i \
37 -d 'grant_type=client_credentials' -d client_id=provider-cli)
39 ACCESS_TOKEN=$(echo $TOKEN | jq -r '.access_token')
40 REFRESH_TOKEN=$(echo $TOKEN | jq -r '.refresh_token')
46 local prefix="${1}" type=${2} msg="${3}" data=${4}
48 echo "Test ${TESTS}: Testing $type /${prefix}"
50 url=$INGRESS_HOST:$INGRESS_PORT"/"$prefix
52 result=$(curl -s -X ${type} -H "Content-type: application/json" -H "Authorization: Bearer $ACCESS_TOKEN" $url)
54 if [ "$result" != "$msg" ]; then
65 run_test "rapp-provider" "GET" "Hello World!" ""
68 echo "-----------------------------------------------------------------------"
69 echo "Number of Tests: $TESTS, Tests Passed: $PASSED, Tests Failed: $FAILED"
71 echo "-----------------------------------------------------------------------"