Skip to content

Commit ee0f50d

Browse files
committed
Merge branch 'devel' of github.com:ORNL/DataFed into devel
2 parents 4f3fdb9 + 072041d commit ee0f50d

File tree

21 files changed

+302
-373
lines changed

21 files changed

+302
-373
lines changed
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/bin/bash
22

33
# If no arguments are provided assume command paths have not been passed in
4-
if [ $# -eq 0 ]
5-
then
4+
if [ $# -eq 0 ]; then
65
TIMEOUT_CMD="timeout"
76
TCPDUMP_CMD="tcpdump"
87
MAX_TEST_TIME_SEC=4
@@ -13,10 +12,8 @@ else
1312
fi
1413

1514
# Check that pcap group exists and the user is part of it
16-
if [ $(getent group pcap) ]
17-
then
18-
if id -nG "$USER" | grep -qw "pcap"
19-
then
15+
if [ $(getent group pcap) ]; then
16+
if id -nG "$USER" | grep -qw "pcap"; then
2017
echo "CONTINUE"
2118
else
2219
echo "SKIPPING - user does not belong to pcap group cannot run tcp_secure test"
@@ -27,28 +24,27 @@ else
2724
exit 0
2825
fi
2926

30-
echo
27+
echo
3128
echo "Running with:"
3229
echo "TCPDUMP: ${TCPDUMP_CMD}"
3330
echo "TIMEOUT: ${TIMEOUT_CMD}"
3431
echo "MAX_TEST_TIME: ${MAX_TEST_TIME_SEC}"
3532

3633
# Grab the packets sent on the loop back interface (127.0.0.1) and port 7515
37-
output=$( ${TIMEOUT_CMD} ${MAX_TEST_TIME_SEC} ${TCPDUMP_CMD} -vvv -A port 7515 -i lo)
38-
match=$( echo "$output" | grep token)
34+
output=$(${TIMEOUT_CMD} ${MAX_TEST_TIME_SEC} ${TCPDUMP_CMD} -vvv -A port 7515 -i lo)
35+
match=$(echo "$output" | grep token)
3936

4037
echo "Content of grep ${match}"
41-
# If '.magic_token' is returned from the network sniffer then we know that
38+
# If '.magic_token' is returned from the network sniffer then we know that
4239
# the encryption is not working
43-
if [[ "${match}" == ".magic_token" ]]
44-
then
40+
if [[ "${match}" == ".magic_token" ]]; then
4541
echo "SUCCESS - the connection is expected to be insecure"
4642
exit 0
4743
else
4844
echo "FAILED - the connection is unreadable, either it is encrypted when it should not be or there is an error."
4945
echo " it could be the case that the permissions have changed on tcpdump. See the README for settings"
5046
echo " that must be enabled to run it correctly."
51-
echo
47+
echo
5248
echo "$output"
5349
exit 1
5450
fi

common/tests/security/tcp_secure/test_tcp_secure.sh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/bin/bash
22

33
# If no arguments are provided assume command paths have not been passed in
4-
if [ $# -eq 0 ]
5-
then
4+
if [ $# -eq 0 ]; then
65
TIMEOUT_CMD="timeout"
76
TCPDUMP_CMD="tcpdump"
87
MAX_TEST_TIME_SEC=2
@@ -13,10 +12,8 @@ else
1312
fi
1413

1514
# Check that pcap group exists and the user is part of it
16-
if [ $(getent group pcap) ]
17-
then
18-
if id -nG "$USER" | grep -qw "pcap"
19-
then
15+
if [ $(getent group pcap) ]; then
16+
if id -nG "$USER" | grep -qw "pcap"; then
2017
echo "CONTINUE"
2118
else
2219
echo "SKIPPING - user does not belong to pcap group cannot run tcp_secure test"
@@ -34,13 +31,12 @@ echo "TIMEOUT: ${TIMEOUT_CMD}"
3431
echo "MAX_TEST_TIME: ${MAX_TEST_TIME_SEC}"
3532

3633
# Grab the first 30 packets sent on the loop back interface (127.0.0.1) and port 7515
37-
match=$( "${TIMEOUT_CMD}" "${MAX_TEST_TIME_SEC}" "${TCPDUMP_CMD}" -vvv -A port 7515 -i lo | grep token)
34+
match=$("${TIMEOUT_CMD}" "${MAX_TEST_TIME_SEC}" "${TCPDUMP_CMD}" -vvv -A port 7515 -i lo | grep token)
3835

3936
echo "Content of grep ${match}"
40-
# If '.magic_token' is returned from the network sniffer then we know that
37+
# If '.magic_token' is returned from the network sniffer then we know that
4138
# the encryption is not working
42-
if [[ "${match}" == ".magic_token" ]]
43-
then
39+
if [[ "${match}" == ".magic_token" ]]; then
4440
echo "FAILED - the connection is insecure we were able to pull out the token"
4541
exit 1
4642
else

compose/all/cleanup_globus_files.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ SOURCE=$(dirname "$SCRIPT")
44
PROJECT_ROOT=$(realpath "${SOURCE}/../../")
55

66
"${PROJECT_ROOT}/scripts/compose_cleanup_globus_files.sh" -d "$(pwd)"
7-

compose/all/generate_env.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ PROJECT_ROOT=$(realpath "${SOURCE}/../../")
77
export DATAFED_COMPOSE_REPO_DOMAIN="datafed-repo"
88

99
"${PROJECT_ROOT}/scripts/compose_generate_env.sh" -d "$(pwd)" "$@"
10-

compose/metadata/build_metadata_images_for_compose.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ PROJECT_ROOT=$(realpath "${SOURCE}/../../")
88

99
BUILD_ARG_FILE="$SOURCE/.build-args"
1010
if [ $# -gt 0 ]; then
11-
# Do not check if file already exists becuase other generate scripts
12-
# from a different repo might have already put their args in the file
13-
# and calling this script might be the second step. Where this step would
14-
# be appending to an existing file.
15-
BUILD_ARG_FILE="$1/.build-args"
11+
# Do not check if file already exists becuase other generate scripts
12+
# from a different repo might have already put their args in the file
13+
# and calling this script might be the second step. Where this step would
14+
# be appending to an existing file.
15+
BUILD_ARG_FILE="$1/.build-args"
1616
fi
1717

1818
# Generate arg list
1919

20-
if [ ! -f "$BUILD_ARG_FILE" ]
21-
then
20+
if [ ! -f "$BUILD_ARG_FILE" ]; then
2221
echo "Missing .build-args file, please run generate_build_args.sh first."
2322
fi
2423

compose/metadata/generate_build_args.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ if [ $# -gt 0 ]; then
2222
else
2323

2424
# Force the user to manaully rm the file to avoid accidental overwrites.
25-
if [ -f "$BUILD_ARG_FILE" ]
26-
then
25+
if [ -f "$BUILD_ARG_FILE" ]; then
2726
echo "$BUILD_ARG_FILE already exist! Will not overwrite!"
2827
exit 0
2928
fi
3029
fi
3130

3231
# Needs to append to the ./build-args.sh file not overwrite.
33-
cat << EOF >> "$BUILD_ARG_FILE"
32+
cat <<EOF >>"$BUILD_ARG_FILE"
3433
BASE_IMAGE=debian:bookworm-slim
3534
EOF

compose/metadata/generate_env.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ SOURCE=$(dirname "$SCRIPT")
44
PROJECT_ROOT=$(realpath "${SOURCE}/../../")
55

66
"${PROJECT_ROOT}/scripts/compose_generate_env.sh" -d "$(pwd)" -m
7-

compose/repo/cleanup_globus_files.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ SOURCE=$(dirname "$SCRIPT")
44
PROJECT_ROOT=$(realpath "${SOURCE}/../../")
55

66
"${PROJECT_ROOT}/scripts/compose_cleanup_globus_files.sh" -d "$(pwd)"
7-

compose/repo/generate_env.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ SOURCE=$(dirname "$SCRIPT")
44
PROJECT_ROOT=$(realpath "${SOURCE}/../../")
55

66
"${PROJECT_ROOT}/scripts/compose_generate_env.sh" -d "$(pwd)" -r
7-
Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22

3-
43
set -uef -o pipefail
54

65
SCRIPT=$(realpath "$BASH_SOURCE[0]")
@@ -10,8 +9,7 @@ source "${PROJECT_ROOT}/config/datafed.sh"
109
source "${PROJECT_ROOT}/scripts/dependency_versions.sh"
1110
source "${PROJECT_ROOT}/scripts/dependency_install_functions.sh"
1211

13-
Help()
14-
{
12+
Help() {
1513
echo "$(basename $0) Will initialize fixtures for Foxx tests"
1614
echo
1715
echo "Syntax: $(basename $0) [-h|u|p|y]"
@@ -31,74 +29,71 @@ Help()
3129
local_DATABASE_NAME="sdms"
3230
local_DATABASE_USER="root"
3331

34-
if [ -z "${DATAFED_DATABASE_HOST:-}" ]
35-
then
32+
if [ -z "${DATAFED_DATABASE_HOST:-}" ]; then
3633
local_DATAFED_DATABASE_HOST="localhost"
3734
else
3835
local_DATAFED_DATABASE_HOST=$(printenv DATAFED_DATABASE_HOST)
3936
fi
4037

41-
if [ -z "${DATAFED_DATABASE_PASSWORD:-}" ]
42-
then
38+
if [ -z "${DATAFED_DATABASE_PASSWORD:-}" ]; then
4339
local_DATAFED_DATABASE_PASSWORD=""
4440
else
4541
local_DATAFED_DATABASE_PASSWORD=$(printenv DATAFED_DATABASE_PASSWORD)
4642
fi
4743

48-
if [ -z "${FOXX_MAJOR_API_VERSION:-}" ]
49-
then
50-
local_FOXX_MAJOR_API_VERSION=$(cat ${PROJECT_ROOT}/cmake/Version.cmake | grep -o -P "(?<=FOXX_API_MAJOR).*(?=\))" | xargs )
44+
if [ -z "${FOXX_MAJOR_API_VERSION:-}" ]; then
45+
local_FOXX_MAJOR_API_VERSION=$(cat ${PROJECT_ROOT}/cmake/Version.cmake | grep -o -P "(?<=FOXX_API_MAJOR).*(?=\))" | xargs)
5146
else
5247
local_FOXX_MAJOR_API_VERSION=$(printenv FOXX_MAJOR_API_VERSION)
5348
fi
5449

5550
VALID_ARGS=$(getopt -o hu:p:f: --long 'help',database-user:,database-password:,foxx-api-major-version: -- "$@")
5651
if [[ $? -ne 0 ]]; then
57-
exit 1;
52+
exit 1
5853
fi
5954
eval set -- "$VALID_ARGS"
6055
while [ : ]; do
6156
echo "$1"
6257
case "$1" in
63-
-h | --help)
64-
Help
65-
exit 0
66-
;;
67-
-u | --database-user)
68-
echo "Processing 'Database user' option. Input argument is '$2'"
69-
local_DATABASE_USER=$2
70-
shift 2
71-
;;
72-
-p | --database-password)
73-
echo "Processing 'Database password' option. Input argument is '$2'"
74-
local_DATAFED_DATABASE_PASSWORD=$2
75-
shift 2
76-
;;
77-
-f | --foxx-api-major-version)
78-
echo "Processing 'Foxx major api version' option. Input argument is '$2'"
79-
local_FOXX_MAJOR_API_VERSION=$2
80-
shift 2
81-
;;
82-
--) shift;
83-
break
84-
;;
85-
\?) # incorrect option
86-
echo "Error: Invalid option"
87-
exit;;
58+
-h | --help)
59+
Help
60+
exit 0
61+
;;
62+
-u | --database-user)
63+
echo "Processing 'Database user' option. Input argument is '$2'"
64+
local_DATABASE_USER=$2
65+
shift 2
66+
;;
67+
-p | --database-password)
68+
echo "Processing 'Database password' option. Input argument is '$2'"
69+
local_DATAFED_DATABASE_PASSWORD=$2
70+
shift 2
71+
;;
72+
-f | --foxx-api-major-version)
73+
echo "Processing 'Foxx major api version' option. Input argument is '$2'"
74+
local_FOXX_MAJOR_API_VERSION=$2
75+
shift 2
76+
;;
77+
--)
78+
shift
79+
break
80+
;;
81+
\?) # incorrect option
82+
echo "Error: Invalid option"
83+
exit
84+
;;
8885
esac
8986
done
9087

