Merge pull request 'federation: add star scenario' (#196) from earl-warren/end-to-end:wip-federation into main

Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/196
This commit is contained in:
earl-warren 2024-06-07 16:26:04 +00:00
commit 9cfd043b8a
2 changed files with 46 additions and 4 deletions

View file

@ -50,10 +50,10 @@ cd end-to-end
```sh
make TAGS='bindata sqlite sqlite_unlock_notify' generate forgejo
cp -a forgejo /srv/forgejo-binaries/forgejo-7.0-dev
cp -a forgejo /srv/forgejo-binaries/forgejo-8.0-dev
```
It will be used whenever the version `7.0-dev` is specified in a test.
It will be used whenever the version `8.0-dev` is specified in a test.
## Running actions locally

View file

@ -1,2 +1,44 @@
test forgejo = $($ONE_CURL api_json $ONE_HOST_PORT/api/v1/nodeinfo | jq -r .software.name)
test forgejo = $($TWO_CURL api_json $TWO_HOST_PORT/api/v1/nodeinfo | jq -r .software.name)
TMPDIR=$(mktemp -d)
trap "rm -fr $TMPDIR" EXIT
function star_count() {
local curl=$1
local host_port=$2
local count=$3
$curl api_json http://$host_port/api/v1/repos/root/test > $TMPDIR/count.json
if test $count != $(jq -r .stars_count < $TMPDIR/count.json) ; then
jq . < $TMPDIR/count.json
return 1
fi
}
#
# create a repo on each instance
#
$ONE_CURL api_json --data '{"name":"test","auto_init":true}' $ONE_HOST_PORT/api/v1/user/repos > $TMPDIR/one-repo.json
one_repo_id=$(jq -r .id < $TMPDIR/one-repo.json)
$TWO_CURL api_json --data '{"name":"test","auto_init":true}' $TWO_HOST_PORT/api/v1/user/repos > $TMPDIR/two-repo.json
two_repo_id=$(jq -r .id < $TMPDIR/two-repo.json)
#
# the repo in instance two is federated with the repo in instance one
#
$ONE_CURL web --form action=federation --form following_repos=http://$TWO_HOST_PORT/api/v1/activitypub/repository-id/$two_repo_id http://$ONE_HOST_PORT/root/test/settings
#
# check that both repo have 0 star
#
star_count $ONE_CURL $ONE_HOST_PORT 0
star_count $TWO_CURL $TWO_HOST_PORT 0
#
# star the repo on instance one and expect the star to show on instance two
#
$ONE_CURL api_json -X PUT $ONE_HOST_PORT/api/v1/user/starred/root/test
#
# check that both repo have 1 star
#
star_count $ONE_CURL $ONE_HOST_PORT 1
star_count $TWO_CURL $TWO_HOST_PORT 1