Skip to content

Commit

Permalink
fix(emails): Fix integration tests assuming the email is the actorId
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Oct 23, 2024
1 parent 4cb26cc commit 4874ab5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
15 changes: 13 additions & 2 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,9 @@ protected function assertAttendeeList(string $identifier, ?TableNode $formData,
if (isset($expectedKeys['callId'])) {
$data['callId'] = (string)$attendee['callId'];
}
if (isset($expectedKeys['invitedActorId'], $attendee['invitedActorId'])) {
$data['invitedActorId'] = (string)$attendee['invitedActorId'];
}
if (isset($expectedKeys['status'], $attendee['status'])) {
$data['status'] = (string)$attendee['status'];
}
Expand Down Expand Up @@ -891,6 +894,9 @@ protected function assertAttendeeList(string $identifier, ?TableNode $formData,
if (isset($attendee['actorId']) && str_ends_with($attendee['actorId'], '@{$REMOTE_URL}')) {
$attendee['actorId'] = str_replace('{$REMOTE_URL}', rtrim($this->remoteServerUrl, '/'), $attendee['actorId']);
}
if (preg_match('/^SHA256\(([a-z0-9@.+\-]+)\)$/', $attendee['actorId'], $match)) {
$attendee['actorId'] = hash('sha256', $match[1]);
}

if (isset($attendee['actorId'], $attendee['actorType']) && $attendee['actorType'] === 'federated_users' && !str_contains($attendee['actorId'], '@')) {
$attendee['actorId'] .= '@' . rtrim($this->localRemoteServerUrl, '/');
Expand Down Expand Up @@ -928,6 +934,10 @@ protected function assertAttendeeList(string $identifier, ?TableNode $formData,
$attendee['participantType'] = (string)$this->mapParticipantTypeTestInput($attendee['participantType']);
}

if (isset($attendee['invitedActorId']) && $attendee['invitedActorId'] === 'ABSENT') {
unset($attendee['invitedActorId']);
}

if (isset($attendee['status']) && $attendee['status'] === 'ABSENT') {
unset($attendee['status']);
}
Expand Down Expand Up @@ -1382,9 +1392,10 @@ public function userResendsInvite(string $user, string $identifier, int $statusC
$body = null;
if ($formData instanceof TableNode) {
$attendee = $formData?->getRowsHash()['attendeeId'] ?? '';
if (isset(self::$userToAttendeeId[$identifier]['emails'][$attendee])) {
$actorId = hash('sha256', $attendee);
if (isset(self::$userToAttendeeId[$identifier]['emails'][$actorId])) {
$body = [
'attendeeId' => self::$userToAttendeeId[$identifier]['emails'][$attendee],
'attendeeId' => self::$userToAttendeeId[$identifier]['emails'][$actorId],
];
} elseif (str_starts_with($attendee, 'not-found')) {
$body = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Feature: conversation/invite-email
# Ref https://github.com/nextcloud/calendar/pull/5380
When user "participant1" adds email "[email protected]" to room "room" with 200 (v4)
Then user "participant1" sees the following attendees in room "room" with 200 (v4)
| participantType | inCall | actorType | actorId |
| 4 | 0 | emails | test@example.tld |
| 1 | 0 | users | participant1 |
| participantType | inCall | actorType | actorId | invitedActorId |
| 4 | 0 | emails | SHA256(test@example.tld) | test@example.tld |
| 1 | 0 | users | participant1 | ABSENT |
# Reinvite all emails
When user "participant1" resends invite for room "room" with 200 (v4)
# Reinvite only one
Expand Down
48 changes: 24 additions & 24 deletions tests/integration/features/conversation-5/sip-dialin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,36 @@ Feature: conversation-2/sip-dialin
# Guests don't get a PIN as they can not be recognized and are deleted on leave
When user "guest" joins room "room" with 200 (v4)
Then user "participant1" sees the following attendees in room "room" with 200 (v4)
| participantType | inCall | actorType | actorId | attendeePin |
| 4 | 0 | emails | test@example.tld | **PIN** |
| 4 | 0 | guests | "guest" | |
| 1 | 0 | users | participant1 | **PIN** |
| 3 | 0 | users | participant2 | **PIN** |
| 3 | 0 | users | participant3 | **PIN** |
| participantType | inCall | actorType | actorId | attendeePin |
| 4 | 0 | emails | SHA256(test@example.tld) | **PIN** |
| 4 | 0 | guests | "guest" | |
| 1 | 0 | users | participant1 | **PIN** |
| 3 | 0 | users | participant2 | **PIN** |
| 3 | 0 | users | participant3 | **PIN** |
When user "participant2" sets SIP state for room "room" to "disabled" with 403 (v4)
Then user "participant1" sees the following attendees in room "room" with 200 (v4)
| participantType | inCall | actorType | actorId | attendeePin |
| 4 | 0 | emails | test@example.tld | **PIN** |
| 4 | 0 | guests | "guest" | |
| 1 | 0 | users | participant1 | **PIN** |
| 3 | 0 | users | participant2 | **PIN** |
| 3 | 0 | users | participant3 | **PIN** |
| participantType | inCall | actorType | actorId | attendeePin |
| 4 | 0 | emails | SHA256(test@example.tld) | **PIN** |
| 4 | 0 | guests | "guest" | |
| 1 | 0 | users | participant1 | **PIN** |
| 3 | 0 | users | participant2 | **PIN** |
| 3 | 0 | users | participant3 | **PIN** |
When user "participant1" sets SIP state for room "room" to "disabled" with 200 (v4)
Then user "participant1" sees the following attendees in room "room" with 200 (v4)
| participantType | inCall | actorType | actorId | attendeePin |
| 4 | 0 | emails | test@example.tld | |
| 4 | 0 | guests | "guest" | |
| 1 | 0 | users | participant1 | |
| 3 | 0 | users | participant2 | |
| 3 | 0 | users | participant3 | |
| participantType | inCall | actorType | actorId | attendeePin |
| 4 | 0 | emails | SHA256(test@example.tld) | |
| 4 | 0 | guests | "guest" | |
| 1 | 0 | users | participant1 | |
| 3 | 0 | users | participant2 | |
| 3 | 0 | users | participant3 | |
When user "participant1" sets SIP state for room "room" to "no pin" with 200 (v4)
Then user "participant1" sees the following attendees in room "room" with 200 (v4)
| participantType | inCall | actorType | actorId | attendeePin |
| 4 | 0 | emails | test@example.tld | **PIN** |
| 4 | 0 | guests | "guest" | |
| 1 | 0 | users | participant1 | **PIN** |
| 3 | 0 | users | participant2 | **PIN** |
| 3 | 0 | users | participant3 | **PIN** |
| participantType | inCall | actorType | actorId | attendeePin |
| 4 | 0 | emails | SHA256(test@example.tld) | **PIN** |
| 4 | 0 | guests | "guest" | |
| 1 | 0 | users | participant1 | **PIN** |
| 3 | 0 | users | participant2 | **PIN** |
| 3 | 0 | users | participant3 | **PIN** |

Scenario: Non-SIP admin tries to enable SIP
Given the following "spreed" app config is set
Expand Down

0 comments on commit 4874ab5

Please sign in to comment.