Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/meteor/tests/end-to-end/api/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2583,7 +2583,7 @@ describe('[Chat]', () => {
otherUser = await createUser({ username });
otherUserCredentials = await login(otherUser.username, password);
parentThreadId = (await sendSimpleMessage({ roomId: testChannel._id })).body.message._id;
await addUserToRoom({ rid: testChannel._id, usernames: [otherUser.username] });
await addUserToRoom({ rid: testChannel._id, usernames: [otherUser.username], type: 'c' });
});

after(() => Promise.all([deleteUser(otherUser), deleteMessage({ msgId: parentThreadId, roomId: testChannel._id })]));
Expand Down
48 changes: 25 additions & 23 deletions ee/packages/federation-matrix/tests/end-to-end/permissions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import type { IRoomNativeFederated, IUser } from '@rocket.chat/core-typings';

import type {} from '../../../../../apps/meteor/app/api/server/v1/permissions.ts';
import { api } from '../../../../../apps/meteor/tests/data/api-data';
import {
addUserToRoomViaMethod,
createRoom,
getSubscriptionByRoomId,
getSubscriptions,
} from '../../../../../apps/meteor/tests/data/rooms.helper';
import { addUserToRoom, createRoom, getSubscriptionByRoomId, getSubscriptions } from '../../../../../apps/meteor/tests/data/rooms.helper';
import { createUser, deleteUser, getRequestConfig } from '../../../../../apps/meteor/tests/data/users.helper';
import type { IRequestConfig, TestUser } from '../../../../../apps/meteor/tests/data/users.helper';
import { IS_EE } from '../../../../../apps/meteor/tests/e2e/config/constants';
Expand Down Expand Up @@ -185,28 +180,29 @@ import { SynapseClient } from '../helper/synapse-client';
await deleteUser(user, {}, rc1AdminRequestConfig);
});
it('should not be able to add a user without access-federation permission to a room', async () => {
const addUserResponse = await addUserToRoomViaMethod({
const [addUserResponse] = await addUserToRoom({
usernames: [user.username],
rid: createResponse.body.group._id,
config: rc1AdminRequestConfig,
type: 'p',
});

expect(addUserResponse.status).toBe(400);
expect(addUserResponse.body).toHaveProperty('success', false);
expect(addUserResponse.body.message).toMatch(/error-not-authorized-federation/);
expect(addUserResponse.body).toHaveProperty('errorType', 'error-not-authorized-federation');
});

it("should be able to add a remote user to a room regardless of the user's access-federation permission defined locally", async () => {
addUserResponse = await addUserToRoomViaMethod({
[addUserResponse] = await addUserToRoom({
usernames: [federationConfig.hs1.adminMatrixUserId],
rid: createResponse.body.group._id,
config: rc1AdminRequestConfig,
type: 'p',
});

expect(addUserResponse.status).toBe(200);
expect(addUserResponse.body).toHaveProperty('success', true);
expect(addUserResponse.body).toHaveProperty('message');
expect(addUserResponse.body.message).toMatch('{"msg":"result","id":"id","result":true}');
expect(addUserResponse.body).toHaveProperty('group');
});
});
});
Expand Down Expand Up @@ -270,15 +266,16 @@ import { SynapseClient } from '../helper/synapse-client';
config: rc1AdminRequestConfig,
}).expect(200);

const addUserResponse = await addUserToRoomViaMethod({
const [addUserResponse] = await addUserToRoom({
usernames: [user.username],
rid: createResponse.body.group._id,
config: rc1AdminRequestConfig,
}).expect(200);
type: 'p',
});

expect(addUserResponse.status).toBe(200);
expect(addUserResponse.body).toHaveProperty('success', true);
expect(addUserResponse.body).toHaveProperty('message');
expect(addUserResponse.body.message).toMatch('{"msg":"result","id":"id","result":true}');
expect(addUserResponse.body).toHaveProperty('group');
});
});
});
Expand Down Expand Up @@ -425,10 +422,11 @@ import { SynapseClient } from '../helper/synapse-client';

expect(createResponse.status).toBe(200);

