Browse Source

parameters could be import from config file, in order to make a batch test

nas 3 years ago
parent
commit
e9217088dc
8 changed files with 89 additions and 13 deletions
  1. 30
    0
      test/config.sh
  2. 8
    0
      test/dep/address.sh
  3. 8
    0
      test/dep/data.sh
  4. 7
    0
      test/dep/id.sh
  5. 8
    0
      test/dep/password.sh
  6. 8
    0
      test/dep/tablename.sh
  7. 8
    0
      test/dep/username.sh
  8. 12
    13
      test/login.sh

+ 30
- 0
test/config.sh View File

@@ -0,0 +1,30 @@
1
+#!/bin/sh
2
+
3
+script_path=$(readlink -f $0)
4
+dir_path=$(dirname $script_path)
5
+
6
+get_conf(){
7
+    while IFS= read -r line ;
8
+    do
9
+	echo "$line"
10
+	cf_key=`echo $line | awk 'BEGIN {FS = "="} {print $1}'`
11
+	cf_val=`echo $line | awk 'BEGIN {FS = "="} {print $2}'`
12
+	echo "$cf_key $cf_val"
13
+	eval $cf_key=$cf_val
14
+    done < $1
15
+}
16
+
17
+get_conf test.conf
18
+
19
+if [ "$1" ]
20
+then
21
+    address=$1
22
+fi
23
+if [ "$2" ]
24
+then
25
+    username=$2
26
+fi
27
+if [ "$3" ]
28
+then
29
+    password=$3
30
+fi

+ 8
- 0
test/dep/address.sh View File

@@ -0,0 +1,8 @@
1
+#/bin/sh
2
+
3
+if [ -z "$address" ]
4
+then
5
+    echo "Missing parameters : web adresses is needed\n"
6
+    help
7
+    exit
8
+fi

+ 8
- 0
test/dep/data.sh View File

@@ -0,0 +1,8 @@
1
+#/bin/sh
2
+
3
+if [ -z "$data" ]
4
+then
5
+    echo "Missing parameters : data are needed\n"
6
+    help
7
+    exit
8
+fi

+ 7
- 0
test/dep/id.sh View File

@@ -0,0 +1,7 @@
1
+#/bin/sh
2
+if [ -z "$id" ]
3
+then
4
+    echo "Missing parameters : an id is needed\n"
5
+    help
6
+    exit
7
+fi

+ 8
- 0
test/dep/password.sh View File

@@ -0,0 +1,8 @@
1
+#/bin/sh
2
+
3
+if [ -z "$password" ]
4
+then
5
+    echo "Missing parameters : password is needed\n"
6
+    help
7
+    exit
8
+fi

+ 8
- 0
test/dep/tablename.sh View File

@@ -0,0 +1,8 @@
1
+#/bin/sh
2
+
3
+if [ -z "$tablename" ]
4
+then
5
+    echo "Missing parameters : tablename is needed\n"
6
+    help
7
+    exit
8
+fi

+ 8
- 0
test/dep/username.sh View File

@@ -0,0 +1,8 @@
1
+#/bin/sh
2
+
3
+if [ -z "$username" ]
4
+then
5
+    echo "Missing parameters : username is needed\n"
6
+    help
7
+    exit
8
+fi

+ 12
- 13
test/login.sh View File

@@ -3,28 +3,27 @@
3 3
 help() {
4 4
     echo "Syntaxe"
5 5
     echo "‾‾‾‾‾‾‾"
6
-    echo "sh $0 [ adresse ] [ username ] [ password ]\n"
6
+    echo "sh $0 [ address ] [ username ] [ password ]\n"
7 7
 }
8 8
 
9
-if [ -z "$1" ]
9
+if [ "$1" ]
10 10
 then
11
-    echo "Missing parameters : web adresses is needed\n"
12
-    help
13
-    exit
11
+    address=$1
14 12
 fi
15 13
 if [ -z "$2" ]
16 14
 then
17
-    echo "Missing parameters : username is needed\n"
18
-    help
19
-    exit
15
+    username=$2
20 16
 fi
21 17
 if [ -z "$3" ]
22 18
 then
23
-    echo "Missing parameters : password is needed\n"
24
-    help
25
-    exit
19
+    password=$3
26 20
 fi
21
+
22
+. ./config.sh
23
+. ./dep/address.sh
24
+. ./dep/username.sh
25
+. ./dep/password.sh
26
+
27 27
 echo "Login as $2 in cookie.txt"
28
-echo "$1 $2 $3"
29
-curl --header "Content-Type: application/json" --cookie-jar cookie.txt --request POST --data "{\"username\":\"$2\",\"password\":\"$3\"}" $1/api.php/login
28
+curl --header "Content-Type: application/json" --cookie-jar cookie.txt --request POST --data "{\"username\":\"$username\",\"password\":\"$password\"}" $address/api.php/login
30 29
 echo "\n"

Loading…
Cancel
Save