-
Notifications
You must be signed in to change notification settings - Fork 0
/
ganggo_helper.bash
52 lines (49 loc) · 1.67 KB
/
ganggo_helper.bash
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
51
52
# ganggo_start_server "g1" "9000"
function ganggo_start_server() {
start_app "$1" "$2" "testing_ganggo"$(latest_tag "ganggo")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs $1" "Listening on")
echo "expected 0, got $code"
[ "$code" -eq "0" ]
}
# ganggo_create_user "g1" "http://localhost:9000"
function ganggo_create_user() {
post "username=$1&password=pppppp&confirm=pppppp" "$2/users/sign_up"
echo "expected 302, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "302" ]
}
# ganggo_fetch_token "g1" "http://localhost:9000"
function ganggo_fetch_token() {
post "grant_type=password&username=$1&password=pppppp&client_id=bats" \
"$2/api/v0/oauth/tokens"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
token=$(json_value "token")
echo "body = $HTTP_BODY"
echo "token = $token"
[ "$token" != "null" ]
echo "-H access_token:$token" > $curl_params
}
# ganggo_start_sharing "g2@localhost:9001" "http://localhost:9000"
function ganggo_start_sharing() {
# search and discover a person
post "handle=$1" "$2/api/v0/search"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
personID=$(json_value "ID")
echo "body = $HTTP_BODY"
echo "personID = $personID"
[ "$personID" -gt 0 ]
# create a new aspect
post "aspect_name=test" "$2/api/v0/aspects"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
aspectID=$(json_value "ID")
echo "body = $HTTP_BODY"
echo "aspectID = $aspectID"
[ "$aspectID" -gt 0 ]
# start sharing with person
post "" "$2/api/v0/people/$personID/aspects/$aspectID"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
}