#!/bin/sh
# PCP QA Test No. 780
# Exercise PMWEBAPI Access-Control-Allow-Origin HTTP header.
#
# Copyright (c) 2014,2019 Red Hat.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

_check_series
which curl >/dev/null 2>&1 || _notrun "No curl binary installed"

signal=$PCP_BINADM_DIR/pmsignal
status=1	# failure is the default!
$sudo rm -rf $tmp.* $seq.full
trap "cd $here; _cleanup; exit \$status" 0 1 2 3 15

_cleanup()
{
    $sudo rm -f $tmp.*
}

unset http_proxy
unset HTTP_PROXY

# real QA test starts here
_service pmproxy restart >/dev/null 2>&1

curl -s -S "http://localhost:44323/pmapi/context" -I | _webapi_header_filter
echo >>$here/$seq.full
echo "=== pmproxy log ===" >>$here/$seq.full
cat $PCP_LOG_DIR/pmproxy/pmproxy.log >>$here/$seq.full

# success, all done
status=0
exit