const addUserResponse = await addUserToRoomViaMethod({
const [addUserResponse] = await addUserToRoom({
usernames: [rcValidUser2.username],
rid: createResponse.body.group._id,
config: rcValidUser1.config,
type: 'p',
});

expect(addUserResponse.status).toBe(200);
Expand Down Expand Up @@ -520,15 +518,16 @@ import { SynapseClient } from '../helper/synapse-client';

expect(createResponse.status).toBe(200);

const addUserResponse = await addUserToRoomViaMethod({
const [addUserResponse] = await addUserToRoom({
usernames: [userWithNonMatchingEmail.username],
rid: createResponse.body.group._id,
config: rcValidUser1.config,
type: 'p',
});

expect(addUserResponse.status).toBe(400);
expect(addUserResponse.body).toHaveProperty('success', false);
expect(addUserResponse.body.message).toMatch(/error-not-authorized-federation/);
expect(addUserResponse.body).toHaveProperty('errorType', 'error-not-authorized-federation');
});

it('should NOT be able to be added to a federated room during creation', async () => {
Expand Down Expand Up @@ -602,15 +601,16 @@ import { SynapseClient } from '../helper/synapse-client';

expect(createResponse.status).toBe(200);

const addUserResponse = await addUserToRoomViaMethod({
const [addUserResponse] = await addUserToRoom({
usernames: [userWithUnverifiedEmail.username],
rid: createResponse.body.group._id,
config: rcValidUser1.config,
type: 'p',
});

expect(addUserResponse.status).toBe(400);
expect(addUserResponse.body).toHaveProperty('success', false);
expect(addUserResponse.body.message).toMatch(/error-not-authorized-federation/);
expect(addUserResponse.body).toHaveProperty('errorType', 'error-not-authorized-federation');
});
});

Expand Down Expand Up @@ -666,15 +666,16 @@ import { SynapseClient } from '../helper/synapse-client';

expect(createResponse.status).toBe(200);

const addUserResponse = await addUserToRoomViaMethod({
const [addUserResponse] = await addUserToRoom({
usernames: [userWithoutEmail.username],
rid: createResponse.body.group._id,
config: rcValidUser1.config,
type: 'p',
});

expect(addUserResponse.status).toBe(400);
expect(addUserResponse.body).toHaveProperty('success', false);
expect(addUserResponse.body.message).toMatch(/error-not-authorized-federation/);
expect(addUserResponse.body).toHaveProperty('errorType', 'error-not-authorized-federation');
});
});

Expand Down Expand Up @@ -875,10 +876,11 @@ import { SynapseClient } from '../helper/synapse-client';

expect(createResponse.status).toBe(200);

const addUserResponse = await addUserToRoomViaMethod({
const [addUserResponse] = await addUserToRoom({
usernames: [userWithNonMatchingEmail.username],
rid: createResponse.body.group._id,
config: rc1AdminRequestConfig,
type: 'p',
});

expect(addUserResponse.status).toBe(200);
Expand Down
4 changes: 4 additions & 0 deletions ee/packages/federation-matrix/tests/end-to-end/room.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ import { SynapseClient } from '../helper/synapse-client';
rid: nonFederatedChannel._id,
type: 'p',
config: rc1AdminRequestConfig,
type: 'p',
});

// The REST endpoint rejects the invite with the federation-specific error: the federated
Expand Down Expand Up @@ -852,6 +853,7 @@ import { SynapseClient } from '../helper/synapse-client';
rid: federatedChannel._id,
type: 'p',
config: rc1AdminRequestConfig,
type: 'p',
});

expect(addUserResponse.body).toHaveProperty('success', true);
Expand Down Expand Up @@ -956,6 +958,7 @@ import { SynapseClient } from '../helper/synapse-client';
rid: federatedChannel._id,
type: 'p',
config: rc1AdminRequestConfig,
type: 'p',
});

addUserResponse.forEach((response) => expect(response.body).toHaveProperty('success', true));
Expand Down Expand Up @@ -1093,6 +1096,7 @@ import { SynapseClient } from '../helper/synapse-client';
rid: federatedChannel._id,
type: 'p',
config: rc1AdminRequestConfig,
type: 'p',
});

addUserResponse.forEach((response) => expect(response.body).toHaveProperty('success', true));
Expand Down
Loading