9188
ERROR_DETECTED=0
92-
if [ -z "$local_DATAFED_DATABASE_PASSWORD" ]
93-
then
89+
if [ -z "$local_DATAFED_DATABASE_PASSWORD" ]; then
9490
echo "Error DATAFED_DATABASE_PASSWORD is not defined, this is a required argument"
9591
echo " This variable can be set using the command line option -p, --database-password"
9692
echo " or with the environment variable DATAFED_DATABASE_PASSWORD."
9793
ERROR_DETECTED=1
9894
fi
9995

100-
if [ "$ERROR_DETECTED" == "1" ]
101-
then
96+
if [ "$ERROR_DETECTED" == "1" ]; then
10297
exit 1
10398
fi
10499

@@ -116,30 +111,30 @@ install_nvm
116111
install_node
117112

118113
FOXX_PREFIX=""
119-
if ! command -v foxx > /dev/null 2>&1; then
120-
FOXX_PREFIX="${DATAFED_DEPENDENCIES_INSTALL_PATH}/npm/bin/"
114+
if ! command -v foxx >/dev/null 2>&1; then
115+
FOXX_PREFIX="${DATAFED_DEPENDENCIES_INSTALL_PATH}/npm/bin/"
121116
fi
122117

123118
PATH_TO_PASSWD_FILE=${SOURCE}/database_temp.password
124119

