test: add basic federation test (#37190)

This commit is contained in:
Diego Sampaio 2025-10-09 20:14:52 -03:00 committed by GitHub
parent 6497440471
commit 76fde8d460
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 39 deletions

View File

@ -3,56 +3,36 @@ import { after, before, describe, it } from 'mocha';
import { getCredentials, request } from '../../data/api-data';
import { updateSetting } from '../../data/permissions.helper';
import { IS_EE } from '../../e2e/config/constants';
describe.skip('federation', () => {
(IS_EE ? describe : describe.skip)('federation', () => {
before((done) => getCredentials(done));
// FIXME: why debouncing is causing timeouts here on the hooks?
// Since we don't care about the watchers on this setting, not debouncing is fine.
describe('well-known', () => {
describe('when matrix disabled', () => {
before(async () => {
await updateSetting('Federation_Matrix_enabled', false, false);
await updateSetting('Federation_Matrix_serve_well_known', true, false);
await updateSetting('Federation_Service_Enabled', false, false);
await updateSetting('Federation_Service_Domain', 'localhost', false);
});
after(async () => {
await updateSetting('Federation_Matrix_serve_well_known', false, false);
await updateSetting('Federation_Service_Enabled', false, false);
});
it('should return 404 not found', async () => {
await request.get('/.well-known/matrix/server').expect(404);
await request.get('/.well-known/matrix/client').expect(404);
});
});
describe('when matrix enabled but well-known disabled', () => {
before(async () => {
await updateSetting('Federation_Matrix_enabled', true, false);
await updateSetting('Federation_Matrix_serve_well_known', false, false);
});
after(async () => {
await updateSetting('Federation_Matrix_enabled', false, false);
});
it('should return 404 not found', async () => {
await request.get('/.well-known/matrix/server').expect(404);
await request.get('/.well-known/matrix/client').expect(404);
await request.get('/.well-known/matrix/server').expect(403);
});
});
describe('when enabled', () => {
before(async () => {
await updateSetting('Federation_Matrix_enabled', true, false);
await updateSetting('Federation_Matrix_serve_well_known', true, false);
await updateSetting('Federation_Service_Enabled', true);
await updateSetting('Federation_Service_Domain', 'rc.host');
});
after(async () => {
await updateSetting('Federation_Matrix_enabled', false, false);
await updateSetting('Federation_Matrix_serve_well_known', false, false);
await updateSetting('Federation_Service_Enabled', false);
await updateSetting('Federation_Service_Domain', '');
});
it('should return matrix information', async () => {
@ -61,15 +41,7 @@ describe.skip('federation', () => {
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('m.server', 'localhost:8008');
});
await request
.get('/.well-known/matrix/client')
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body['m.homeserver']).to.have.property('base_url', 'http://localhost');
expect(res.body).to.have.property('m.server', 'rc.host:443');
});
});
});

View File

@ -24,6 +24,8 @@ services:
- 'COVERAGE_REPORTER=${COVERAGE_REPORTER}'
- DISABLE_DB_WATCHERS=${DISABLE_DB_WATCHERS}
- OVERWRITE_SETTING_Log_Level=${DEBUG_LOG_LEVEL:-0}
- Federation_Service_Enabled=true
- 'Federation_Service_Domain=rc.host'
extra_hosts:
- 'host.docker.internal:host-gateway'
depends_on: