1. synch with oc

2. modify oc2/ocrc.c rcfilenames to look for .ocrc before .dodsrc.
3. Modify testauth.sh to avoid using names that might already
   exist for cookies file and netrc file. Still must use .ocrc
   to test for local/home search.
4. Modify testauth.sh to save and restore any file it creates
   that already exists.
This commit is contained in:
dmh 2014-12-31 22:29:36 -07:00
parent c046ca08fd
commit e35a14a85d
5 changed files with 121 additions and 88 deletions

6
Make0
View File

@ -4,9 +4,9 @@ NCLIB=./liblib/.libs/libnetcdf.a
LFLAG=-L/usr/local/lib
HDF5LIB=-lhdf5_hl -lhdf5
CURLLIB=-lcurl
ZLIB=-lz
#HDF5LIB=-lhdf5_hl -lhdf5
#CURLLIB=-lcurl
#ZLIB=-lz
OTHERLIBS=-lm

View File

@ -11,15 +11,16 @@ SHOW=1
CMP=1
WD=`pwd`
# if this is part of a distcheck action, then this script
# will be executed in a different directory
# than the one containing it; so capture the path to this script
# as the location of the source directory.
# capture the build directory
# Do a hack to remove e.g. c: for CYGWIN
builddir=`pwd`/..
if test "x$TOPSRCDIR" = x ; then
if test "x$TOPSRCDIR" != x ; then
srcdir="$TOPSRCDIR/ncdap_test"
else
srcdir=`dirname $0`
@ -35,20 +36,14 @@ if [ `uname | cut -d "_" -f 1` = "MINGW32" ]; then
fi
cd ${builddir}/ncdap_test
if test "x$URS" != x ; then CMP= ; SHOW=1; fi
if test "x$CMP" = x1 ; then SHOW= ; fi
EXPECT=$srcdir/expected3/testData.nc.dmp
NETRCFILE=$builddir/netrc
NETRCFILE=$WD/test_auth_netrc
# This is the control variable
NETRC=$NETRCFILE
COOKIES="${WD}/test_auth_cookies"
RC=.ocrc
EXPECT=$srcdir/expected3/testData.nc.dmp
OCLOGFILE=stderr
if test "x$DBG" = x1 ; then
SHOW=1
fi
# Major parameters
@ -56,8 +51,6 @@ BASICCOMBO="tiggeUser:tigge"
URLSERVER="remotetest.unidata.ucar.edu"
URLPATH="thredds/dodsC/restrict/testData.nc"
COOKIES="$builddir/cookies"
# See if we need to override
if test "x$URS" != "x" ; then
#https://54.86.135.31/opendap/data/nc/fnoc1.nc.dds
@ -66,26 +59,36 @@ URLPATH="opendap/data/nc/fnoc1.nc"
BASICCOMBO="$URS"
NOEMBED=1
NETRC=$NETRCFILE
CMP=
else
NETRC=
fi
if test "x$CMP" = x1 ; then SHOW= ; else SHOW=1; fi
if test "x$DBG" = x1 ; then SHOW=1; fi
# Split the combo
BASICUSER=`echo $BASICCOMBO | cut -d: -f1`
BASICPWD=`echo $BASICCOMBO | cut -d: -f2`
NCDUMP=$builddir/ncdump/ncdump
RC=.ocrc
LOCALRC=./$RC
HOMERC=${HOME}/$RC
HOMERC=`echo "$HOMERC" | sed -e "s|//|/|g"`
SPECRC=$TEMP
if test "x$TEMP" = x ; then
SPECRC="/tmp"
fi
SPECRC="$SPECRC/temprc"
function createrc {
if test "x$1" != x ; then
if test "x$1" = x ; then
echo "createrc: no rc file specified"
else
rm -f $1
RCP=$1
rm -f $RCP
NRC=$2
echo "Creating rc file $RCP"
if test "x${DBG}" != x ; then
echo "HTTP.VERBOSE=1" >>$RCP
@ -94,8 +97,8 @@ echo "HTTP.COOKIEJAR=${COOKIES}" >>$RCP
if test "x${URS}" = x ; then
echo "HTTP.CREDENTIALS.USERPASSWORD=${BASICCOMBO}" >>$RCP
fi
if test "x${NETRC}" != x ; then
echo "HTTP.NETRC=${NETRC}" >>$RCP
if test "x${NRC}" != x ; then
echo "HTTP.NETRC=${NRC}" >>$RCP
fi
fi
}
@ -110,7 +113,29 @@ fi
}
function reset {
rm -f ./tmp ./.ocrc ./.dodsrc $HOME/.ocrc $HOME/.dodsrc $COOKIES $NETRC
for f in ./$RC $HOME/$RC $SPECRC $COOKIES $NETRC ; do
if test "x$DBG" = x1 ; then echo "Deleting $f"; fi
rm -f ${f}
if test -f ${f}.save ; then
if test "x$DBG" = x1 ; then echo "restoring old ${f}" ; fi
cp ${f}.save ${f}
fi
done
# unconditional
rm -f ./tmp
}
function save {
for f in ./$RC $HOME/$RC $SPECRC $COOKIES $NETRC ; do
if test -f $f ; then
if test -f ${f}.save ; then
ignore=1
else
if test "x$DBG" = x1 ; then echo "saving $f"; fi
cp ${f} ${f}.save
fi
fi
done
}
function compare {
@ -124,52 +149,46 @@ function compare {
fi
}
# Invoke ncdump to extract the URL
function doit {
reset
createnetrc $2
createrc $1 $2
echo "command: ${NCDUMP} -h $URL"
${NCDUMP} -h "$URL" >./tmp
if test "x$CMP" = x1 ; then compare ; fi
if test "x${SHOW}" = x1 ; then cat ./tmp ; fi
}
pass=0
# Assemble the ncdump command
if test "x$GDB" = x1 ; then
NCDUMP="gdb --args $NCDUMP"
fi
# Initialize
save
reset
if test "x$NOEMBED" != x1 ; then
echo "***Testing rc file with embedded user:pwd"
URL="https://${BASICCOMBO}@${URLSERVER}/$URLPATH"
# Invoke ncdump to extract the URL
echo "command: ${NCDUMP} -h $URL"
${NCDUMP} -h "$URL" >./tmp
if test "x$CMP" = x1 ; then compare ; fi
if test "x${SHOW}" = x1 ; then cat ./tmp ; fi
doit
fi
URL="https://${URLSERVER}/$URLPATH"
if test "x$NOLOCAL" != x1 ; then
URL="https://${URLSERVER}/$URLPATH"
echo "***Testing rc file in local directory"
# Create the rc file and (optional) netrc file in ./
reset
createnetrc $NETRC
createrc $LOCALRC
# Invoke ncdump to extract a file the URL
echo "command: ${NCDUMP} -h $URL"
${NCDUMP} -h "$URL" >./tmp
if test "x$CMP" = x1 ; then compare ; fi
if test "x${SHOW}" = x1 ; then cat ./tmp ; fi
doit $LOCALRC $NETRC
fi
if test "x$NOHOME" != x1 ; then
URL="https://${URLSERVER}/$URLPATH"
echo "***Testing rc file in home directory"
# Create the rc file and (optional) netrc fil in ./
reset
createnetrc $NETRC
createrc $HOMERC
# Invoke ncdump to extract a file the URL
echo "command: ${NCDUMP} -h $URL"
${NCDUMP} -h "$URL" >./tmp
if test "x$CMP" = x1 ; then compare; fi
if test "x${SHOW}" = x1 ; then cat ./tmp ; fi
doit $HOMERC $NETRC
fi
#cleanup

View File

@ -2119,28 +2119,35 @@ Set the absolute path to use for the rc file.
WARNING: this MUST be called before any other
call in order for this to take effect.
\param[in] rcfile The path to use.
\param[in] rcfile The path to use. If NULL, or "",
then do not use any rcfile.
\retval OC_NOERR if the request succeeded.
\retval OC_ERCFILE if the file failed to load
*/
OCerror
oc_set_rcfile(const char* rcfile)
{
OCerror stat = OC_NOERR;
FILE* f;
if(rcfile == NULL || strlen(rcfile) == 0)
{stat = (OC_EINVAL); goto done;}
f = fopen(rcfile,"r");
if(f == NULL)
{stat = (OC_ERCFILE); goto done;}
fclose(f);
if(!ocglobalstate.initialized) {
if(rcfile != NULL && strlen(rcfile) == 0)
rcfile = NULL;
if(!ocglobalstate.initialized)
ocinternalinitialize(); /* so ocglobalstate is defined, but not triplestore */
if(rcfile == NULL) {
ocglobalstate.rc.ignore = 1;
} else {
FILE* f = fopen(rcfile,"r");
if(f == NULL) {
stat = (OC_ERCFILE);
goto done;
}
fclose(f);
ocglobalstate.rc.rcfile = strdup(rcfile);
/* (re) load the rcfile and esp the triplestore*/
stat = ocrc_load();
}
done:
return OCTHROW(stat);
}

View File

@ -165,6 +165,7 @@ extern struct OCGLOBALSTATE {
char* tempdir; /* track a usable temp dir */
char* home; /* track $HOME for use in creating $HOME/.oc dir */
struct {
int ignore; /* if 1, then do not use any rc file */
int loaded;
struct OCTriplestore ocrc; /* the rc file triple store fields*/
char* rcfile; /* specified rcfile; overrides anything else */

View File

@ -26,8 +26,8 @@ static char* combinecredentials(const char* user, const char* pwd);
static void storedump(char* msg, struct OCTriple*, int ntriples);
/* Define default rc files and aliases*/
static char* rcfilenames[] = {".dodsrc",".ocrc",NULL};
/* Define default rc files and aliases, also defines search order*/
static char* rcfilenames[] = {".ocrc",".dodsrc",NULL};
/* The Username and password are in the URL if the URL is of the form:
* http://<name>:<passwd>@<host>/....
@ -358,6 +358,10 @@ ocrc_load(void)
OCerror stat = OC_NOERR;
char* path = NULL;
if(ocglobalstate.rc.ignore) {
oclog(OCLOGDBG,"No runtime configuration file specified; continuing");
return OC_NOERR;
}
if(ocglobalstate.rc.loaded) return OC_NOERR;
/* locate the configuration files: first if specified,
@ -407,6 +411,10 @@ ocrc_process(OCstate* state)
ocinternalinitialize();
if(!ocglobalstate.rc.loaded)
ocrc_load();
/* Note, we still must do this function even if
ocglobalstate.rc.ignore is set in order
to getinfo e.g. user:pwd from url
*/
url_userpwd = uri->userpwd;
url_hostport = occombinehostport(uri);
@ -554,6 +562,8 @@ ocrc_locate(char* key, char* hostport)
struct OCTriplestore* ocrc = &ocglobalstate.rc.ocrc;
struct OCTriple* triple;
if(ocglobalstate.rc.ignore)
return NULL;
if(!ocglobalstate.rc.loaded)
ocrc_load();
@ -626,13 +636,10 @@ ocrc_lookup(char* suffix, char* url)
if(value != NULL)
return value;
}
<<<<<<< HEAD
return NULL;
=======
return value;
}
/* compile the .dodsrc, if any */
/* compile the rc file, if any */
static OCerror
ocreadrc(void)
{
@ -669,7 +676,6 @@ done:
if(path != NULL)
free(path);
return stat;
>>>>>>> 4bcf90c7c8e9263453b469cc358b3f5a7af84d3a
}
#endif