summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-10-04 17:08:27 +0200
committerJoas Schilling <coding@schilljs.com>2023-10-23 15:47:58 +0200
commitcd87f6c8ad1f47f430e8a2d4f35d1fd47890dff3 (patch)
tree0d431d61f277a6bbb62b421501a4ad66d37b6251
parentc172fd57eea03ff4a53ea9233d467cdfb4663cb0 (diff)
tests(sip-dialout): Add integration test for adding phone number to a conversation
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php19
-rw-r--r--tests/integration/features/conversation-2/sip-dialout.feature41
2 files changed, 59 insertions, 1 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index 38f7e61dc..daf981b09 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -69,6 +69,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
protected static array $botNameToId;
/** @var array<string, string> */
protected static array $botNameToHash;
+ /** @var array<string, string> */
+ protected static array $phoneNumberToActorId;
/** @var array<string, mixed>|null */
protected static ?array $nextChatRequestParameters = null;
@@ -665,6 +667,9 @@ class FeatureContext implements Context, SnippetAcceptingContext {
if (isset($expectedKeys['displayName'])) {
$data['displayName'] = (string) $attendee['displayName'];
}
+ if (isset($expectedKeys['phoneNumber'])) {
+ $data['phoneNumber'] = (string) $attendee['phoneNumber'];
+ }
if (!isset(self::$userToAttendeeId[$identifier][$attendee['actorType']])) {
self::$userToAttendeeId[$identifier][$attendee['actorType']] = [];
@@ -683,6 +688,14 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$attendee['actorId'] .= '@' . rtrim($this->baseRemoteUrl, '/');
}
+ if (isset($attendee['actorId'], $attendee['actorType'], $attendee['phoneNumber'])
+ && $attendee['actorType'] === 'phones'
+ && $attendee['actorId'] === 'PHONE(' . $actual['phoneNumber'] . ')'
+ && $attendee['phoneNumber'] === $actual['phoneNumber']) {
+ $attendee['actorId'] = $actual['actorId'];
+ self::$phoneNumberToActorId[$attendee['phoneNumber']] = $actual['actorId'];
+ }
+
// Breakout room regex
if (isset($attendee['actorId']) && strpos($attendee['actorId'], '/') === 0 && preg_match($attendee['actorId'], $actual['actorId'])) {
$attendee['actorId'] = $actual['actorId'];
@@ -691,6 +704,10 @@ class FeatureContext implements Context, SnippetAcceptingContext {
if (isset($attendee['participantType'])) {
$attendee['participantType'] = (string)$this->mapParticipantTypeTestInput($attendee['participantType']);
}
+
+ if (isset($attendee['actorType']) && $attendee['actorType'] === 'phones') {
+ $attendee['participantType'] = (string)$this->mapParticipantTypeTestInput($attendee['participantType']);
+ }
return $attendee;
}, $formData->getHash(), $result);
@@ -1526,7 +1543,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
- * @Then /^user "([^"]*)" adds (user|group|email|circle|remote) "([^"]*)" to room "([^"]*)" with (\d+) \((v4)\)$/
+ * @Then /^user "([^"]*)" adds (user|group|email|circle|remote|phone) "([^"]*)" to room "([^"]*)" with (\d+) \((v4)\)$/
*
* @param string $user
* @param string $newType
diff --git a/tests/integration/features/conversation-2/sip-dialout.feature b/tests/integration/features/conversation-2/sip-dialout.feature
new file mode 100644
index 000000000..5ad447fe9
--- /dev/null
+++ b/tests/integration/features/conversation-2/sip-dialout.feature
@@ -0,0 +1,41 @@
+Feature: conversation-2/sip-dialout
+ Background:
+ Given user "participant1" exists
+ Given user "participant2" exists
+ Given group "group1" exists
+ Given user "participant1" is member of group "group1"
+
+ Scenario: SIP admin uses dial out
+ Given the following "spreed" app config is set
+ | sip_bridge_dialin_info | +49-1234-567890 |
+ | sip_bridge_shared_secret | 1234567890abcdef |
+ | sip_bridge_groups | ["group1"] |
+ | sip_dialout | yes |
+ Given user "participant1" creates room "room" (v4)
+ | roomType | 3 |
+ | roomName | room |
+ And user "participant1" is participant of the following rooms (v4)
+ | id | type | participantType | sipEnabled |
+ | room | 3 | 1 | 0 |
+ When user "participant1" adds user "participant2" to room "room" with 200 (v4)
+ When user "participant1" adds phone "+491601231212" to room "room" with 200 (v4)
+ Then user "participant1" sees the following attendees in room "room" with 200 (v4)
+ | participantType | inCall | actorType | actorId | displayName | phoneNumber |
+ | 3 | 0 | phones | PHONE(+491601231212) | +49160123… | +491601231212 |
+ | 1 | 0 | users | participant1 | participant1-displayname | |
+ | 3 | 0 | users | participant2 | participant2-displayname | |
+ When user "participant2" adds phone "+491601231212" to room "room" with 403 (v4)
+
+ Scenario: Non-SIP admin tries to dial out
+ Given the following "spreed" app config is set
+ | sip_bridge_dialin_info | +49-1234-567890 |
+ | sip_bridge_shared_secret | 1234567890abcdef |
+ | sip_bridge_groups | ["group1"] |
+ | sip_dialout | yes |
+ Given user "participant2" creates room "room" (v4)
+ | roomType | 3 |
+ | roomName | room |
+ When user "participant2" adds phone "+491601231212" to room "room" with 501 (v4)
+ When user "participant2" adds user "participant1" to room "room" with 200 (v4)
+ # SIP admin that is not a moderator can also not dial-out
+ When user "participant1" adds phone "+491601231212" to room "room" with 403 (v4)