netcdf-c/ncdap_test/testauth.sh
Dennis Heimbigner 74b40fd788 Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716

The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}.  So now it
is possible to use a key like "0/1/2/0" for chunk names.

This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.

Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.

In addition the following unrelated changes were made.

1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
   is not found then the other options that depend upon it properly
   are disabled.
1. I decided that xarray support should be enabled by default for pure
   zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
   to work when testing in parallel, some inter-test dependencies needed to
   be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-24 19:48:15 -06:00

208 lines
4.5 KiB
Bash
Executable File

#!/bin/sh
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
#SHOW=1
#DBG=1
if test "x$NCAUTH_HOMETEST" != x ; then
RCHOME=1
fi
RCHOME=1
WD=`pwd`
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
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 in local directory"
reset
# Create the rc file and (optional) netrc fil 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