From 23f3df0ca96feb63a0bf6c3e17ed65acef20b461 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Mon, 4 Jan 2021 15:22:27 +0100 Subject: Adding check-user script --- .../src/test/resources/check-user.sh | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 archiva-modules/archiva-web/archiva-webapp/src/test/resources/check-user.sh (limited to 'archiva-modules') diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/check-user.sh b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/check-user.sh new file mode 100755 index 000000000..b1b8de1a2 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/check-user.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Just a simple script that checks, if a user exists by using the REST Api + +BASE_URL="http://localhost:8080/archiva" +USER_NAME="admin" +PASSWD="admin456" + +CHECK_USER=$1 + + +#Authenticate +TOKEN=$(curl -s -X POST "${BASE_URL}/api/v2/redback/auth/authenticate" -H "accept: application/json" -H "Content-Type: application/json" \ + -d "{\"grant_type\":\"authorization_code\",\"client_id\":\"test-bash\",\"client_secret\":\"string\",\"code\":\"string\",\"scope\":\"string\",\"state\":\"string\",\"user_id\":\"${USER_NAME}\",\ + \"password\":\"${PASSWD}\",\"redirect_uri\":\"string\"}"|sed -n -e '/access_token/s/.*"access_token":"\([^"]\+\)".*/\1/gp') +if [ "${TOKEN}" == "" ]; then + echo "Authentication failed!" + exit 1 +fi + +echo curl -I -w ' - %{http_code}' "${BASE_URL}/api/v2/redback/users/${CHECK_USER}" -H "accept: application/json" \ + -H "Authorization: Bearer ${TOKEN}" \ + -H "Content-Type: application/json" + +curl -I -w ' - %{http_code}' "${BASE_URL}/api/v2/redback/users/${CHECK_USER}" -H "accept: application/json" \ + -H "Authorization: Bearer ${TOKEN}" \ + -H "Content-Type: application/json" -- cgit v1.2.3