125120
# set up test user fixtures, this script should be idempotent, this script is described in the manifest
126121
"${FOXX_PREFIX}foxx" script -u "${local_DATABASE_USER}" \
127-
--server "tcp://${local_DATAFED_DATABASE_HOST}:8529" \
128-
-p "${PATH_TO_PASSWD_FILE}" \
129-
--database "${local_DATABASE_NAME}" \
130-
"/api/${local_FOXX_MAJOR_API_VERSION}" user-fixture
122+
--server "tcp://${local_DATAFED_DATABASE_HOST}:8529" \
123+
-p "${PATH_TO_PASSWD_FILE}" \
124+
--database "${local_DATABASE_NAME}" \
125+
"/api/${local_FOXX_MAJOR_API_VERSION}" user-fixture
131126

132127
# set up test globus collection fixtures, this script should be idempotent, this script is described in the manifest
133128
"${FOXX_PREFIX}foxx" script -u "${local_DATABASE_USER}" \
134-
--server "tcp://${local_DATAFED_DATABASE_HOST}:8529" \
135-
-p "${PATH_TO_PASSWD_FILE}" \
136-
--database "${local_DATABASE_NAME}" \
137-
"/api/${local_FOXX_MAJOR_API_VERSION}" collection-fixture
129+
--server "tcp://${local_DATAFED_DATABASE_HOST}:8529" \
130+
-p "${PATH_TO_PASSWD_FILE}" \
131+
--database "${local_DATABASE_NAME}" \
132+
"/api/${local_FOXX_MAJOR_API_VERSION}" collection-fixture
138133

139134
# set up test globus token fixtures, this script should be idempotent, this script is described in the manifest
140135
# order matters, must follow user and collection fixtures
141136
"${FOXX_PREFIX}foxx" script -u "${local_DATABASE_USER}" \
142-
--server "tcp://${local_DATAFED_DATABASE_HOST}:8529" \
143-
-p "${PATH_TO_PASSWD_FILE}" \
144-
--database "${local_DATABASE_NAME}" \
145-
"/api/${local_FOXX_MAJOR_API_VERSION}" globus-token-fixture
137+
--server "tcp://${local_DATAFED_DATABASE_HOST}:8529" \
138+
-p "${PATH_TO_PASSWD_FILE}" \
139+
--database "${local_DATABASE_NAME}" \
140+
"/api/${local_FOXX_MAJOR_API_VERSION}" globus-token-fixture

0 commit comments

Comments
 (0)