Skip to content

Commit 53834d4

Browse files
committed
tests: Make federation tests do real federation
Signed-off-by: Joas Schilling <[email protected]>
1 parent 954d41c commit 53834d4

10 files changed

+310
-277
lines changed

tests/integration/features/bootstrap/FeatureContext.php

+21-15
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ private function assertInvites($invites, TableNode $formData) {
694694
$data['id'] = self::$tokenToIdentifier[$invite['token']];
695695
}
696696
if (isset($expectedInvite['inviterCloudId'])) {
697-
$data['inviterCloudId'] = $invite['inviterCloudId'];
697+
$data['inviterCloudId'] = $this->translateRemoteServer($invite['inviterCloudId']);
698698
}
699699
if (isset($expectedInvite['inviterDisplayName'])) {
700700
$data['inviterDisplayName'] = $invite['inviterDisplayName'];
@@ -717,17 +717,19 @@ private function assertInvites($invites, TableNode $formData) {
717717
}
718718

719719
protected function translateRemoteServer(string $server): string {
720-
$server = str_replace('http://', '', $server);
721-
if ($server === 'localhost:8080') {
722-
return 'LOCAL';
723-
}
724-
if ($server === 'localhost:8180') {
725-
return 'LOCAL_REMOTE';
726-
}
727-
if ($server === 'localhost:8280') {
728-
return 'REMOTE';
720+
$server = str_replace([
721+
'http://localhost:8080',
722+
'http://localhost:8180',
723+
'http://localhost:8280',
724+
], [
725+
'LOCAL',
726+
'LOCAL_REMOTE',
727+
'REMOTE',
728+
], $server);
729+
if (str_contains($server, 'http://')) {
730+
return 'unknown-server';
729731
}
730-
return 'unknown-server';
732+
return $server;
731733
}
732734

733735
/**
@@ -914,7 +916,7 @@ protected function assertAttendeeList(string $identifier, ?TableNode $formData,
914916
}
915917

916918
if (isset($attendee['actorId'], $attendee['actorType']) && $attendee['actorType'] === 'federated_users' && !str_contains($attendee['actorId'], '@')) {
917-
$attendee['actorId'] .= '@' . rtrim($this->localRemoteServerUrl, '/');
919+
$attendee['actorId'] .= '@' . rtrim($this->remoteServerUrl, '/');
918920
}
919921

920922
if (isset($attendee['actorId']) && preg_match('/TEAM_ID\(([^)]+)\)/', $attendee['actorId'], $matches)) {
@@ -1594,7 +1596,7 @@ public function userRemovesAttendeeFromRoom(string $user, string $actorType, str
15941596
$attendeeId = 123456789;
15951597
} else {
15961598
if ($actorType === 'remote') {
1597-
$actorId .= '@' . rtrim($this->localRemoteServerUrl, '/');
1599+
$actorId .= '@' . rtrim($this->remoteServerUrl, '/');
15981600
$actorType = 'federated_user';
15991601
}
16001602

@@ -1994,7 +1996,9 @@ public function userAddAttendeeToRoom(string $user, string $newType, string $new
19941996

19951997
if ($newType === 'federated_user') {
19961998
if (!str_contains($newId, '@')) {
1997-
$newId .= '@' . $this->localRemoteServerUrl;
1999+
$newId .= '@' . $this->remoteServerUrl;
2000+
} elseif (str_ends_with($newId, '@LOCAL_REMOTE')) {
2001+
$newId = str_replace('LOCAL_REMOTE', $this->localRemoteServerUrl, $newId);
19982002
} else {
19992003
$newId = str_replace('REMOTE', $this->remoteServerUrl, $newId);
20002004
}
@@ -3404,12 +3408,13 @@ public function userSeesTheFollowingSystemMessagesInRoom($user, $identifier, $st
34043408
return;
34053409
}
34063410

3407-
$expected = array_map(static function (array $message) {
3411+
$expected = array_map(function (array $message) {
34083412
if (isset($message['messageParameters'])) {
34093413
$result = preg_match('/POLL_ID\(([^)]+)\)/', $message['messageParameters'], $matches);
34103414
if ($result) {
34113415
$message['messageParameters'] = str_replace($matches[0], '"' . self::$questionToPollId[$matches[1]] . '"', $message['messageParameters']);
34123416
}
3417+
$message['messageParameters'] = str_replace('{$REMOTE_URL}', trim(json_encode(trim($this->remoteServerUrl, '/')), '"'), $message['messageParameters']);
34133418
}
34143419
return $message;
34153420
}, $formData->getHash());
@@ -3423,6 +3428,7 @@ public function userSeesTheFollowingSystemMessagesInRoom($user, $identifier, $st
34233428
'actorId' => ($message['actorType'] === 'guests') ? self::$sessionIdToUser[$message['actorId']] : (string)$message['actorId'],
34243429
'systemMessage' => (string)$message['systemMessage'],
34253430
];
3431+
$data['actorId'] = $this->translateRemoteServer($data['actorId']);
34263432

34273433
if (isset($expected['actorDisplayName'])) {
34283434
$data['actorDisplayName'] = $message['actorDisplayName'];

tests/integration/features/federation/call.feature

+48-48
Large diffs are not rendered by default.

tests/integration/features/federation/chat.feature

+119-127
Large diffs are not rendered by default.

tests/integration/features/federation/invite.feature

+19-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Feature: federation/invite
66
| federation_enabled | yes |
77
Given using server "LOCAL"
88
Given user "participant1" exists
9-
Given user "participant2" exists
9+
And the following "spreed" app config is set
10+
| federation_enabled | yes |
1011

1112
Scenario: Federation is disabled
1213
Given the following "spreed" app config is set
@@ -20,8 +21,6 @@ Feature: federation/invite
2021
| users | participant1 | 1 |
2122

2223
Scenario: Invite an invalid user
23-
Given the following "spreed" app config is set
24-
| federation_enabled | yes |
2524
Given user "participant1" creates room "room" (v4)
2625
| roomType | 3 |
2726
| roomName | room |
@@ -31,8 +30,6 @@ Feature: federation/invite
3130
| users | participant1 | 1 |
3231

3332
Scenario: Accepting an invite
34-
Given the following "spreed" app config is set
35-
| federation_enabled | yes |
3633
Given user "participant1" creates room "room" (v4)
3734
| roomType | 3 |
3835
| roomName | room |
@@ -43,24 +40,27 @@ Feature: federation/invite
4340
| federated_users | participant2 | 3 |
4441
Then user "participant1" sees the following system messages in room "room" with 200
4542
| room | actorType | actorId | systemMessage | message | messageParameters |
46-
| room | users | participant1 | federated_user_added | You invited {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"},"federated_user":{"type":"user","id":"participant2","name":"participant2-displayname","server":"http:\/\/localhost:8180","mention-id":"federated_user\/participant2@http:\/\/localhost:8180"}} |
43+
| room | users | participant1 | federated_user_added | You invited {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"},"federated_user":{"type":"user","id":"participant2","name":"participant2-displayname","server":"{$REMOTE_URL}","mention-id":"federated_user\/participant2@{$REMOTE_URL}"}} |
4744
| room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"}} |
4845
And user "participant1" adds federated_user "participant2" to room "room" with 200 (v4)
46+
Given using server "REMOTE"
4947
Then user "participant2" is participant of the following rooms (v4)
5048
| id | name | type |
5149
Then last response has federation invites header set to "1"
50+
Given using server "LOCAL"
5251
When user "participant1" sees the following attendees in room "room" with 200 (v4)
5352
| actorType | actorId | participantType |
5453
| users | participant1 | 1 |
5554
| federated_users | participant2 | 3 |
5655
Then user "participant1" sees the following system messages in room "room" with 200
5756
| room | actorType | actorId | systemMessage | message | messageParameters |
58-
| room | users | participant1 | federated_user_added | You invited {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"},"federated_user":{"type":"user","id":"participant2","name":"participant2-displayname","server":"http:\/\/localhost:8180","mention-id":"federated_user\/participant2@http:\/\/localhost:8180"}} |
57+
| room | users | participant1 | federated_user_added | You invited {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"},"federated_user":{"type":"user","id":"participant2","name":"participant2-displayname","server":"{$REMOTE_URL}","mention-id":"federated_user\/participant2@{$REMOTE_URL}"}} |
5958
| room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"}} |
6059
And force run "OCA\Talk\BackgroundJob\RemoveEmptyRooms" background jobs
60+
Given using server "REMOTE"
6161
And user "participant2" has the following invitations (v1)
62-
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
63-
| LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname |
62+
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
63+
| LOCAL | room | 0 | participant1@LOCAL | participant1-displayname |
6464
Then user "participant2" has the following notifications
6565
| app | object_type | object_id | subject | message |
6666
| spreed | remote_talk_share | INVITE_ID(LOCAL::room) | @participant1-displayname invited you to a federated conversation | @participant1-displayname invited you to join room on http://localhost:8080 |
@@ -76,29 +76,32 @@ Feature: federation/invite
7676
And user "participant2" declines invite to room "room" of server "LOCAL" with 400 (v1)
7777
| error | state |
7878
And user "participant2" has the following invitations (v1)
79-
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
80-
| LOCAL | room | 1 | participant1@http://localhost:8080 | participant1-displayname |
79+
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
80+
| LOCAL | room | 1 | participant1@LOCAL | participant1-displayname |
81+
Given using server "LOCAL"
8182
When user "participant1" sees the following attendees in room "room" with 200 (v4)
8283
| actorType | actorId | participantType |
8384
| users | participant1 | 1 |
8485
| federated_users | participant2 | 3 |
8586
Then user "participant1" sees the following system messages in room "room" with 200
8687
| room | actorType | actorId | systemMessage | message | messageParameters |
87-
| room | federated_users | participant2@http://localhost:8180 | federated_user_added | {federated_user} accepted the invitation | {"actor":{"type":"user","id":"participant2","name":"participant2-displayname","server":"http:\/\/localhost:8180","mention-id":"federated_user\/participant2@http:\/\/localhost:8180"},"federated_user":{"type":"user","id":"participant2","name":"participant2-displayname","server":"http:\/\/localhost:8180","mention-id":"federated_user\/participant2@http:\/\/localhost:8180"}} |
88-
| room | users | participant1 | federated_user_added | You invited {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"},"federated_user":{"type":"user","id":"participant2","name":"participant2-displayname","server":"http:\/\/localhost:8180","mention-id":"federated_user\/participant2@http:\/\/localhost:8180"}} |
88+
| room | federated_users | participant2@REMOTE | federated_user_added | {federated_user} accepted the invitation | {"actor":{"type":"user","id":"participant2","name":"participant2-displayname","server":"{$REMOTE_URL}","mention-id":"federated_user\/participant2@{$REMOTE_URL}"},"federated_user":{"type":"user","id":"participant2","name":"participant2-displayname","server":"{$REMOTE_URL}","mention-id":"federated_user\/participant2@{$REMOTE_URL}"}} |
89+
| room | users | participant1 | federated_user_added | You invited {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"},"federated_user":{"type":"user","id":"participant2","name":"participant2-displayname","server":"{$REMOTE_URL}","mention-id":"federated_user\/participant2@{$REMOTE_URL}"}} |
8990
| room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"}} |
9091
# Remove a remote user after they joined
9192
When user "participant1" removes remote "participant2" from room "room" with 200 (v4)
93+
Given using server "REMOTE"
9294
And user "participant2" has the following invitations (v1)
9395
Then user "participant2" is participant of the following rooms (v4)
96+
Given using server "LOCAL"
9497
When user "participant1" sees the following attendees in room "room" with 200 (v4)
9598
| actorType | actorId | participantType |
9699
| users | participant1 | 1 |
97100
Then user "participant1" sees the following system messages in room "room" with 200
98101
| room | actorType | actorId | systemMessage | message | messageParameters |
99-
| room | users | participant1 | federated_user_removed | You removed {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180","mention-id":"federated_user\/participant2@http:\/\/localhost:8180"}} |
100-
| room | federated_users | participant2@http://localhost:8180 | federated_user_added | {federated_user} accepted the invitation | {"actor":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180","mention-id":"federated_user\/participant2@http:\/\/localhost:8180"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180","mention-id":"federated_user\/participant2@http:\/\/localhost:8180"}} |
101-
| room | users | participant1 | federated_user_added | You invited {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180","mention-id":"federated_user\/participant2@http:\/\/localhost:8180"}} |
102+
| room | users | participant1 | federated_user_removed | You removed {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8280","server":"{$REMOTE_URL}","mention-id":"federated_user\/participant2@{$REMOTE_URL}"}} |
103+
| room | federated_users | participant2@REMOTE | federated_user_added | {federated_user} accepted the invitation | {"actor":{"type":"user","id":"participant2","name":"participant2@localhost:8280","server":"{$REMOTE_URL}","mention-id":"federated_user\/participant2@{$REMOTE_URL}"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8280","server":"{$REMOTE_URL}","mention-id":"federated_user\/participant2@{$REMOTE_URL}"}} |
104+
| room | users | participant1 | federated_user_added | You invited {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8280","server":"{$REMOTE_URL}","mention-id":"federated_user\/participant2@{$REMOTE_URL}"}} |
102105
| room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"}} |
103106

104107
Scenario: Invite user with wrong casing

tests/integration/features/federation/join-leave.feature

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ Feature: federation/join-leave
1414
Given user "participant1" creates room "room" (v4)
1515
| roomType | 2 |
1616
| roomName | room |
17-
And user "participant1" adds federated_user "participant2@REMOTE" to room "room" with 200 (v4)
17+
And user "participant1" adds federated_user "participant2" to room "room" with 200 (v4)
1818
And using server "REMOTE"
1919
And user "participant2" has the following invitations (v1)
20-
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
21-
| LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname |
20+
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
21+
| LOCAL | room | 0 | participant1@LOCAL | participant1-displayname |
2222
And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1)
2323
| id | name | type | remoteServer | remoteToken |
2424
| LOCAL::room | room | 2 | LOCAL | room |
@@ -43,11 +43,11 @@ Feature: federation/join-leave
4343
Given user "participant1" creates room "room" (v4)
4444
| roomType | 2 |
4545
| roomName | room |
46-
And user "participant1" adds federated_user "participant2@REMOTE" to room "room" with 200 (v4)
46+
And user "participant1" adds federated_user "participant2" to room "room" with 200 (v4)
4747
And using server "REMOTE"
4848
And user "participant2" has the following invitations (v1)
49-
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
50-
| LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname |
49+
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
50+
| LOCAL | room | 0 | participant1@LOCAL | participant1-displayname |
5151
And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1)
5252
| id | name | type | remoteServer | remoteToken |
5353
| LOCAL::room | room | 2 | LOCAL | room |
@@ -73,11 +73,11 @@ Feature: federation/join-leave
7373
Given user "participant1" creates room "room" (v4)
7474
| roomType | 2 |
7575
| roomName | room |
76-
And user "participant1" adds federated_user "participant2@REMOTE" to room "room" with 200 (v4)
76+
And user "participant1" adds federated_user "participant2" to room "room" with 200 (v4)
7777
And using server "REMOTE"
7878
And user "participant2" has the following invitations (v1)
79-
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
80-
| LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname |
79+
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
80+
| LOCAL | room | 0 | participant1@LOCAL | participant1-displayname |
8181
And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1)
8282
| id | name | type | remoteServer | remoteToken |
8383
| LOCAL::room | room | 2 | LOCAL | room |

0 commit comments

Comments
 (0)