-
Notifications
You must be signed in to change notification settings - Fork 9
/
sellout.sh
executable file
·50 lines (38 loc) · 1.19 KB
/
sellout.sh
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
#!/bin/bash
#
# Это - тестовый скрипт для проверки работоспособности API
# Для проверки работоспособности API под управлением NodeJS @see api/goods/test-api.sh
#
cd "$(dirname "$0")"
source etc/config
# Библиотека цветов
# Сброс
Color_Off='\e[0m' # Text Reset
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan
White='\e[0;37m' # White
UCyan='\e[4;36m' # Cyan
echo -e $UCyan"Server: "$SITE$Color_Off"\n"
function assert {
SUBSTR=`echo "$1" | grep "$2"`
if [ $? != 0 ]; then
echo -e $Red"Expected: $2"$Color_Off
fi
}
function testBasicAuth {
echo -e $Cyan"Test Basic Auth"$Color_Off
RESP=`curl -is --user $LOGIN_PASS_SELLOUT $SITE/api/login/`
assert "$RESP" 'HTTP/1.1 200 OK'
assert "$RESP" 'success'
}
function ApiSelloutDebug {
echo -e $Cyan"API: /api/sellout/"$Color_Off
cat data/sellout.json | curl -is --user $LOGIN_PASS_SELLOUT -d @- $SITE/api/sellout/json/
}
# Базовые проверки
testBasicAuth
ApiSelloutDebug