Add basic "federation" tests and some bugfixes
This commit is contained in:
41
tests/federation_test.py
Normal file
41
tests/federation_test.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
from html2text import html2text
|
||||
|
||||
|
||||
def resp2plaintext(resp):
|
||||
"""Convert the body of a requests reponse to plain text in order to make basic assertions."""
|
||||
return html2text(resp.text)
|
||||
|
||||
|
||||
def test_federation():
|
||||
"""Ensure the homepage is accessible."""
|
||||
resp = requests.get('http://localhost:5006')
|
||||
resp.raise_for_status()
|
||||
assert resp.status_code == 200
|
||||
|
||||
resp = requests.get('http://localhost:5007')
|
||||
resp.raise_for_status()
|
||||
assert resp.status_code == 200
|
||||
|
||||
# Keep one session per instance
|
||||
|
||||
# Login
|
||||
session1 = requests.Session()
|
||||
resp = session1.post('http://localhost:5006/login', data={'pass': 'hello'})
|
||||
assert resp.status_code == 200
|
||||
|
||||
# Login
|
||||
session2 = requests.Session()
|
||||
resp = session2.post('http://localhost:5007/login', data={'pass': 'hello'})
|
||||
assert resp.status_code == 200
|
||||
|
||||
# Instance1 follows instance2
|
||||
resp = session1.get('http://localhost:5006/api/follow', params={'actor': 'http://instance2_web_1:5005'})
|
||||
assert resp.status_code == 201
|
||||
|
||||
resp = requests.get('http://localhost:5007/followers', headers={'Accept': 'application/activity+json'})
|
||||
resp.raise_for_status()
|
||||
|
||||
assert resp.json()['first']['orderedItems'] == ['http://instance1_web_1:5005']
|
6
tests/fixtures/instance1/config/me.yml
vendored
6
tests/fixtures/instance1/config/me.yml
vendored
@@ -1,7 +1,7 @@
|
||||
username: 'instance_1'
|
||||
username: 'instance1'
|
||||
name: 'Instance 1'
|
||||
icon_url: 'https://sos-ch-dk-2.exo.io/microblogpub/microblobpub.png'
|
||||
domain: 'localhost:5006'
|
||||
summary: 'instance 1 summary'
|
||||
domain: 'instance1_web_1:5005'
|
||||
summary: 'instance1 summary'
|
||||
pass: '$2b$12$nEgJMgaYbXSPOvgnqM4jSeYnleKhXqsFgv/o3hg12x79uEdsR4cUy' # hello
|
||||
https: false
|
||||
|
6
tests/fixtures/instance2/config/me.yml
vendored
6
tests/fixtures/instance2/config/me.yml
vendored
@@ -1,7 +1,7 @@
|
||||
username: 'instance_2'
|
||||
username: 'instance2'
|
||||
name: 'Instance 2'
|
||||
icon_url: 'https://sos-ch-dk-2.exo.io/microblogpub/microblobpub.png'
|
||||
domain: 'localhost:5007'
|
||||
summary: 'instance 2 summary'
|
||||
domain: 'instance2_web_1:5005'
|
||||
summary: 'instance2 summary'
|
||||
pass: '$2b$12$nEgJMgaYbXSPOvgnqM4jSeYnleKhXqsFgv/o3hg12x79uEdsR4cUy' # hello
|
||||
https: false
|
||||
|
Reference in New Issue
Block a user