Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable DAP2 authorization tests #2011

Merged
merged 22 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,9 @@ IF(MSVC)
FILE(COPY ${netCDF_SOURCE_DIR}/libsrc/XGetopt.c
DESTINATION ${netCDF_BINARY_DIR}/ncdump/)
FILE(COPY ${netCDF_SOURCE_DIR}/libsrc/XGetopt.c
DESTINATION ${netCDF_BINARY_DIR}/nczarr_test/)
DESTINATION ${netCDF_BINARY_DIR}/nczarr_test/)
FILE(COPY ${netCDF_SOURCE_DIR}/libsrc/XGetopt.c
DESTINATION ${netCDF_BINARY_DIR}/ncdap_test/)
ENDIF()
ENDIF()

Expand Down
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This file contains a high-level description of this package's evolution. Release

## 4.8.1 - TBD

* [Bug Fix] Re-enable DAP2 authorization testing. See [Github #2011](https://github.com/Unidata/netcdf-c/issues/2011).
* [Bug Fix] Fix bug with windows version of mkstemp that causes failure to create more than 26 temp files. See [Github #1998](https://github.com/Unidata/netcdf-c/pull/1998).
* [Bug Fix] Fix ncdump bug when printing VLENs with basetype char. See [Github #1986](https://github.com/Unidata/netcdf-c/issues/1986).
* [Bug Fixes] The netcdf-c library was incorrectly determining the scope of types referred to by nc_inq_type_equal. See [Github #1959](https://github.com/Unidata/netcdf-c/pull/1959) for more information.
Expand Down
2 changes: 1 addition & 1 deletion libdap2/cdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,7 @@ free1cdfnode(CDFnode* node)
nullfree(node->ocname);
nullfree(node->ncbasename);
nullfree(node->ncfullname);
nullfree(node->dodsspecial.dimname);
if(node->attributes != NULL) {
for(j=0;j<nclistlength(node->attributes);j++) {
NCattribute* att = (NCattribute*)nclistget(node->attributes,j);
Expand All @@ -1099,7 +1100,6 @@ free1cdfnode(CDFnode* node)
nullfree(att);
}
}
nullfree(node->dodsspecial.dimname);
nclistfree(node->subnodes);
nclistfree(node->attributes);
nclistfree(node->array.dimsetplus);
Expand Down
2 changes: 2 additions & 0 deletions libdap2/dapattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ fprintf(stderr,"%s.maxstrlen=%d\n",node->ocname,(int)node->dodsspecial.maxstrlen
#endif
} else if(strcmp(ocname,"DODS.dimName")==0
|| strcmp(ocname,"DODS_EXTRA.dimName")==0) {
nullfree(node->dodsspecial.dimname); /* in case repeated */
node->dodsspecial.dimname = NULL;
if(values != NULL) {
nullfree(node->dodsspecial.dimname);
node->dodsspecial.dimname = nulldup(values[0]);
Expand Down
5 changes: 2 additions & 3 deletions libdap2/ncd2dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,8 @@ fprintf(stderr,"ce=%s\n",dumpconstraint(dapcomm->oc.dapconstraint));
ocstat = oc_open(dapcomm->oc.urltext,&dapcomm->oc.conn);
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}

#ifdef DEBUG1
(void)oc_trace_curl(dapcomm->oc.conn);
#endif
if(getenv("CURLOPT_VERBOSE") != NULL)
(void)oc_trace_curl(dapcomm->oc.conn);

nullfree(dapcomm->oc.urltext); /* clean up */
dapcomm->oc.urltext = NULL;
Expand Down
6 changes: 4 additions & 2 deletions libdap4/d4curlfunctions.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ set_curlflag(NCD4INFO* state, int flag)
break;
case CURLOPT_NETRC: case CURLOPT_NETRC_FILE:
if(state->auth->curlflags.netrc) {
SETCURLOPT(state, CURLOPT_NETRC, (OPTARG)CURL_NETRC_REQUIRED);
SETCURLOPT(state, CURLOPT_NETRC_FILE, state->auth->curlflags.netrc);
SETCURLOPT(state, CURLOPT_NETRC, (OPTARG)CURL_NETRC_OPTIONAL);
/* IF HTTP.NETRC is set with "", then assume the default .netrc file (which is apparently CWD) */
if(strlen(state->auth->curlflags.netrc)>0)
SETCURLOPT(state, CURLOPT_NETRC_FILE, state->auth->curlflags.netrc);
}
break;
case CURLOPT_VERBOSE:
Expand Down
5 changes: 5 additions & 0 deletions libdap4/d4file.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ NCD4_open(const char * path, int mode,
ncsetlogging(1);
}

/* Check env values */
if(getenv("CURLOPT_VERBOSE") != NULL)
d4info->auth->curlflags.verbose = 1;


/* Setup a curl connection */
{
CURL* curl = NULL; /* curl handle*/
Expand Down
4 changes: 2 additions & 2 deletions nc_test4/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ tst_h_scalar tst_rename tst_rename2 tst_rename3 tst_h5_endians \
tst_atts_string_rewrite tst_hdf5_file_compat tst_fill_attr_vanish \
tst_rehash tst_filterparser tst_bug324 tst_types tst_atts3 \
tst_put_vars tst_elatefill tst_udf tst_put_vars_two_unlim_dim \
tst_bug1442 tst_charvlenbug
tst_bug1442

# Temporary I hoped, but hoped in vain.
if !ISCYGWIN
NC4_TESTS += tst_h_strbug tst_h_refs
endif

# Build test programs plus programs used in test scripts.
check_PROGRAMS = $(NC4_TESTS) tst_empty_vlen_unlim
check_PROGRAMS = $(NC4_TESTS) tst_empty_vlen_unlim tst_charvlenbug
TESTS = $(NC4_TESTS) run_empty_vlen_test.sh

# Add these if large file tests are turned on.
Expand Down
2 changes: 2 additions & 0 deletions nc_test4/tst_misc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ echo "*** Fail: phony dimension creation"
ECODE=1
fi

if "x$NC_VLEN_NOTEST" = x1 ; then
echo "*** Testing char(*) type printout error in ncdump"
rm -f ./tst_charvlenbug.nc ./tmp
${execdir}/tst_charvlenbug
Expand All @@ -25,6 +26,7 @@ else
echo "*** Fail: char(*) ncdump printout"
ECODE=1
fi
fi

rm -f tmp

Expand Down
2 changes: 1 addition & 1 deletion nc_test4/tst_szip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -e
rm -f testnc.h5 testszip.nc szip_dump.cdl

echo "*** Test read of known szip file"
${NCDUMP} ${srcdir}/ref_szip.h5 >szip_dump.cdl
${NCDUMP} -n ref_szip ${srcdir}/ref_szip.h5 >szip_dump.cdl
diff -w ${srcdir}/ref_szip.cdl ./szip_dump.cdl

echo "*** Testing tst_szip "
Expand Down
17 changes: 13 additions & 4 deletions ncdap_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,28 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)

FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE)

IF(ENABLE_DAP_REMOTE_TESTS)
IF(ENABLE_TESTS)

IF(ENABLE_DAP_REMOTE_TESTS)
BUILD_BIN_TEST(findtestserver)
BUILD_BIN_TEST(pingurl)
ENDIF()
ENDIF()

IF(USE_X_GETOPT)
SET(XGSRC XGetopt.c)
ENDIF()
BUILD_BIN_TEST(pathcvt ${XGSRC})

IF(ENABLE_TESTS)
# Base tests
# The tests are set up as a combination of shell scripts and executables that
# must be run in a particular order. It is painful but will use macros to help
# keep it from being too bad.
# Binary Test Macro

add_sh_test(ncdap tst_ncdap3)
IF(BUILD_UTILITIES)
add_sh_test(ncdap tst_ncdap3)
add_sh_test(ncdap testpathcvt)
ENDIF()

IF(NOT MSVC)
add_bin_env_test(ncdap t_dap3a)
Expand Down
10 changes: 6 additions & 4 deletions ncdap_test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ check_PROGRAMS += t_dap3a test_cvt3 test_vara
TESTS += t_dap3a test_cvt3 test_vara
if BUILD_UTILITIES
TESTS += tst_ncdap3.sh
TESTS += testpathcvt.sh
endif

# remote tests are optional
# because the server may be down or inaccessible

if ENABLE_DAP_REMOTE_TESTS
noinst_PROGRAMS = findtestserver pingurl
noinst_PROGRAMS = findtestserver pingurl pathcvt
findtestserver_SOURCES = findtestserver.c
pingurl_SOURCES = pingurl.c
pathcvt_SOURCES = pathcvt.c
endif

if ENABLE_DAP_REMOTE_TESTS
Expand Down Expand Up @@ -91,10 +93,10 @@ EXTRA_DIST = tst_ncdap3.sh \
tst_zero_len_var.sh \
tst_filelists.sh tst_urls.sh tst_utils.sh \
t_dap.c CMakeLists.txt tst_formatx.sh testauth.sh testurl.sh \
t_ncf330.c tst_ber.sh tst_fillmismatch.sh tst_encode.sh \
findtestserver.c.in
t_ncf330.c tst_ber.sh tst_fillmismatch.sh tst_encode.sh testpathcvt.sh \
findtestserver.c.in ref_pathcvt.txt

CLEANFILES = test_varm3 test_cvt3 file_results/* remote_results/* datadds* t_dap3a test_nstride_cached *.exe
CLEANFILES = test_varm3 test_cvt3 file_results/* remote_results/* datadds* t_dap3a test_nstride_cached *.exe tmp*.txt
# This should only be left behind if using parallel io
CLEANFILES += tmp_*

Expand Down
137 changes: 137 additions & 0 deletions ncdap_test/pathcvt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* Copyright 2018, University Corporation for Atmospheric Research
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif

#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#endif

#include "ncpathmgr.h"

/*
Synopsis

pathcvt [-u|-w|-m|-c] [-e] PATH

Options
-e add backslash escapes to '\' and ' '
Output type options:
-u convert to Unix form of path
-w convert to Windows form of path
-m convert to MSYS form of path
-c convert to Cygwin form of path

Default is to convert to the format used by the platform.

*/

#define DEBUG

struct Options {
int target;
int escape;
int debug;
} cvtoptions;

static char* escape(const char* path);
static void usage(const char* msg);

int
main(int argc, char** argv)
{
int c;
char* cvtpath = NULL;
char* inpath;

memset((void*)&cvtoptions,0,sizeof(cvtoptions));

while ((c = getopt(argc, argv, "cD:ehmuw")) != EOF) {
switch(c) {
case 'c': cvtoptions.target = NCPD_CYGWIN; break;
case 'e': cvtoptions.escape = 1; break;
case 'h': usage(NULL); break;
case 'm': cvtoptions.target = NCPD_MSYS; break;
case 'u': cvtoptions.target = NCPD_NIX; break;
case 'w': cvtoptions.target = NCPD_WIN; break;
case 'D':
sscanf(optarg,"%d",&cvtoptions.debug);
break;
case '?':
usage("unknown option");
break;
}
}

argc -= optind;
argv += optind;

/* If no file arguments left or more than one, print usage message. */
if (argc == 0)
usage("no path specified");
if (argc > 1)
usage("more than one path specified");
inpath = argv[0];
if(cvtoptions.target == NCPD_UNKNOWN)
cvtpath = NCpathcvt(inpath);
else
cvtpath = NCpathcvt_test(inpath,cvtoptions.target,'c');
if(cvtpath && cvtoptions.escape) {
char* path = cvtpath; cvtpath = NULL;
cvtpath = escape(path);
free(path);
}
printf("%s",cvtpath);
if(cvtpath) free(cvtpath);
return 0;
}

static void
usage(const char* msg)
{
if(msg != NULL) fprintf(stderr,"%s\n",msg);
fprintf(stderr,"pathcvt [-u|-w|-m|-c] PATH\n");
if(msg == NULL) exit(0); else exit(1);
}

static char*
escape(const char* path)
{
size_t slen = strlen(path);
const char* p;
char* q;
char* epath = NULL;

epath = (char*)malloc((2*slen) + 1);
if(epath == NULL) usage("out of memtory");
p = path;
q = epath;
for(;*p;p++) {
switch (*p) {
case '\\': case ' ':
*q++ = '\\';
/* fall thru */
default:
*q++ = *p;
break;
}
}
*q = '\0';
return epath;
}

45 changes: 45 additions & 0 deletions ncdap_test/ref_pathcvt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
path: /xxx/a/b
/xxx/a/b
/cygdrive/c/xxx/a/b
/c/xxx/a/b
c:\\xxx\\a\\b
path: d:/x/y
/d/x/y
/cygdrive/d/x/y
/d/x/y
d:\\x\\y
path: /cygdrive/d/x/y
/d/x/y
/cygdrive/d/x/y
/d/x/y
d:\\x\\y
path: /d/x/y
/d/x/y
/cygdrive/d/x/y
/d/x/y
d:\\x\\y
path: /cygdrive/d
/d
/cygdrive/d
/d
d:
path: /d
/d
/cygdrive/d
/d
d:
path: /cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn
/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn
/cygdrive/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn
/d/git/netcdf-c/dap4_test/test_anon_dim.2.syn
d:\\git\\netcdf-c\\dap4_test\\test_anon_dim.2.syn
path: d:\x\y
/d/x/y
/cygdrive/d/x/y
/d/x/y
d:\\x\\y
path: d:\x\y w\z
/d/x/y w/z
/cygdrive/d/x/y w/z
/d/x/y w/z
d:\\x\\y\\ w\\z
Loading