Unverified Commit c50e911b authored by zauberstuhl's avatar zauberstuhl Committed by GitHub

Merge pull request #8 from thefederationinfo/add_mastodon

Add first basic mastodon federation tests
parents 5c196924 481e9884
......@@ -6,9 +6,11 @@ language: go
services:
- postgresql
- docker
- redis
matrix:
include:
- env: PROJECT=diaspora
- env: PROJECT=ganggo
- env: PROJECT=mastodon
install: bash scripts/install.sh
script: bats --tap $(find . -name $PROJECT'*.bats')
#!/usr/bin/env bats
load test_helper
endpoint="http://localhost:3000"
@test "$btf start mastodon#1 server" {
start_app "m1" "3000" "testing_mastodon:"$(latest_tag "mastodon")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs m1" "webpack: Compiled successfully.")
echo "expected 0, got $code"
[ "$code" -eq "0" ]
}
@test "$btf start mastodon#2 server" {
start_app "m2" "3001" "testing_mastodon:"$(latest_tag "mastodon")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs m2" "Use Ctrl-C to stop")
echo "expected 0, got $code"
[ "$code" -eq "0" ]
}
# see https://github.com/tootsuite/documentation/blob/master/Using-the-API/Testing-with-cURL.md
@test "$btf create oauth application" {
post "client_name=bats&redirect_uris=urn:ietf:wg:oauth:2.0:oob&scopes=read%20write%20follow" "$endpoint/api/v1/apps"
[ "$HTTP_STATUS_CODE" == "200" ]
client_id=$(json_value "client_id")
[ "$client_id" != "" ]
client_secret=$(json_value "client_secret")
[ "$client_secret" != "" ]
post "client_id=$client_id&client_secret=$client_secret&grant_type=password&username=admin@localhost:3000&password=mastodonadmin&scope=read%20write%20follow" "$endpoint/oauth/token"
[ "$HTTP_STATUS_CODE" == "200" ]
token=$(json_value "access_token")
echo "token = $token"
[ "$token" != "" ]
echo "-H 'Authorization: Bearer $token'" > $curl_params
}
@test "$btf follow admin@localhost:3001" {
post "uri=admin@localhost:3001" "$endpoint/api/v1/follows"
echo "HTTP_STATUS_CODE = $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
username=$(json_value "username")
[ "$username" != "" ]
[ "$username" == "admin" ]
}
@test "$btf search for admin@localhost:3001" {
get "$endpoint/api/v1/search?q=admin@localhost:3001"
echo "HTTP_STATUS_CODE = $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
echo "HTTP_BODY = $HTTP_BODY"
acct=$(echo $HTTP_BODY |jq -r '.accounts[] | select(.username == "admin") | .acct')
[ "$acct" != "" ]
[ "$acct" == "admin@localhost:3001" ]
}
@test "$btf clean-up containers, databases and temp files" {
stop_app "m1 m2"
[ "$?" -eq 0 ]
remove_app "m1 m2"
[ "$?" -eq 0 ]
psql -U postgres -c "drop database m1;"
[ "$?" -eq 0 ]
rm -v $curl_params
[ "$?" -eq 0 ]
}
DEFAULT_LOCALE=en
LOCAL_HTTPS=false
RAILS_ENV=development
DISABLE_DATABASE_ENVIRONMENT_CHECK=1
SAFETY_ASSURED=1
REDIS_HOST=localhost
REDIS_PORT=6379
DB_HOST=localhost
DB_USER=postgres
DB_NAME=DATABASE_NAME
DB_PASS=
DB_PORT=5432
SECRET_KEY_BASE=56a260789480614a3ffda6b0e085dd078bbfac3b76e89def754b402edfbdea1cc361ec378ac89b68705b3565b6553d7f4a1df1354b18b43f6ad38feae42ad076
OTP_SECRET=2d5bb282b3667c6706b6ecceaf50445472c289492ec33043f4ed0b1310944c4c2c290eeb8008b41dccd9f8e052befd2c4644556be671b4863b338c85ea47aa0b
FROM ruby:2.5.0-alpine3.7
ARG UID=991
ARG GID=991
ENV RAILS_SERVE_STATIC_FILES=true \
RAILS_ENV=development NODE_ENV=development \
LOCAL_HTTPS=false
ARG YARN_VERSION=1.3.2
ARG YARN_DOWNLOAD_SHA256=6cfe82e530ef0837212f13e45c1565ba53f5199eec2527b85ecbcd88bf26821d
ARG LIBICONV_VERSION=1.15
ARG LIBICONV_DOWNLOAD_SHA256=ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178
EXPOSE 3000 4000
WORKDIR /mastodon
RUN apk -U upgrade \
&& apk add -t build-dependencies \
build-base \
icu-dev \
libidn-dev \
libressl \
libtool \
postgresql-dev \
protobuf-dev \
python \
&& apk add \
ca-certificates \
ffmpeg \
file \
git \
icu-libs \
imagemagick \
libidn \
libpq \
nodejs \
nodejs-npm \
protobuf \
su-exec \
tini \
tzdata \
&& update-ca-certificates \
&& mkdir -p /tmp/src /opt \
&& wget -O yarn.tar.gz "https://github.com/yarnpkg/yarn/releases/download/v$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& echo "$YARN_DOWNLOAD_SHA256 *yarn.tar.gz" | sha256sum -c - \
&& tar -xzf yarn.tar.gz -C /tmp/src \
&& rm yarn.tar.gz \
&& mv /tmp/src/yarn-v$YARN_VERSION /opt/yarn \
&& ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
&& wget -O libiconv.tar.gz "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-$LIBICONV_VERSION.tar.gz" \
&& echo "$LIBICONV_DOWNLOAD_SHA256 *libiconv.tar.gz" | sha256sum -c - \
&& tar -xzf libiconv.tar.gz -C /tmp/src \
&& rm libiconv.tar.gz \
&& cd /tmp/src/libiconv-$LIBICONV_VERSION \
&& ./configure --prefix=/usr/local \
&& make -j$(getconf _NPROCESSORS_ONLN)\
&& make install \
&& libtool --finish /usr/local/lib \
&& cd /mastodon \
&& rm -rf /tmp/* /var/cache/apk/*
RUN addgroup -g ${GID} mastodon && adduser -h /mastodon -s /bin/sh -D -G mastodon -u ${UID} mastodon
RUN git clone https://github.com/tootsuite/mastodon.git /mastodon
RUN chown -R mastodon:mastodon /mastodon
USER mastodon
RUN bundle config build.nokogiri --with-iconv-lib=/usr/local/lib --with-iconv-include=/usr/local/include
RUN bundle install
RUN yarn install --pure-lockfile
COPY .env /mastodon/.env
COPY start.sh /start.sh
CMD ["/bin/bash", "/start.sh"]
#!/bin/bash
WEBPACK_PORT=$(($PORT+100))
# XXX workaround for ruby goldfinger gem
# adds the ability to search profiles via http
# (see https://github.com/tootsuite/goldfinger/pull/2)
sed -i 's/https/http/' \
/usr/local/bundle/gems/goldfinger-*/lib/goldfinger/client.rb
sed -i "s/DATABASE_NAME/$DATABASE/" /mastodon/.env
sed -i "s/port: 3035/port: $WEBPACK_PORT/" config/webpacker.yml
./bin/webpack-dev-server --port $WEBPACK_PORT &
bundle exec rails db:setup
bundle exec rails server -p $PORT
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