Skip to content

Commit 622f532

Browse files
committed
[DBS-1820] added newer style format for Mongo authorization setting
1 parent 8d9cdb2 commit 622f532

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

include/tests_databases

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,25 @@
127127
for FILE in ${MONGO_CONF_FILES}; do
128128
if [ -f ${FILE} ]; then
129129
LogText "Result: found MongoDB configuration file (${FILE})"
130-
LogText "Test: determine authorization setting in new style YAML format"
131-
AUTH_IN_CONFIG=$(${GREPBINARY} "authorization: enabled" ${FILE} | ${GREPBINARY} -E -v "(^#|#auth)")
132-
if HasData "${AUTH_IN_CONFIG}"; then
133-
LogText "Result: GOOD, found authorization option enabled in configuration file (YAML format)"
134-
MONGODB_AUTHORIZATION_ENABLED=1
135-
else
130+
# YAML with quotes
131+
if [ ${MONGODB_AUTHORIZATION_ENABLED} -eq 0 ]; then
132+
LogText "Test: determine authorization setting in new style YAML format"
133+
AUTH_IN_CONFIG=$(${GREPBINARY} "authorization: \"enabled\"" ${FILE} | ${GREPBINARY} -E -v "(^#|#auth)")
134+
if HasData "${AUTH_IN_CONFIG}"; then
135+
LogText "Result: GOOD, found authorization option enabled in configuration file (YAML format with quotes)"
136+
MONGODB_AUTHORIZATION_ENABLED=1
137+
fi
138+
fi
139+
# YAML without quotes
140+
if [ ${MONGODB_AUTHORIZATION_ENABLED} -eq 0 ]; then
141+
AUTH_IN_CONFIG=$(${GREPBINARY} "authorization: enabled" ${FILE} | ${GREPBINARY} -E -v "(^#|#auth)")
142+
if HasData "${AUTH_IN_CONFIG}"; then
143+
LogText "Result: GOOD, found authorization option enabled in configuration file (YAML format without quotes)"
144+
MONGODB_AUTHORIZATION_ENABLED=1
145+
fi
146+
fi
147+
# Old style
148+
if [ ${MONGODB_AUTHORIZATION_ENABLED} -eq 0 ]; then
136149
LogText "Result: did NOT find authorization option enabled in configuration file (with YAML format)"
137150
LogText "Test: now searching for old style configuration (auth = true) in configuration file"
138151
AUTH_IN_CONFIG=$(${GREPBINARY} "auth = true" ${FILE} | ${GREPBINARY} -v "noauth" | ${GREPBINARY} -E -v "(^#|#auth)")

0 commit comments

Comments
 (0)