Skip to content

Commit

Permalink
test: Remove LOCAL_REMOTE logic
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Feb 19, 2025
1 parent d023fd9 commit 55dd9d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 75 deletions.
53 changes: 2 additions & 51 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
private array $cookieJars;

protected string $localServerUrl;

protected string $localRemoteServerUrl;

protected string $remoteServerUrl;

protected string $baseUrl;

protected string $currentServer;
Expand Down Expand Up @@ -184,7 +180,6 @@ public function getAttendeeId(string $type, string $id, string $room, ?string $u
public function __construct() {
$this->cookieJars = [];
$this->localServerUrl = getenv('TEST_SERVER_URL');
$this->localRemoteServerUrl = getenv('TEST_LOCAL_REMOTE_URL');
$this->remoteServerUrl = getenv('TEST_REMOTE_URL');

foreach (['LOCAL', 'REMOTE'] as $server) {
Expand Down Expand Up @@ -563,7 +558,6 @@ private function assertRooms(array $rooms, TableNode $formData, bool $shouldOrde
if (isset($expectedRoom['lastMessageActorId'])) {
$data['lastMessageActorId'] = $room['lastMessage'] ? $room['lastMessage']['actorId'] : '';
$data['lastMessageActorId'] = str_replace(rtrim($this->localServerUrl, '/'), '{$LOCAL_URL}', $data['lastMessageActorId']);
$data['lastMessageActorId'] = str_replace(rtrim($this->localRemoteServerUrl, '/'), '{$LOCAL_REMOTE_URL}', $data['lastMessageActorId']);
$data['lastMessageActorId'] = str_replace(rtrim($this->remoteServerUrl, '/'), '{$REMOTE_URL}', $data['lastMessageActorId']);
}
if (isset($expectedRoom['lastReadMessage'])) {
Expand Down Expand Up @@ -650,13 +644,7 @@ public function userAcceptsDeclinesRemoteInvite(string $user, string $acceptsDec
$verb = $acceptsDeclines === 'accepts' ? 'POST' : 'DELETE';

$this->setCurrentUser($user);
if ($this->currentServer === 'LOCAL' && $server === 'LOCAL') {
$this->baseUrl = $this->localRemoteServerUrl;
$this->sendRequest($verb, '/apps/spreed/api/' . $apiVersion . '/federation/invitation/' . $inviteId);
$this->baseUrl = $this->localServerUrl;
} else {
$this->sendRequest($verb, '/apps/spreed/api/' . $apiVersion . '/federation/invitation/' . $inviteId);
}
$this->sendRequest($verb, '/apps/spreed/api/' . $apiVersion . '/federation/invitation/' . $inviteId);
$this->assertStatusCode($this->response, $status);
$response = $this->getDataFromResponse($this->response);

Expand Down Expand Up @@ -719,11 +707,9 @@ private function assertInvites($invites, TableNode $formData) {
protected function translateRemoteServer(string $server): string {
$server = str_replace([
'http://localhost:8080',
'http://localhost:8180',
'http://localhost:8280',
], [
'LOCAL',
'LOCAL_REMOTE',
'REMOTE',
], $server);
if (str_contains($server, 'http://')) {
Expand Down Expand Up @@ -905,9 +891,6 @@ protected function assertAttendeeList(string $identifier, ?TableNode $formData,
if (isset($attendee['actorId']) && str_ends_with($attendee['actorId'], '@{$LOCAL_URL}')) {
$attendee['actorId'] = str_replace('{$LOCAL_URL}', rtrim($this->localServerUrl, '/'), $attendee['actorId']);
}
if (isset($attendee['actorId']) && str_ends_with($attendee['actorId'], '@{$LOCAL_REMOTE_URL}')) {
$attendee['actorId'] = str_replace('{$LOCAL_REMOTE_URL}', rtrim($this->localRemoteServerUrl, '/'), $attendee['actorId']);
}
if (isset($attendee['actorId']) && str_ends_with($attendee['actorId'], '@{$REMOTE_URL}')) {
$attendee['actorId'] = str_replace('{$REMOTE_URL}', rtrim($this->remoteServerUrl, '/'), $attendee['actorId']);
}
Expand All @@ -926,9 +909,6 @@ protected function assertAttendeeList(string $identifier, ?TableNode $formData,
if (isset($attendee['sessionIds']) && str_contains($attendee['sessionIds'], '@{$LOCAL_URL}')) {
$attendee['sessionIds'] = str_replace('{$LOCAL_URL}', rtrim($this->localServerUrl, '/'), $attendee['sessionIds']);
}
if (isset($attendee['sessionIds']) && str_contains($attendee['sessionIds'], '@{$LOCAL_REMOTE_URL}')) {
$attendee['sessionIds'] = str_replace('{$LOCAL_REMOTE_URL}', rtrim($this->localRemoteServerUrl, '/'), $attendee['sessionIds']);
}
if (isset($attendee['sessionIds']) && str_contains($attendee['sessionIds'], '@{$REMOTE_URL}')) {
$attendee['sessionIds'] = str_replace('{$REMOTE_URL}', rtrim($this->remoteServerUrl, '/'), $attendee['sessionIds']);
}
Expand Down Expand Up @@ -1997,8 +1977,6 @@ public function userAddAttendeeToRoom(string $user, string $newType, string $new
if ($newType === 'federated_user') {
if (!str_contains($newId, '@')) {
$newId .= '@' . $this->remoteServerUrl;
} elseif (str_ends_with($newId, '@LOCAL_REMOTE')) {
$newId = str_replace('LOCAL_REMOTE', $this->localRemoteServerUrl, $newId);
} else {
$newId = str_replace('REMOTE', $this->remoteServerUrl, $newId);
}
Expand Down Expand Up @@ -2067,11 +2045,8 @@ public function userSetsPermissionsForInRoomTo(string $user, string $participant
} elseif (strpos($participant, 'guest') === 0) {
$sessionId = self::$userToSessionId[$participant];
$attendeeId = $this->getAttendeeId('guests', sha1($sessionId), $identifier, $statusCode === 200 ? $user : null);
} elseif (str_ends_with($participant, '@{$LOCAL_REMOTE_URL}') ||
str_ends_with($participant, '@{$REMOTE_URL}')) {
$participant = str_replace('{$LOCAL_REMOTE_URL}', rtrim($this->localRemoteServerUrl, '/'), $participant);
} elseif (str_ends_with($participant, '@{$REMOTE_URL}')) {
$participant = str_replace('{$REMOTE_URL}', rtrim($this->remoteServerUrl, '/'), $participant);

$attendeeId = $this->getAttendeeId('federated_users', $participant, $identifier, $statusCode === 200 ? $user : null);
} else {
$attendeeId = $this->getAttendeeId('users', $participant, $identifier, $statusCode === 200 ? $user : null);
Expand Down Expand Up @@ -2325,7 +2300,6 @@ public function userSendsMessageToRoom(string $user, string $sendingMode, string
$message = substr($message, 1, -1);
$message = str_replace('\n', "\n", $message);
$message = str_replace('{$LOCAL_URL}', $this->localServerUrl, $message);
$message = str_replace('{$LOCAL_REMOTE_URL}', $this->localRemoteServerUrl, $message);
$message = str_replace('{$REMOTE_URL}', $this->remoteServerUrl, $message);
if (str_contains($message, '@"TEAM_ID(')) {
$result = preg_match('/TEAM_ID\(([^)]+)\)/', $message, $matches);
Expand Down Expand Up @@ -2743,9 +2717,6 @@ protected function preparePollExpectedData(array $expected): array {
if (str_ends_with($expected['actorId'], '@{$LOCAL_URL}')) {
$expected['actorId'] = str_replace('{$LOCAL_URL}', rtrim($this->localServerUrl, '/'), $expected['actorId']);
}
if (str_ends_with($expected['actorId'], '@{$LOCAL_REMOTE_URL}')) {
$expected['actorId'] = str_replace('{$LOCAL_REMOTE_URL}', rtrim($this->localRemoteServerUrl, '/'), $expected['actorId']);
}
if (str_ends_with($expected['actorId'], '@{$REMOTE_URL}')) {
$expected['actorId'] = str_replace('{$REMOTE_URL}', rtrim($this->remoteServerUrl, '/'), $expected['actorId']);
}
Expand All @@ -2754,9 +2725,6 @@ protected function preparePollExpectedData(array $expected): array {
if (str_contains($expected['details'], '@{$LOCAL_URL}')) {
$expected['details'] = str_replace('{$LOCAL_URL}', rtrim($this->localServerUrl, '/'), $expected['details']);
}
if (str_contains($expected['details'], '@{$LOCAL_REMOTE_URL}')) {
$expected['details'] = str_replace('{$LOCAL_REMOTE_URL}', rtrim($this->localRemoteServerUrl, '/'), $expected['details']);
}
if (str_contains($expected['details'], '@{$REMOTE_URL}')) {
$expected['details'] = str_replace('{$REMOTE_URL}', rtrim($this->remoteServerUrl, '/'), $expected['details']);
}
Expand Down Expand Up @@ -3211,19 +3179,13 @@ protected function compareDataResponse(?TableNode $formData = null) {
if (str_ends_with($expected[$i]['actorId'], '@{$LOCAL_URL}')) {
$expected[$i]['actorId'] = str_replace('{$LOCAL_URL}', rtrim($this->localServerUrl, '/'), $expected[$i]['actorId']);
}
if (str_ends_with($expected[$i]['actorId'], '@{$LOCAL_REMOTE_URL}')) {
$expected[$i]['actorId'] = str_replace('{$LOCAL_REMOTE_URL}', rtrim($this->localRemoteServerUrl, '/'), $expected[$i]['actorId']);
}
if (str_ends_with($expected[$i]['actorId'], '@{$REMOTE_URL}')) {
$expected[$i]['actorId'] = str_replace('{$REMOTE_URL}', rtrim($this->remoteServerUrl, '/'), $expected[$i]['actorId']);
}

if (str_contains($expected[$i]['messageParameters'], '{$LOCAL_URL}')) {
$expected[$i]['messageParameters'] = str_replace('{$LOCAL_URL}', str_replace('/', '\/', rtrim($this->localServerUrl, '/')), $expected[$i]['messageParameters']);
}
if (str_contains($expected[$i]['messageParameters'], '{$LOCAL_REMOTE_URL}')) {
$expected[$i]['messageParameters'] = str_replace('{$LOCAL_REMOTE_URL}', str_replace('/', '\/', rtrim($this->localRemoteServerUrl, '/')), $expected[$i]['messageParameters']);
}
if (str_contains($expected[$i]['messageParameters'], '{$REMOTE_URL}')) {
$expected[$i]['messageParameters'] = str_replace('{$REMOTE_URL}', str_replace('/', '\/', rtrim($this->remoteServerUrl, '/')), $expected[$i]['messageParameters']);
}
Expand All @@ -3232,9 +3194,6 @@ protected function compareDataResponse(?TableNode $formData = null) {
if (str_ends_with($expected[$i]['lastEditActorId'], '@{$LOCAL_URL}')) {
$expected[$i]['lastEditActorId'] = str_replace('{$LOCAL_URL}', rtrim($this->localServerUrl, '/'), $expected[$i]['lastEditActorId']);
}
if (str_ends_with($expected[$i]['lastEditActorId'], '@{$LOCAL_REMOTE_URL}')) {
$expected[$i]['lastEditActorId'] = str_replace('{$LOCAL_REMOTE_URL}', rtrim($this->localRemoteServerUrl, '/'), $expected[$i]['lastEditActorId']);
}
if (str_ends_with($expected[$i]['lastEditActorId'], '@{$REMOTE_URL}')) {
$expected[$i]['lastEditActorId'] = str_replace('{$REMOTE_URL}', rtrim($this->remoteServerUrl, '/'), $expected[$i]['lastEditActorId']);
}
Expand Down Expand Up @@ -3510,18 +3469,12 @@ public function userGetsTheFollowingCandidateMentionsInRoomFor($user, $identifie
if (str_ends_with($row['id'], '@{$LOCAL_URL}')) {
$row['id'] = str_replace('{$LOCAL_URL}', rtrim($this->localServerUrl, '/'), $row['id']);
}
if (str_ends_with($row['id'], '@{$LOCAL_REMOTE_URL}')) {
$row['id'] = str_replace('{$LOCAL_REMOTE_URL}', rtrim($this->localRemoteServerUrl, '/'), $row['id']);
}
if (str_ends_with($row['id'], '@{$REMOTE_URL}')) {
$row['id'] = str_replace('{$REMOTE_URL}', rtrim($this->remoteServerUrl, '/'), $row['id']);
}
if (str_ends_with($row['mentionId'], '@{$BASE_URL}')) {
$row['mentionId'] = str_replace('{$BASE_URL}', rtrim($this->localServerUrl, '/'), $row['mentionId']);
}
if (str_ends_with($row['mentionId'], '@{$LOCAL_REMOTE_URL}')) {
$row['mentionId'] = str_replace('{$LOCAL_REMOTE_URL}', rtrim($this->localRemoteServerUrl, '/'), $row['mentionId']);
}
if (str_ends_with($row['mentionId'], '@{$REMOTE_URL}')) {
$row['mentionId'] = str_replace('{$REMOTE_URL}', rtrim($this->remoteServerUrl, '/'), $row['mentionId']);
}
Expand Down Expand Up @@ -4006,7 +3959,6 @@ private function assertNotifications($notifications, TableNode $formData) {
$messageText = self::$messageIdToText[$message] ?? 'UNKNOWN_MESSAGE';

$messageText = str_replace($this->localServerUrl, '{$LOCAL_URL}', $messageText);
$messageText = str_replace($this->localRemoteServerUrl, '{$LOCAL_REMOTE_URL}', $messageText);
$messageText = str_replace($this->remoteServerUrl, '{$REMOTE_URL}', $messageText);

$data['object_id'] = self::$tokenToIdentifier[$roomToken] . '/' . $messageText;
Expand Down Expand Up @@ -4583,7 +4535,6 @@ private function assertReactionList(?TableNode $formData): void {
$reaction['actorId'] = ($reaction['actorType'] === 'guests') ? self::$sessionIdToUser[$reaction['actorId']] : (string)$reaction['actorId'];
if ($reaction['actorType'] === 'federated_users') {
$reaction['actorId'] = str_replace(rtrim($this->localServerUrl, '/'), '{$LOCAL_URL}', $reaction['actorId']);
$reaction['actorId'] = str_replace(rtrim($this->localRemoteServerUrl, '/'), '{$LOCAL_REMOTE_URL}', $reaction['actorId']);
$reaction['actorId'] = str_replace(rtrim($this->remoteServerUrl, '/'), '{$REMOTE_URL}', $reaction['actorId']);
}
return $reaction;
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/features/federation/call.feature
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ Feature: federation/call
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
| LOCAL | room | 0 | participant1@LOCAL | participant1-displayname |
And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1)
| id | name | type | remoteServer | remoteToken |
| LOCAL::room | room | 2 | LOCAL | room |
| id | name | type | remoteServer | remoteToken |
| LOCAL::room | room | 2 | LOCAL | room |
And using server "LOCAL"
And user "participant1" joins room "room" with 200 (v4)
And user "participant1" joins call "room" with 400 (v4)
Expand All @@ -381,8 +381,8 @@ Feature: federation/call
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
| LOCAL | room | 0 | participant1@LOCAL | participant1-displayname |
And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1)
| id | name | type | remoteServer | remoteToken |
| LOCAL::room | room | 2 | LOCAL | room |
| id | name | type | remoteServer | remoteToken |
| LOCAL::room | room | 2 | LOCAL | room |
And using server "LOCAL"
And user "participant1" joins room "room" with 200 (v4)
And user "participant1" joins call "room" with 200 (v4)
Expand All @@ -404,8 +404,8 @@ Feature: federation/call
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
| LOCAL | room | 0 | participant1@LOCAL | participant1-displayname |
And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1)
| id | name | type | remoteServer | remoteToken |
| LOCAL::room | room | 2 | LOCAL | room |
| id | name | type | remoteServer | remoteToken |
| LOCAL::room | room | 2 | LOCAL | room |
And using server "LOCAL"
And user "participant1" joins room "room" with 200 (v4)
And user "participant1" joins call "room" with 200 (v4)
Expand All @@ -431,8 +431,8 @@ Feature: federation/call
| remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
| LOCAL | room | 0 | participant1@LOCAL | participant1-displayname |
And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1)
| id | name | type | remoteServer | remoteToken |
| LOCAL::room | room | 2 | LOCAL | room |
| id | name | type | remoteServer | remoteToken |
| LOCAL::room | room | 2 | LOCAL | room |
And using server "LOCAL"
And user "participant1" joins room "room" with 200 (v4)
And user "participant1" joins call "room" with 200 (v4)
Expand Down
17 changes: 1 addition & 16 deletions tests/integration/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ echo -e "Running on process ID: \033[1;35m$PHPPID1\033[0m"
# Output filtered php server logs
tail -f phpserver.log | grep --line-buffered -v -E ":[0-9]+ Accepted$" | grep --line-buffered -v -E ":[0-9]+ Closing$" &

PORT_FED=8180
export PORT_FED

echo "" > phpserver_fed.log
PHP_CLI_SERVER_WORKERS=3 php -S localhost:${PORT_FED} -t ${ROOT_DIR} &> phpserver_fed.log &
PHPPID2=$!
echo -e "Running on process ID: \033[1;35m$PHPPID2\033[0m"

# Output filtered federated php server logs
tail -f phpserver_fed.log | grep --line-buffered -v -E ":[0-9]+ Accepted$" | grep --line-buffered -v -E ":[0-9]+ Closing$" &

occ_host() {
NEXTCLOUD_CONFIG_DIR=${MAIN_SERVER_CONFIG_DIR} ${ROOT_DIR}/occ "$@"
}
Expand Down Expand Up @@ -100,14 +89,13 @@ echo -e "Running on process ID: \033[1;35m$PHPPID3\033[0m"
tail -f phpserver_fed_real.log | grep --line-buffered -v -E ":[0-9]+ Accepted$" | grep --line-buffered -v -E ":[0-9]+ Closing$" &

# Kill all sub-processes in case of ctrl+c
trap 'pkill -P $PHPPID1; pkill -P $PHPPID2; pkill -P $PHPPID3; pkill -P $PROCESS_ID; wait $PHPPID1; wait $PHPPID2; wait $PHPPID3;' INT TERM
trap 'pkill -P $PHPPID1; pkill -P $PHPPID3; pkill -P $PROCESS_ID; wait $PHPPID1; wait $PHPPID3;' INT TERM

export NEXTCLOUD_HOST_ROOT_DIR=${ROOT_DIR}
export NEXTCLOUD_HOST_CONFIG_DIR=${MAIN_SERVER_CONFIG_DIR}
export NEXTCLOUD_REMOTE_ROOT_DIR=${REMOTE_ROOT_DIR}
export NEXTCLOUD_REMOTE_CONFIG_DIR=${REAL_FEDERATED_SERVER_CONFIG_DIR}
export TEST_SERVER_URL="http://localhost:8080/"
export TEST_LOCAL_REMOTE_URL="http://localhost:8180/"
export TEST_REMOTE_URL="http://localhost:8280/"

export NEXTCLOUD_CONFIG_DIR="$MAIN_SERVER_CONFIG_DIR"
Expand Down Expand Up @@ -204,12 +192,10 @@ echo -e "\033[0;36m#\033[0m"

# Kill child PHP processes
pkill -P $PHPPID1;
pkill -P $PHPPID2;
pkill -P $PHPPID3;

# Kill parent PHP processes
kill -TERM $PHPPID1;
kill -TERM $PHPPID2;
kill -TERM $PHPPID3;

# Kill child processes of this script (e.g. tail)
Expand Down Expand Up @@ -248,7 +234,6 @@ rm -rf ${REMOTE_ROOT_DIR}/apps/spreedcheats
rm -rf ${REMOTE_ROOT_DIR}/apps/talk_webhook_demo

wait $PHPPID1
wait $PHPPID2
wait $PHPPID3

echo ''
Expand Down

0 comments on commit 55dd9d1

Please sign in to comment.