Commit 7c027be3 authored by Lukas Matt's avatar Lukas Matt

Move regular used functions into separate helper files

parent 89228d6f
# vim:ft=sh
load test_helper
load ganggo_helper
gngg_endpnt="http://localhost:9000"
......@@ -10,15 +11,11 @@ gngg_endpnt="http://localhost:9000"
}
@test "$btf start ganggo#1 server" {
start_app "g1" "9000" "testing_ganggo:"$(latest_tag "ganggo")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs g1" "Listening on")
echo "expected 0, got $code"
[ "$code" -eq "0" ]
ganggo_start_server g1 "9000"
}
@test "$btf start diaspora#1 server" {
start_app "d1" "3000" "testing_diaspora:"$(latest_tag "diaspora")
start_app "d1" "3000" "testing_diaspora"$(latest_tag "diaspora")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs d1" "Starting Diaspora in production")
echo "expected 0, got $code"
......@@ -28,9 +25,7 @@ gngg_endpnt="http://localhost:9000"
}
@test "$btf create ganggo user" {
post "username=g1&password=pppppp&confirm=pppppp" "$gngg_endpnt/users/sign_up"
echo "expected 302, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "302" ]
ganggo_create_user g1 $gngg_endpnt
}
@test "$btf create diaspora user" {
......
......@@ -4,6 +4,7 @@
#
load test_helper
load ganggo_helper
endpoint="http://localhost:9000"
......@@ -13,15 +14,11 @@ endpoint="http://localhost:9000"
}
@test "$btf start ganggo#1 server" {
start_app "g1" "9000" "testing_ganggo:"$(latest_tag "ganggo")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs g1" "Listening on")
echo "expected 0, got $code"
[ "$code" -eq "0" ]
ganggo_start_server g1 "9000"
}
@test "$btf start diaspora#1 server" {
start_app "d1" "3000" "testing_diaspora:"$(latest_tag "diaspora")
start_app "d1" "3000" "testing_diaspora"$(latest_tag "diaspora")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs d1" "Starting Diaspora in production")
echo "expected 0, got $code"
......@@ -31,49 +28,19 @@ endpoint="http://localhost:9000"
}
@test "$btf create user" {
post "username=g1&password=pppppp&confirm=pppppp" "$endpoint/users/sign_up"
echo "expected 302, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "302" ]
ganggo_create_user g1 $endpoint
}
@test "$btf create diaspora user" {
skip "exists already"
}
# according to https://ganggo.github.io/api/#api-Oauth-ApiOAuth_Create
@test "$btf fetch user token" {
post "grant_type=password&username=g1&password=pppppp&client_id=bats" \
"$endpoint/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_fetch_token g1 $endpoint
}
@test "$btf setup user relations" {
# search and discover a person
post "handle=d1@localhost:3000" "$endpoint/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" "$endpoint/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 "" "$endpoint/api/v0/people/$personID/aspects/$aspectID"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
ganggo_start_sharing "d1@localhost:3000" $endpoint
}
function send_type() {
......
......@@ -4,6 +4,7 @@
#
load test_helper
load ganggo_helper
g1endpoint="http://localhost:9000"
g2endpoint="http://localhost:9001"
......@@ -16,67 +17,27 @@ g2endpoint="http://localhost:9001"
}
@test "$btf start ganggo#1 server" {
start_app "g1" "9000" "testing_ganggo:"$(latest_tag "ganggo")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs g1" "Listening on")
echo "expected 0, got $code"
[ "$code" -eq "0" ]
ganggo_start_server g1 "9000"
}
@test "$btf start ganggo#2 server" {
start_app "g2" "9001" "testing_ganggo:"$(latest_tag "ganggo")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs g2" "Listening on")
echo "expected 0, got $code"
[ "$code" -eq "0" ]
ganggo_start_server g2 "9001"
}
@test "$btf create user#1" {
post "username=g1&password=pppppp&confirm=pppppp" "$g1endpoint/users/sign_up"
echo "expected 302, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "302" ]
ganggo_create_user g1 $g1endpoint
}
@test "$btf create user#2" {
post "username=g2&password=pppppp&confirm=pppppp" "$g2endpoint/users/sign_up"
echo "expected 302, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "302" ]
ganggo_create_user g2 $g2endpoint
}
# according to https://ganggo.github.io/api/#api-Oauth-ApiOAuth_Create
@test "$btf fetch user#1 token" {
post "grant_type=password&username=g1&password=pppppp&client_id=bats" \
"$g1endpoint/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_fetch_token g1 $g1endpoint
}
@test "$btf setup user relations" {
# search and discover a person
post "handle=g2@localhost:9001" "$g1endpoint/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" "$g1endpoint/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 "" "$g1endpoint/api/v0/people/$personID/aspects/$aspectID"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
ganggo_start_sharing "g2@localhost:9001" $g1endpoint
}
function send_type() {
......
# 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" ]
}
......@@ -5,7 +5,7 @@ load test_helper
endpoint="http://localhost:3000"
@test "$btf start mastodon#1 server" {
start_app "m1" "3000" "testing_mastodon:"$(latest_tag "mastodon")
start_app "m1" "3000" "testing_mastodon"$(latest_tag "mastodon")
[ "$?" -eq 0 ]
code=$(wait_for_mastodon "m1")
echo "expected 0, got $code"
......@@ -13,7 +13,7 @@ endpoint="http://localhost:3000"
}
@test "$btf start mastodon#2 server" {
start_app "m2" "3001" "testing_mastodon:"$(latest_tag "mastodon")
start_app "m2" "3001" "testing_mastodon"$(latest_tag "mastodon")
[ "$?" -eq 0 ]
code=$(wait_for_mastodon "m2")
echo "expected 0, got $code"
......
......@@ -59,6 +59,7 @@ function start_app() {
echo "With SHA $PRSHA"
params="-e PRSHA=$PRSHA -e PRREPO=$PRREPO"
fi
echo "Starting docker container $1 (thefederation/$3) on port $2"
docker run --name=$1 $params -e DATABASE=$1 -e PORT=$2 -p $2:$2 --net=host -d thefederation/$3
}
......@@ -138,7 +139,7 @@ function latest_tag() {
git tag |sort -r |while read tag; do
label=$(echo $tag |cut -d- -f2)
if [ "$label" == "$1" ]; then
echo $tag
echo :$tag
break
fi
done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment