Commit eb507461 authored by zauberstuhl's avatar zauberstuhl

Refactor testsuite code

parent cfa553b4
...@@ -48,13 +48,13 @@ Say we have a project called `testproject` and it can communicate with other `te ...@@ -48,13 +48,13 @@ Say we have a project called `testproject` and it can communicate with other `te
If we have two servers running on `172.17.0.4:3000` and `172.17.0.5:3000` we can send `172.17.0.4` If we have two servers running on `172.17.0.4:3000` and `172.17.0.5:3000` we can send `172.17.0.4`
a simple message by executing following command: a simple message by executing following command:
curl http://172.17.0.5:3000/add@172.17.0.4:3000 curl http://172.17.0.5:3000/send?http://172.17.0.4:3000/ping
If we ask the server directly whether it received a message or not: If we ask the server directly whether it received a message or not:
curl http://172.17.0.4:3000 docker logs <container-172.17.0.4> 2>&1 | grep ping | wc -l
it should return one, otherwise it will return zero! it should return the number of received pings!
**Getting started** **Getting started**
...@@ -75,9 +75,11 @@ Then you can install the testsuite dependencies: ...@@ -75,9 +75,11 @@ Then you can install the testsuite dependencies:
* github.com/stedolan/jq * github.com/stedolan/jq
* github.com/sstephenson/bats * github.com/sstephenson/bats
Simply run the install script or do it manually: If you prefer running tests within docker you can also use the testsuite image:
bash scripts/install.sh docker run --rm -ti \
-v /var/run/docker.sock:/var/run/docker.sock \
registry.git.feneas.org/feneas/federation/testsuite:latest bash
## Docker Image ## Docker Image
...@@ -114,14 +116,12 @@ Following environment variables will be available while tests are running: ...@@ -114,14 +116,12 @@ Following environment variables will be available while tests are running:
For our `testproject` that could look something like this: For our `testproject` that could look something like this:
``` ```
FROM debian:jessie FROM golang:1.12
RUN apt-get update RUN git clone \
RUN apt-get install -y \ https://git.feneas.org/feneas/federation/testsuite-testproject.git \
git-core postgresql-client netcat curl /go/src/feneas/federation/testsuite-testproject
WORKDIR /go/src/feneas/federation/testsuite-testproject
RUN git clone https://git.feneas.org/feneas/federation/testsuite-testproject.git
WORKDIR testsuite-testproject
ADD entrypoint.sh /entrypoint.sh ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh
...@@ -147,7 +147,12 @@ if [ "$PROJECT" == "testproject" ]; then ...@@ -147,7 +147,12 @@ if [ "$PROJECT" == "testproject" ]; then
} }
fi fi
./testproject.sh $DATABASE postgreshost $PORT go build -o server main.go || {
echo "Cannot build sources"
exit 1
}
./server :$PORT
``` ```
### Building ### Building
...@@ -156,7 +161,7 @@ fi ...@@ -156,7 +161,7 @@ fi
Last final step before we have a fully functional docker image is to build the actual image: Last final step before we have a fully functional docker image is to build the actual image:
docker build --no-cache -t registry.git.feneas.org/feneas/federation/testsuite/testproject:v1.0.3-testproject . docker build --no-cache -t registry.git.feneas.org/feneas/federation/testsuite/testproject:vX.X.X-testproject .
The testsuite requires a special naming for every image: `registry.git.feneas.org/feneas/federation/testsuite/<project>:<version>-<project>` The testsuite requires a special naming for every image: `registry.git.feneas.org/feneas/federation/testsuite/<project>:<version>-<project>`
...@@ -166,7 +171,7 @@ and create a project tag and we are done with the image part: ...@@ -166,7 +171,7 @@ and create a project tag and we are done with the image part:
cd <workspace>/testsuite/testproject cd <workspace>/testsuite/testproject
git add . git add .
git commit -m "Add testproject docker image" git commit -m "Add testproject docker image"
git tag v1.0.3-testproject git tag vX.X.X-testproject
## Testing ## Testing
...@@ -186,34 +191,23 @@ I suggest we start with loading the test helper first since it holds many helper ...@@ -186,34 +191,23 @@ I suggest we start with loading the test helper first since it holds many helper
load test_helper load test_helper
``` ```
Since we need two instances of our `testproject` we have to create two postgresql databases first: Since we need two instances of our `testproject` we have to create them first:
```
@test "$btf create databases" {
for tp in tp1 tp2; do
create_database $tp
[ "$?" -eq 0 ]
done
}
```
and start-up the mentioned servers:
``` ```
@test "$btf start testproject#1 server" { @test "$PREFIX start testproject#1 server" {
start_app tp1 3000 testproject$(latest_tag testproject) start_app tp1 3000 testproject$(latest_tag testproject)
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
} }
@test "$btf start testproject#2 server" { @test "$PREFIX start testproject#2 server" {
start_app tp2 3000 testproject$(latest_tag testproject) start_app tp2 3001 testproject$(latest_tag testproject)
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
} }
``` ```
Now the interesting part starts.. We want to test a request to tp2! Now the interesting part starts.. We want to test a request to tp2!
If we execute the curl command (mentioned at the beginning of this If we execute the curl command (mentioned at the beginning of this
document) tp2 should federated/relay the message to tp1. document) tp2 should federate/relay the message to tp1.
To prove this we send two requests: To prove this we send two requests:
...@@ -221,24 +215,38 @@ To prove this we send two requests: ...@@ -221,24 +215,38 @@ To prove this we send two requests:
2. to tp1 ensuring the message was received 2. to tp1 ensuring the message was received
``` ```
@test "$btf increase count on tp1 via tp2" { @test "$PREFIX ping both servers, should reply with pong" {
get "http://$(container_ip tp2):3000/add@$(container_ip tp1):3000" get "http://$(container_ip tp1):3000/ping"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ] [ "$HTTP_STATUS_CODE" == "200" ]
echo "expected pong, got $HTTP_BODY"
[ "$HTTP_BODY" == "pong" ]
get "http://$(container_ip tp2):3001/ping"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
echo "expected pong, got $HTTP_BODY"
[ "$HTTP_BODY" == "pong" ]
} }
@test "$btf test count on tp1, it should be one" { @test "$PREFIX ping testproject#1 via testproject#2 server" {
get "http://$(container_ip tp1):3000" get "http://$(container_ip tp2):3001/send?http://$(container_ip tp1):3000/ping"
echo "expected 200, got $HTTP_STATUS_CODE" echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ] [ "$HTTP_STATUS_CODE" == "200" ]
echo "expected 1, got $HTTP_BODY" echo "expected ok, got $HTTP_BODY"
[ "$HTTP_BODY" == "1" ] [ "$HTTP_BODY" == "ok" ]
# ping count should be two by now
count=$(docker logs $(container_id tp1) 2>&1 | grep ping | wc -l)
echo "expected 2, got $count"
[ "$count" -eq "2" ]
} }
``` ```
Last but not least we do some cleaning and we are done with our first unit test for the federated web `\m/` Last but not least we do some cleaning and we are done with our first unit test for the federated web `\m/`
``` ```
@test "$btf stop and delete the containers" { @test "$PREFIX stop and delete the containers" {
for tp in tp1 tp2; do for tp in tp1 tp2; do
stop_app $tp stop_app $tp
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
...@@ -246,16 +254,9 @@ Last but not least we do some cleaning and we are done with our first unit test ...@@ -246,16 +254,9 @@ Last but not least we do some cleaning and we are done with our first unit test
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
done done
} }
@test "$btf drop databases" {
for tp in tp1 tp2; do
drop_database $tp
[ "$?" -eq 0 ]
done
}
``` ```
{% include info.html text="You will find the full version of testproject.bats [here](https://git.feneas.org/feneas/federation/testsuite/raw/master/testproject.bats)!" %} {% include info.html text="You will find the full version of testproject.bats [here](https://git.feneas.org/feneas/federation/testsuite/raw/master/tests/testproject.bats)!" %}
That should be it! You can add and commit your changes and request a MR upstream: That should be it! You can add and commit your changes and request a MR upstream:
......
...@@ -24,7 +24,7 @@ function ganggo_fetch_token() { ...@@ -24,7 +24,7 @@ function ganggo_fetch_token() {
echo "body = $HTTP_BODY" echo "body = $HTTP_BODY"
echo "token = $token" echo "token = $token"
[ "$token" != "null" ] [ "$token" != "null" ]
echo "-H access_token:$token" > $curl_params echo "-H access_token:$token" > $CURL_PARAMS
} }
# ganggo_start_sharing "g2@localhost:9001" "http://localhost:9000" # ganggo_start_sharing "g2@localhost:9001" "http://localhost:9000"
......
...@@ -27,7 +27,7 @@ function socialhome_fetch_token() { ...@@ -27,7 +27,7 @@ function socialhome_fetch_token() {
echo "body = $HTTP_BODY" echo "body = $HTTP_BODY"
echo "token = $token" echo "token = $token"
[ "$token" != "null" ] [ "$token" != "null" ]
echo "-H 'Authorization: Token $token'" > $curl_params echo "-H 'Authorization: Token $token'" > $CURL_PARAMS
} }
# socialhome_start_sharing "g1@localhost:9000" "http://localhost:9001" # socialhome_start_sharing "g1@localhost:9000" "http://localhost:9001"
......
FROM debian:jessie FROM golang:1.12
RUN apt-get update RUN git clone \
RUN apt-get install -y \ https://git.feneas.org/feneas/federation/testsuite-testproject.git \
git-core postgresql-client nmap curl inotify-tools /go/src/feneas/federation/testsuite-testproject
WORKDIR /go/src/feneas/federation/testsuite-testproject
RUN git clone https://git.feneas.org/feneas/federation/testsuite-testproject.git
WORKDIR testsuite-testproject
ADD entrypoint.sh /entrypoint.sh ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh
......
...@@ -11,4 +11,9 @@ if [ "$PROJECT" == "testproject" ]; then ...@@ -11,4 +11,9 @@ if [ "$PROJECT" == "testproject" ]; then
} }
fi fi
./testproject.sh $DATABASE postgreshost $PORT go build -o server main.go || {
echo "Cannot build sources"
exit 1
}
./server :$PORT
export btf=$(basename $BATS_TEST_FILENAME) export PREFIX=$(basename $BATS_TEST_FILENAME)
export curl_params="/tmp/.bats-curl_params" export CURL_PARAMS="$BATS_TMPDIR/curl-params"
export test_id="/tmp/.bats-test_id" export TEST_ID="$BATS_TMPDIR/test-id$CI_JOB_ID"
export CI_REGISTRY_IMAGE="registry.git.feneas.org/feneas/federation/testsuite" export CI_REGISTRY_IMAGE="registry.git.feneas.org/feneas/federation/testsuite"
unset HTTP_STATUS_CODE unset HTTP_STATUS_CODE
...@@ -38,7 +38,7 @@ function fetch() { ...@@ -38,7 +38,7 @@ function fetch() {
unset params unset params
unset field_params unset field_params
[ -f "$curl_params" ] && params=$(cat $curl_params) [ -f "$CURL_PARAMS" ] && params=$(cat $CURL_PARAMS)
if [[ "$3" == "url" ]]; then field_params="-d '$2'" if [[ "$3" == "url" ]]; then field_params="-d '$2'"
else else
IFS='&' read -ra reqparams <<< "$2" IFS='&' read -ra reqparams <<< "$2"
...@@ -97,16 +97,22 @@ function stop_app() { ...@@ -97,16 +97,22 @@ function stop_app() {
# remove_app "g1" # remove_app "g1"
function remove_app() { function remove_app() {
# print the entire container log before
# deleting for debugging purposes
echo -e "#\n#\n# CONTAINER LOG $(container_id "$1")\n#\n#" >&3
docker logs "$(container_id "$1")" 2>&1 \
| while read line; do echo "# $line" >&3; done
# delete the container
docker rm "$(container_id "$1")" docker rm "$(container_id "$1")"
} }
# container_id "g1" # container_id "g1"
function container_id() { function container_id() {
# set a gloabl test ID for multiple project testing # set a gloabl test ID for multiple project testing
if [ ! -f "$test_id" ]; then if [ ! -f "$TEST_ID" ]; then
shuf -i 10000-90000 -n 1 > $test_id shuf -i 10000-90000 -n 1 > $TEST_ID
fi fi
echo "$(cat $test_id)-$1" echo "$(cat $TEST_ID)-$1"
} }
# container_ip "g1" # container_ip "g1"
......
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
load '../test_helper' load '../test_helper'
load '../projects/ganggo/ganggo_helper' load '../projects/ganggo/ganggo_helper'
@test "$btf create database" { @test "$PREFIX create database" {
create_database "g1" create_database "g1"
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
} }
@test "$btf start ganggo#1 server" { @test "$PREFIX start ganggo#1 server" {
ganggo_start_server g1 "9000" ganggo_start_server g1 "9000"
} }
@test "$btf start diaspora#1 server" { @test "$PREFIX start diaspora#1 server" {
start_app "d1" "3000" "diaspora"$(latest_tag "diaspora") start_app "d1" "3000" "diaspora"$(latest_tag "diaspora")
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
code=$(wait_for "docker logs $(container_id "d1")" "Starting Diaspora in production") code=$(wait_for "docker logs $(container_id "d1")" "Starting Diaspora in production")
...@@ -22,17 +22,17 @@ load '../projects/ganggo/ganggo_helper' ...@@ -22,17 +22,17 @@ load '../projects/ganggo/ganggo_helper'
sleep 15 sleep 15
} }
@test "$btf create ganggo user" { @test "$PREFIX create ganggo user" {
ganggo_create_user g1 "http://$(container_ip "g1"):9000" ganggo_create_user g1 "http://$(container_ip "g1"):9000"
} }
@test "$btf create diaspora user" { @test "$PREFIX create diaspora user" {
rails_runner d1 "User.build( rails_runner d1 "User.build(
username: 'd1', email: 'd1@d1.de', password: 'pppppp').save!" username: 'd1', email: 'd1@d1.de', password: 'pppppp').save!"
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
} }
@test "$btf setup user relations" { @test "$PREFIX setup user relations" {
rails_runner "d1" "user = User.find_by(username: 'd1') rails_runner "d1" "user = User.find_by(username: 'd1')
person = Person.find_or_fetch_by_identifier('g1@$(container_ip "g1"):9000') person = Person.find_or_fetch_by_identifier('g1@$(container_ip "g1"):9000')
aspect = Aspect.new(name: 'test', user_id: user.id) aspect = Aspect.new(name: 'test', user_id: user.id)
...@@ -101,15 +101,15 @@ function send_type() { ...@@ -101,15 +101,15 @@ function send_type() {
[ "$code" -eq "0" ] [ "$code" -eq "0" ]
} }
@test "$btf create public entities and check federation" { @test "$PREFIX create public entities and check federation" {
send_type public send_type public
} }
@test "$btf create private entities and check federation" { @test "$PREFIX create private entities and check federation" {
send_type private send_type private
} }
@test "$btf stop and delete containers" { @test "$PREFIX stop and delete containers" {
for app in g1 d1; do for app in g1 d1; do
stop_app $app stop_app $app
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
...@@ -118,7 +118,7 @@ function send_type() { ...@@ -118,7 +118,7 @@ function send_type() {
done done
} }
@test "$btf drop databases" { @test "$PREFIX drop databases" {
drop_database "g1" drop_database "g1"
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
drop_database "d1" drop_database "d1"
......
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
load '../test_helper' load '../test_helper'
load '../projects/ganggo/ganggo_helper' load '../projects/ganggo/ganggo_helper'
@test "$btf create database" { @test "$PREFIX create database" {
create_database "g1" create_database "g1"
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
} }
@test "$btf start ganggo#1 server" { @test "$PREFIX start ganggo#1 server" {
ganggo_start_server g1 "9000" ganggo_start_server g1 "9000"
} }
@test "$btf start diaspora#1 server" { @test "$PREFIX start diaspora#1 server" {
start_app "d1" "3000" "diaspora"$(latest_tag "diaspora") start_app "d1" "3000" "diaspora"$(latest_tag "diaspora")
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
code=$(wait_for "docker logs $(container_id "d1")" "Starting Diaspora in production") code=$(wait_for "docker logs $(container_id "d1")" "Starting Diaspora in production")
...@@ -25,21 +25,21 @@ load '../projects/ganggo/ganggo_helper' ...@@ -25,21 +25,21 @@ load '../projects/ganggo/ganggo_helper'
sleep 15 sleep 15
} }
@test "$btf create user" { @test "$PREFIX create user" {
ganggo_create_user g1 "http://$(container_ip "g1"):9000" ganggo_create_user g1 "http://$(container_ip "g1"):9000"
} }
@test "$btf create diaspora user" { @test "$PREFIX create diaspora user" {
rails_runner d1 "User.build( rails_runner d1 "User.build(
username: 'd1', email: 'd1@d1.de', password: 'pppppp').save!" username: 'd1', email: 'd1@d1.de', password: 'pppppp').save!"
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
} }
@test "$btf fetch user token" { @test "$PREFIX fetch user token" {
ganggo_fetch_token g1 "http://$(container_ip "g1"):9000" ganggo_fetch_token g1 "http://$(container_ip "g1"):9000"
} }
@test "$btf setup user relations" { @test "$PREFIX setup user relations" {
ganggo_start_sharing \ ganggo_start_sharing \
"d1@$(container_ip "d1"):3000" "http://$(container_ip "g1"):9000" "d1@$(container_ip "d1"):3000" "http://$(container_ip "g1"):9000"
} }
...@@ -109,15 +109,15 @@ function send_type() { ...@@ -109,15 +109,15 @@ function send_type() {
#[ "$code" -eq "0" ] #[ "$code" -eq "0" ]
} }
@test "$btf create public entities and check federation" { @test "$PREFIX create public entities and check federation" {
send_type public send_type public
} }
@test "$btf create private entities and check federation" { @test "$PREFIX create private entities and check federation" {
send_type private send_type private
} }
@test "$btf stop and delete containers" { @test "$PREFIX stop and delete containers" {
for app in g1 d1; do for app in g1 d1; do
stop_app $app stop_app $app
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
...@@ -126,7 +126,7 @@ function send_type() { ...@@ -126,7 +126,7 @@ function send_type() {
done done
} }
@test "$btf drop databases" { @test "$PREFIX drop databases" {
drop_database "g1" drop_database "g1"
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
drop_database "d1" drop_database "d1"
......
...@@ -6,34 +6,34 @@ ...@@ -6,34 +6,34 @@
load '../test_helper' load '../test_helper'
load '../projects/ganggo/ganggo_helper' load '../projects/ganggo/ganggo_helper'
@test "$btf create databases" { @test "$PREFIX create databases" {
create_database "g1" create_database "g1"
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
create_database "g2" create_database "g2"
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
} }
@test "$btf start ganggo#1 server" { @test "$PREFIX start ganggo#1 server" {
ganggo_start_server g1 "9000" ganggo_start_server g1 "9000"
} }
@test "$btf start ganggo#2 server" { @test "$PREFIX start ganggo#2 server" {
ganggo_start_server g2 "9001" ganggo_start_server g2 "9001"
} }
@test "$btf create user#1" { @test "$PREFIX create user#1" {
ganggo_create_user g1 "http://$(container_ip "g1"):9000" ganggo_create_user g1 "http://$(container_ip "g1"):9000"
} }
@test "$btf create user#2" { @test "$PREFIX create user#2" {
ganggo_create_user g2 "http://$(container_ip "g2"):9001" ganggo_create_user g2 "http://$(container_ip "g2"):9001"
} }
@test "$btf fetch user#1 token" { @test "$PREFIX fetch user#1 token" {
ganggo_fetch_token g1 "http://$(container_ip "g1"):9000" ganggo_fetch_token g1 "http://$(container_ip "g1"):9000"
} }
@test "$btf setup user relations" { @test "$PREFIX setup user relations" {
ganggo_start_sharing \ ganggo_start_sharing \
"g2@$(container_ip "g2"):9001" "http://$(container_ip "g1"):9000" "g2@$(container_ip "g2"):9001" "http://$(container_ip "g1"):9000"
} }
...@@ -104,15 +104,15 @@ function send_type() { ...@@ -104,15 +104,15 @@ function send_type() {
#[ "$code" -eq "0" ] #[ "$code" -eq "0" ]
} }
@test "$btf create public entities and check federation" { @test "$PREFIX create public entities and check federation" {
send_type public send_type public
} }
@test "$btf create private entities and check federation" { @test "$PREFIX create private entities and check federation" {
send_type private send_type private
} }
@test "$btf stop and delete containers" { @test "$PREFIX stop and delete containers" {
for app in g1 g2; do for app in g1 g2; do
stop_app $app stop_app $app
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
...@@ -121,7 +121,7 @@ function send_type() { ...@@ -121,7 +121,7 @@ function send_type() {
done done
} }
@test "$btf drop databases" { @test "$PREFIX drop databases" {
drop_database "g1" drop_database "g1"
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
drop_database "g2" drop_database "g2"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
load '../test_helper' load '../test_helper'
@test "$btf start mastodon#1 server" { @test "$PREFIX start mastodon#1 server" {
start_app "m1" "3000" "mastodon"$(latest_tag "mastodon") start_app "m1" "3000" "mastodon"$(latest_tag "mastodon")
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
code=$(wait_for_mastodon "m1") code=$(wait_for_mastodon "m1")
...@@ -10,7 +10,7 @@ load '../test_helper' ...@@ -10,7 +10,7 @@ load '../test_helper'
[ "$code" -eq "0" ] [ "$code" -eq "0" ]
} }
@test "$btf start mastodon#2 server" { @test "$PREFIX start mastodon#2 server" {
start_app "m2" "3001" "mastodon"$(latest_tag "mastodon") start_app "m2" "3001" "mastodon"$(latest_tag "mastodon")
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
code=$(wait_for_mastodon "m2") code=$(wait_for_mastodon "m2")
...@@ -19,7 +19,7 @@ load '../test_helper' ...@@ -19,7 +19,7 @@ load '../test_helper'
} }
# see https://github.com/tootsuite/documentation/blob/master/Using-the-API/Testing-with-cURL.md # see https://github.com/tootsuite/documentation/blob/master/Using-the-API/Testing-with-cURL.md
@test "$btf create oauth application" { @test "$PREFIX create oauth application" {
post post
"client_name=bats&redirect_uris=urn:ietf:wg:oauth:2.0:oob&scopes=read%20write%20follow" \ "client_name=bats&redirect_uris=urn:ietf:wg:oauth:2.0:oob&scopes=read%20write%20follow" \
"http://$(container_ip "m1"):3000/api/v1/apps" "http://$(container_ip "m1"):3000/api/v1/apps"
...@@ -37,10 +37,10 @@ load '../test_helper' ...@@ -37,10 +37,10 @@ load '../test_helper'
token=$(json_value "access_token") token=$(json_value "access_token")
echo "token = $token" echo "token = $token"
[ "$token" != "" ] [ "$token" != "" ]
echo "-H 'Authorization: Bearer $token'" > $curl_params echo "-H 'Authorization: Bearer $token'" > $CURL_PARAMS
} }
@test "$btf follow admin@m2:3001" { @test "$PREFIX follow admin@m2:3001" {
post "uri=admin@$(container_ip "m2"):3001" \ post "uri=admin@$(container_ip "m2"):3001" \
"http://$(container_ip "m1"):3000/api/v1/follows" "http://$(container_ip "m1"):3000/api/v1/follows"
post "uri=admin@$(container_ip "m2"):3001" \ post "uri=admin@$(container_ip "m2"):3001" \
...@@ -52,7 +52,7 @@ load '../test_helper' ...@@ -52,7 +52,7 @@ load '../test_helper'
[ "$username" == "admin" ] [ "$username" == "admin" ]
} }