support not authenticate testapi 41/65241/1
authorSerenaFeng <feng.xiaowei@zte.com.cn>
Tue, 20 Nov 2018 07:57:46 +0000 (15:57 +0800)
committerSerenaFeng <feng.xiaowei@zte.com.cn>
Tue, 20 Nov 2018 07:57:46 +0000 (15:57 +0800)
Change-Id: I29db99414d53155a6eec96f93169e07523645b12
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
testapi/docker/prepare-env.sh

index 9086e77..a1b01bd 100755 (executable)
@@ -2,18 +2,20 @@
 FILE=/etc/opnfv_testapi/config.ini
 
 
-if [ "$mongodb_url" != "" ]; then
-    sudo crudini --set --existing $FILE mongo url $mongodb_url
-fi
+[[ "${mongodb_url}" == "" ]] && mongodb_url=mongodb://mongo:27017/
+[[ "${base_url}" == "" ]] && base_url=http://localhost:8000
+[[ ! "${auth}" =~ [f|F]alse ]] && auth=true
 
-if [ "$base_url" != "" ]; then
-    sudo crudini --set --existing $FILE api url $base_url/api/v1
-    sudo crudini --set --existing $FILE ui url $base_url
-    sudo cat > /usr/local/share/opnfv_testapi/testapi-ui/config.json << EOF
+auth_server=`echo ${auth:0:1} | tr '[:lower:]' '[:upper:]'``echo ${auth:1} | tr '[:upper:]' '[:lower:]'`
+auth_web=`echo ${auth} | tr '[:upper:]' '[:lower:]'`
+sudo crudini --set --existing ${FILE} mongo url ${mongodb_url}
+sudo crudini --set --existing ${FILE} api url ${base_url}/api/v1
+sudo crudini --set --existing ${FILE} ui url ${base_url}
+sudo crudini --set --existing ${FILE} api authenticate ${auth_server}
+
+sudo cat > /usr/local/share/opnfv_testapi/testapi-ui/config.json << EOF
 {
-  "testapiApiUrl": "$base_url/api/v1",
-  "authenticate": true
+  "testapiApiUrl": "${base_url}/api/v1",
+  "authenticate": ${auth_web}
 }
 EOF
-
-fi