mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-06 15:34:44 +08:00
e632d02041
The thredds-test server now has some password protected datasets that can be used to test DAP2 authorization support. The general location is ```` https://thredds.ucar.edu/thredds/tdscapabilities/authTest.html ```` and specifically: ```` https://thredds.ucar.edu/thredds/dodsC/test3/testData.nc.html ```` This PR replaces old testcases with ncdap_test/testauth.sh. This testcase allows us to test use of the .dodsrc file and .netrc file and embedded user+pwd. As part of this, I had to create a program (ncdap_test/pathcvt.c) that is essentially the equivalent to cygpath. Given a path in windows, unix, msys or cygwin format, it converts it to the equivalent format in one of those four cases. So it can be used to convert a cygwin path to a windows path, for example. This is needed in testpathcvt and testauth to make sure that the paths in .daprc (e.g. the reference to .netrc) are of the proper format. Misc. Other Changes: 1. Fix some memory leaks in libdap2 2. Setting the env variable CURLOPT_VERBOSE allows tracking of curl operations. 3. Make tst_charvlenbug be conditional on NC_VLEN_NOTEST.
224 lines
5.1 KiB
Bash
Executable File
224 lines
5.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
|
. ../test_common.sh
|
|
|
|
# Since this involves a shared resource: the .rc files in current working directory,
|
|
# we need to isolate from any other test.
|
|
|
|
# Make sure execdir and srcdir absolute paths are available
|
|
WD=`pwd`
|
|
cd $srcdir ; abs_srcdir=`pwd` ; cd $WD
|
|
cd $execdir ; abs_execdir=`pwd` ; cd $WD
|
|
|
|
# Now create a special directory
|
|
# And enter it to execute tests
|
|
rm -fr rcauthdir
|
|
mkdir rcauthdir
|
|
cd rcauthdir
|
|
WD=`pwd`
|
|
|
|
#SHOW=1
|
|
#DBG=1
|
|
|
|
if test "x$NCAUTH_HOMETEST" != x ; then
|
|
RCHOME=1
|
|
fi
|
|
|
|
COOKIES="${WD}/.cookies_test"
|
|
|
|
RC=.daprc
|
|
|
|
if test "x$FPISMSVC" = x ; then
|
|
NETRC=.netrc_test
|
|
NETRCIMP=.netrc
|
|
else
|
|
NETRC=_netrc_test
|
|
NETRCIMP=_netrc
|
|
fi
|
|
|
|
LOCALRCFILES="$WD/.dodsrc $WD/.daprc $WD/.ncrc $WD/$NETRC $WD/$NETRCIMP"
|
|
HOMERCFILES="$HOME/.dodsrc $HOME/.daprc $HOME/.ncrc $HOME/$NETRC $HOME/$NETRCIMP"
|
|
NETRCFILE=$WD/$NETRC
|
|
DAPRCFILE=$WD/$RC
|
|
if test "x$FP_ISMSVC" = x1 ; then
|
|
LOCALRCFILES=`${execdir}/pathcvt "$LOCALRCFILES"`
|
|
HOMERCFILES=`${execdir}/pathcvt "$HOMERCFILES"`
|
|
NETRCFILE=`${execdir}/pathcvt "$NETRCFILE"`
|
|
DAPRCFILE=`${execdir}/pathcvt "$DAPRCFILE"`
|
|
fi
|
|
|
|
HOMENETRCFILE=$HOME/$NETRC
|
|
HOMEDAPRCFILE=$HOME/$RC
|
|
|
|
if test "x$DBG" = x1 ; then
|
|
SHOW=1
|
|
fi
|
|
|
|
# Major parameters
|
|
|
|
AUTHSERVER="thredds.ucar.edu"
|
|
BASICCOMBO="authtester:auth"
|
|
URLPATH="thredds/dodsC/test3/testData.nc"
|
|
PROTO=https
|
|
URLSERVER=${AUTHSERVER}
|
|
|
|
if test "x$DBG" = x1 ; then
|
|
URLPATH="${URLPATH}#log&show=fetch"
|
|
fi
|
|
|
|
# Split the combo
|
|
BASICUSER=`echo $BASICCOMBO | cut -d: -f1`
|
|
BASICPWD=`echo $BASICCOMBO | cut -d: -f2`
|
|
|
|
if test "x$TEMP" = x ; then
|
|
TEMP="/tmp"
|
|
fi
|
|
TEMP=`echo "$TEMP" | sed -e "s|/$||"`
|
|
|
|
LOCALRC=${WD}/$RC
|
|
LOCALNETRC=${WD}/$NETRC
|
|
HOMERC=${HOME}/$RC
|
|
HOMERC=`echo "$HOMERC" | sed -e "s|//|/|g"`
|
|
HOMENETRC=${HOME}/$NETRC
|
|
HOMENETRC=`echo "$HOMENETRC" | sed -e "s|//|/|g"`
|
|
|
|
createrc() {
|
|
local RCP
|
|
local NETRCFILE
|
|
RCP="$1"
|
|
if test "x$RCP" = x ; then
|
|
echo "createrc: no rc specified"
|
|
exit 1
|
|
fi
|
|
shift
|
|
NETRCPATH="$1"
|
|
echo "Creating rc file $RCP"
|
|
if test "x${DBG}" = x1 ; then
|
|
echo "HTTP.VERBOSE=1" >>$RCP
|
|
fi
|
|
if test "x$NETRCPATH" = x ; then
|
|
echo "HTTP.CREDENTIALS.USERPASSWORD=${BASICCOMBO}" >>$RCP
|
|
elif test "x$NETRCPATH" != ximplicit ; then
|
|
echo "HTTP.NETRC=${NETRCPATH}" >>$RCP
|
|
elif test "x$NETRCPATH" = ximplicit ; then
|
|
echo "HTTP.NETRC=" >>$RCP
|
|
fi
|
|
echo "HTTP.COOKIEJAR=${COOKIES}" >>$RCP
|
|
}
|
|
|
|
createnetrc() {
|
|
local NETRCPATH
|
|
NETRCPATH="$1"; # netrc file path
|
|
if test "x$NETRCPATH" = x ; then return; fi
|
|
echo "Creating netrc file $NETRCPATH"
|
|
# echo -n "${PROTO}://$URLSERVER/$URLPATH" >>$NETRCPATH
|
|
echo -n "machine $URLSERVER" >>$NETRCPATH
|
|
echo -n " login $BASICUSER password $BASICPWD" >>$NETRCPATH
|
|
echo "" >>$NETRCPATH
|
|
chmod go-rwx $NETRCPATH
|
|
}
|
|
|
|
# Test cases
|
|
|
|
# Case: !daprc !netrc embedded usr:pwd
|
|
rcembed() {
|
|
echo "***Testing with embedded user:pwd"
|
|
reset
|
|
URL="${PROTO}://${BASICCOMBO}@${URLSERVER}/$URLPATH"
|
|
# Invoke ncdump to extract a file the URL
|
|
${NCDUMP} -h "$URL" > testauthoutput
|
|
}
|
|
|
|
# Case: local daprc no netrc no embed
|
|
rclocal1() {
|
|
echo "***Testing rc file in local directory"
|
|
reset
|
|
# Create the rc file in ./
|
|
createrc $LOCALRC
|
|
# Invoke ncdump to extract a file using the URL
|
|
${NCDUMP} -h "$URL" > testauthoutput
|
|
}
|
|
|
|
# Case: local daprc local netrc no embed
|
|
rclocal2() {
|
|
echo "***Testing rc file + .netrc in local directory"
|
|
reset
|
|
# Create the rc file and (optional) netrc file in ./
|
|
createnetrc $LOCALNETRC
|
|
createrc $LOCALRC $LOCALNETRC
|
|
# Invoke ncdump to extract a file using the URL
|
|
${NCDUMP} -h "$URL" > testauthoutput
|
|
}
|
|
|
|
# Case: home rc no netrc no embed
|
|
rchome1() {
|
|
echo "***Testing home rc file no netrc in home directory"
|
|
reset
|
|
# Create the rc file file in ./
|
|
createrc $HOMERC
|
|
# Invoke ncdump to extract a file the URL
|
|
${NCDUMP} -h "$URL" > testauthoutput
|
|
}
|
|
|
|
# Case: home daprc implicit home netrc no embed
|
|
rchome2() {
|
|
echo "***Testing .netrc file in home directory"
|
|
reset
|
|
createnetrc $HOME/$NETRCIMP
|
|
createrc $HOMERC implicit
|
|
# Invoke ncdump to extract a file using the URL
|
|
${NCDUMP} -h "$URL" > testauthoutput
|
|
}
|
|
|
|
# Case: local rc explicit netrc no embed
|
|
rchome3() {
|
|
echo "***Testing local rc file and .netrc explicit in home directory"
|
|
reset
|
|
# Create the rc file and (optional) netrc file in ./
|
|
createnetrc $HOME/$NETRC
|
|
createrc $LOCALRC $HOME/$NETRC
|
|
# Invoke ncdump to extract a file the URL
|
|
${NCDUMP} -h "$URL" > testauthoutput
|
|
}
|
|
|
|
# Case: local rc implicit netrc no embed
|
|
rchome4() {
|
|
echo "***Testing local rc file and .netrc implicit in home directory"
|
|
reset
|
|
# Create the rc file and (optional) netrc file in ./
|
|
createnetrc $HOME/$NETRCIMP
|
|
createrc $LOCALRC implicit
|
|
# Invoke ncdump to extract a file the URL
|
|
${NCDUMP} -h "$URL" > testauthoutput
|
|
}
|
|
|
|
reset() {
|
|
if test "x$RCHOME" = x1 ; then
|
|
rm -f $HOMERCFILES
|
|
fi
|
|
rm -f $LOCALRCFILES
|
|
unset DAPRCFILE
|
|
rm -f ./testauthoutput
|
|
}
|
|
|
|
rcembed
|
|
|
|
# Next set tests assume these defaults
|
|
URL="${PROTO}://${URLSERVER}/$URLPATH"
|
|
|
|
rclocal1
|
|
rclocal2
|
|
|
|
# Do not do this unless you know what you are doing
|
|
if test "x$RCHOME" = x1 ; then
|
|
rchome1
|
|
rchome2
|
|
rchome3
|
|
rchome4
|
|
fi
|
|
|
|
reset
|
|
exit
|
|
|