From 9a4badaf163164f844b0636f8a0c80b61463c3c1 Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Wed, 31 Mar 2021 21:56:36 -0600 Subject: [PATCH] ckp --- ncdap_test/Makefile.am | 3 ++- ncdap_test/t_auth.c | 41 ++++++++++++++++------------------------- ncdap_test/testauth.sh | 13 +++++++------ 3 files changed, 25 insertions(+), 32 deletions(-) diff --git a/ncdap_test/Makefile.am b/ncdap_test/Makefile.am index b38999acc..998e3ddfa 100644 --- a/ncdap_test/Makefile.am +++ b/ncdap_test/Makefile.am @@ -74,7 +74,8 @@ check_PROGRAMS += t_misc check_PROGRAMS += t_ncf330 if ENABLE_DAP_AUTH_TESTS -TESTS += testbasicauth.sh +check_PROGRAMS += t_auth +TESTS += testauth.sh TESTS += testcontainerauth.sh endif diff --git a/ncdap_test/t_auth.c b/ncdap_test/t_auth.c index 2156154af..a8c247885 100644 --- a/ncdap_test/t_auth.c +++ b/ncdap_test/t_auth.c @@ -28,15 +28,17 @@ See \ref copyright file for more info. #define KEEPRC -#define RC ".ocrc" -#define SPECRC "./ocrc" +#define AUTHTESTSERVER "thredds-dev.unidata.ucar.edu" -#define USERPWD "tiggeUser:tigge" +#define RC ".daprc" +#define SPECRC "./daprc" + +#define USERPWD "authuser:auth" #define COOKIEFILE "./cookies" -#define URL1 "https://%s@%s/dodsC/restrict/testData.nc" -#define URL2 "https://%s/dodsC/restrict/testData.nc" -#define URL3 "https://%s@thredds-test.ucar.edu/thredds/dodsC/restrict/testData.nc" +#define URL1 "https://%s@%s/dodsC/test2/testData.nc" +#define URL2 "https://%s/dodsC/test2/testData.nc" +#define URL3 "https://%s@" AUTHTESTSERVER "/thredds/dodsC/test2/testData.nc" /* Embedded user:pwd */ static char url1[1024]; @@ -45,36 +47,25 @@ static char url1[1024]; static char url2[1024]; /* Test redirect from different machine*/ +#ifndef NOREDIR static char url3[1024]; +#endif static int testrc(const char* prefix, const char* url); static void fillrc(const char* path); static void killrc(); -#ifdef DEBUG -static void -CHECK(int e, const char* msg) -{ - if(e == NC_NOERR) return; - if(msg == NULL) msg = "Error"; - fprintf(stderr,"%s: %s\n", msg, nc_strerror(e)); - exit(1); -} -#endif - int main(int argc, char** argv) { int ncid,retval,pass; - FILE* rc; const char* dfaltsvc; - char buffer[8192]; const char* home; fprintf(stderr,"Testing: Authorization\n"); - dfaltsvc = nc_findtestserver("thredds",REMOTETESTSERVERS); - if(svc == NULL) { + dfaltsvc = nc_findtestserver("thredds",AUTHTESTSERVER); + if(dfaltsvc == NULL) { fprintf(stderr,"WARNING: Cannot locate test server\n"); exit(0); } @@ -110,7 +101,7 @@ fflush(stderr); #ifndef NOLOCAL { /* Test 1: RC in ./ */ - fprintf(stderr,"Testing: user:pwd in %s/%s: %s\n",".",RC); + fprintf(stderr,"Testing: user:pwd in %s/%s\n",".",RC); if(!testrc(".",url2)) { fprintf(stderr,"user:pwd in %s/%s failed\n",".",RC); exit(1); @@ -122,7 +113,7 @@ fflush(stderr); { /* Test 1: RC in HOME */ home = getenv("HOME"); - fprintf(stderr,"user:pwd in %s/%s: %s\n",home,RC); + fprintf(stderr,"user:pwd in %s/%s\n",home,RC); if(!testrc(home,url2)) { fprintf(stderr,"user:pwd in %s/%s failed\n",home,RC); exit(1); @@ -205,10 +196,10 @@ static void killrc() { const char* home; - char path[1024]; #ifdef KEEPRC fprintf(stderr,"kill: ./%s\n",RC); -#else +#else + char path[1024]; snprintf(path,sizeof(path),"%s/%s",".",RC); unlink(path); /* delete the file */ #endif diff --git a/ncdap_test/testauth.sh b/ncdap_test/testauth.sh index 02dd6769c..29ea27e26 100755 --- a/ncdap_test/testauth.sh +++ b/ncdap_test/testauth.sh @@ -4,7 +4,7 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi . ../test_common.sh # Enable if using localhost -LOCAL=1 +#LOCAL=1 RCEMBED=1 RCLOCAL=1 @@ -41,12 +41,13 @@ fi # Major parameters -BASICCOMBO="tiggeUser:tigge" -BADCOMBO="tiggeUser:xxxxx" -URLPATH="thredds/dodsC/testRestrictedDataset/testData2.nc" -PROTO=http +AUTHSERVER="thredds-dev.unidata.ucar.edu" +BASICCOMBO="authuser:auth" +BADCOMBO="authuser:xxxxx" +URLPATH="thredds/dodsC/test2/testData.nc" +PROTO=https if test "x$LOCAL" = x ; then -URLSERVER="remotetest.unidata.ucar.edu" +URLSERVER=${AUTHSERVER} else URLSERVER="localhost:8081" fi