File: testauth.old

package info (click to toggle)
netcdf 1:4.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 104,952 kB
  • sloc: ansic: 228,683; sh: 10,980; yacc: 2,561; makefile: 1,319; lex: 1,173; xml: 173; awk: 2
file content (213 lines) | stat: -rw-r--r-- 4,071 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/bin/sh

#NOEMBED=1
#NOLOCAL=1
#NOHOME=1
#NOENV=1

#DBG=1
#SHOW=1

# Choose at most 1
#GDB=1
#VG=1

NFL=1

WD=`pwd`

NETRCFILE=$WD/test_auth_netrc
# This is the control variable
NETRC=$NETRCFILE

COOKIES="${WD}/test_auth_cookies"

RC=.daprc

NCLOGFILE=stderr
if test "x$DBG" = x1 ; then
SHOW=1
fi

# Major parameters

BASICCOMBO="tiggeUser:tigge"
URLSERVER="remotetest.unidata.ucar.edu"
URLPATH="thredds/dodsC/restrict/testData.nc"

# See if we need to override
if test "x$URS" != "x" ; then
#https://54.86.135.31/opendap/data/nc/fnoc1.nc.dds
URLSERVER="54.86.135.31"
URLPATH="opendap/data/nc/fnoc1.nc"
BASICCOMBO="$URS"
NOEMBED=1
NETRC=$NETRCFILE
else
NETRC=
fi

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`

NCDUMP=
for o in ./.libs/ncdump.exe ./.libs/ncdump ./ncdump.exe ./ncdump ; do
  if test -f $o ; then
  NCDUMP=$o
  break;
  fi
done
if test "x$NCDUMP" = x ; then
echo "no ncdump"
exit 1
fi

if test "x$SHOW" = x ; then
OUTPUT="> /dev/null"
else
OUTPUT=
fi

if test "x$TEMP" = x ; then
  TEMP="/tmp"
fi
TEMP=`echo "$TEMP" | sed -e "s|/$||"`

LOCALRC=./$RC
HOMERC=${HOME}/$RC
HOMERC=`echo "$HOMERC" | sed -e "s|//|/|g"`
ENVRC="$TEMP/$RC"

cd `pwd`
builddir=`pwd`
# Hack for CYGWIN
cd $srcdir
srcdir=`pwd`
cd ${builddir}

function createrc {
if test "x$1" != x ; then
RCP=$1

rm -f $RCP
echo "Creating rc file $RCP"
if test "x${DBG}" != x ; then
echo "HTTP.VERBOSE=1" >>$RCP
fi	
echo "HTTP.COOKIEJAR=${COOKIES}" >>$RCP
if test "x${URS}" = x ; then
echo "HTTP.CREDENTIALS.USERPASSWORD=${BASICCOMBO}" >>$RCP
fi
if test "x${NETRC}" != x && test "x$NFL" = x ; then
echo "HTTP.NETRC=${NETRC}" >>$RCP
fi
fi
}

function createnetrc {
if test "x$1" != x ; then
rm -f $1
echo "Creating netrc file $1"
echo "machine uat.urs.earthdata.nasa.gov login $BASICUSER password $BASICPWD" >>$1
#echo "machine 54.86.135.31 login $BASICUSER password $BASICPWD" >>$1
fi
}

# Forcibly remove all and do not restore with save
function reset {
    for f in ./$RC $HOMERC $ENVRC $COOKIES $NETRC ; do
      rm -f ${f}
    done      
}

# Restore from .save files
function restore {
  for f in ./$RC $HOMERC $ENVRC $COOKIES $NETRC ; do
    rm -f ${f}
    if test -f ${f}.save ; then
      echo "restoring old ${f}"
      cp ${f}.save ${f}
    fi      
  done      
}

function save {
  for f in ./$RC $HOMERC $ENVRC $COOKIES $NETRC ; do
    if test -f $f ; then
      if test -f ${f}.save ; then
        ignore=1
      else
        echo "saving $f"
        cp ${f} ${f}.save
      fi
    fi      
  done      
}

export LD_LIBRARY_PATH="../liblib/.libs:/usr/local/lib:/usr/lib64:$LD_LIBRARY_PATH"

if test "x$GDB" = x1 ; then
NCDUMP="gdb --args $NCDUMP"
fi
if test "x$VG" = x1 ; then
NCDUMP="valgrind --leak-check=full $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 a file from the URL
echo "command: ${NCDUMP} -h $URL ${OUTPUT}"
${NCDUMP} -h "$URL" ${OUTPUT}
fi

URL="https://${URLSERVER}/$URLPATH"
if test "x$NOLOCAL" != x1 ; then
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 ${OUTPUT}"
${NCDUMP} -h "$URL" ${OUTPUT}
fi

if test "x$NOHOME" != x1 ; then
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 ${OUTPUT}"
${NCDUMP} -h "$URL" ${OUTPUT}
fi

if test "x$NOENV" != x1 ; then
echo "*** Testing rc file from env variable"
# Create the rc file and (optional) netrc file
reset
createnetrc $NETRC
export NCRCFILE=$ENVRC
createrc $NCRCFILE

# Invoke ncdump to extract a file the URL
echo "command: ${NCDUMP} -h $URL ${OUTPUT}"
${NCDUMP} -h "$URL" ${OUTPUT} 
fi

set +x
#restore