From e0ba1e75f03e3f0e5366829ba1277b1f559e7af4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 29 Apr 2024 10:47:56 +0200 Subject: test(teams): Add a test to check if "Shared with team" allows chatting Signed-off-by: Joas Schilling --- .github/workflows/integration-mysql.yml | 9 +++++ .github/workflows/integration-oci.yml | 9 +++++ .github/workflows/integration-pgsql.yml | 9 +++++ .github/workflows/integration-sqlite.yml | 9 +++++ .../features/bootstrap/FeatureContext.php | 41 ++++++++++++++++++++++ .../features/bootstrap/SharingContext.php | 25 +++++++++++++ .../features/conversation-2/files.feature | 10 ++++++ tests/integration/run.sh | 4 +++ 8 files changed, 116 insertions(+) diff --git a/.github/workflows/integration-mysql.yml b/.github/workflows/integration-mysql.yml index ef2152149..33b9fafc7 100644 --- a/.github/workflows/integration-mysql.yml +++ b/.github/workflows/integration-mysql.yml @@ -56,6 +56,7 @@ jobs: php-versions: ['8.2'] server-versions: ['master'] guests-versions: ['master'] + circles-versions: ['master'] call-summary-bot-versions: ['main'] notifications-versions: ['master'] @@ -93,6 +94,13 @@ jobs: path: apps/call_summary_bot ref: ${{ matrix.call-summary-bot-versions }} + - name: Checkout circles app + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + repository: nextcloud/circles + path: apps/circles + ref: ${{ matrix.circles-versions }} + - name: Checkout guests app uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: @@ -136,6 +144,7 @@ jobs: ./occ config:system:set hashing_default_password --value=true --type=boolean ./occ app:enable --force ${{ env.APP_NAME }} ./occ app:enable --force call_summary_bot + ./occ app:enable --force circles ./occ app:enable --force guests ./occ app:enable --force notifications diff --git a/.github/workflows/integration-oci.yml b/.github/workflows/integration-oci.yml index 11f460816..8e8162d24 100644 --- a/.github/workflows/integration-oci.yml +++ b/.github/workflows/integration-oci.yml @@ -56,6 +56,7 @@ jobs: php-versions: ['8.2'] server-versions: ['master'] guests-versions: ['master'] + circles-versions: ['master'] call-summary-bot-versions: ['main'] notifications-versions: ['master'] @@ -105,6 +106,13 @@ jobs: path: apps/call_summary_bot ref: ${{ matrix.call-summary-bot-versions }} + - name: Checkout circles app + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + repository: nextcloud/circles + path: apps/circles + ref: ${{ matrix.circles-versions }} + - name: Checkout guests app uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: @@ -148,6 +156,7 @@ jobs: ./occ config:system:set hashing_default_password --value=true --type=boolean ./occ app:enable --force ${{ env.APP_NAME }} ./occ app:enable --force call_summary_bot + ./occ app:enable --force circles ./occ app:enable --force guests ./occ app:enable --force notifications diff --git a/.github/workflows/integration-pgsql.yml b/.github/workflows/integration-pgsql.yml index 3bcc2f2c5..c2df4d745 100644 --- a/.github/workflows/integration-pgsql.yml +++ b/.github/workflows/integration-pgsql.yml @@ -53,6 +53,7 @@ jobs: php-versions: ['8.3'] server-versions: ['master'] guests-versions: ['master'] + circles-versions: ['master'] call-summary-bot-versions: ['main'] notifications-versions: ['master'] @@ -96,6 +97,13 @@ jobs: path: apps/call_summary_bot ref: ${{ matrix.call-summary-bot-versions }} + - name: Checkout circles app + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + repository: nextcloud/circles + path: apps/circles + ref: ${{ matrix.circles-versions }} + - name: Checkout guests app uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: @@ -143,6 +151,7 @@ jobs: ./occ config:system:set memcache.distributed --value="\\OC\\Memcache\\APCu" ./occ app:enable --force ${{ env.APP_NAME }} ./occ app:enable --force call_summary_bot + ./occ app:enable --force circles ./occ app:enable --force guests ./occ app:enable --force notifications diff --git a/.github/workflows/integration-sqlite.yml b/.github/workflows/integration-sqlite.yml index e31924815..c65a4cdf7 100644 --- a/.github/workflows/integration-sqlite.yml +++ b/.github/workflows/integration-sqlite.yml @@ -56,6 +56,7 @@ jobs: php-versions: ['8.2'] server-versions: ['master'] guests-versions: ['master'] + circles-versions: ['master'] call-summary-bot-versions: ['main'] notifications-versions: ['master'] @@ -84,6 +85,13 @@ jobs: path: apps/call_summary_bot ref: ${{ matrix.call-summary-bot-versions }} + - name: Checkout circles app + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + repository: nextcloud/circles + path: apps/circles + ref: ${{ matrix.circles-versions }} + - name: Checkout guests app uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: @@ -127,6 +135,7 @@ jobs: ./occ config:system:set hashing_default_password --value=true --type=boolean ./occ app:enable --force ${{ env.APP_NAME }} ./occ app:enable --force call_summary_bot + ./occ app:enable --force circles ./occ app:enable --force guests ./occ app:enable --force notifications diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index d1a65713e..319704c6c 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -59,6 +59,8 @@ class FeatureContext implements Context, SnippetAcceptingContext { protected static ?array $nextChatRequestParameters = null; /** @var array */ protected static array $modifiedSince; + /** @var array */ + protected static array $createdTeams = []; protected static array $permissionsMap = [ @@ -111,6 +113,10 @@ class FeatureContext implements Context, SnippetAcceptingContext { return self::$identifierToToken[$identifier]; } + public static function getTeamIdForLabel(string $label): string { + return self::$createdTeams[$label] ?? throw new \RuntimeException('Unknown team: ' . $label); + } + public static function getMessageIdForText(string $text): int { return self::$textToMessageId[$text]; } @@ -175,6 +181,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $this->createdUsers = []; $this->createdGroups = []; + self::$createdTeams = []; $this->createdGuestAccountUsers = []; } @@ -197,6 +204,9 @@ class FeatureContext implements Context, SnippetAcceptingContext { foreach ($this->createdGroups as $group) { $this->deleteGroup($group); } + foreach (self::$createdTeams as $team => $id) { + $this->deleteTeam($team); + } foreach ($this->createdGuestAccountUsers as $user) { $this->deleteGuestUser($user); } @@ -3623,6 +3633,37 @@ class FeatureContext implements Context, SnippetAcceptingContext { Assert::assertEquals($totalCount, $ipv4Attempts + $ipv6Attempts, 'IP has bruteforce attempts for other actions registered'); } + /** + * @Given /^team "([^"]*)" exists$/ + */ + public function assureTeamExists(string $team): void { + $this->runOcc(['circles:manage:create', '--type', '1', '--output', 'json', 'admin', $team]); + $this->theCommandWasSuccessful(); + + $output = $this->getLastStdOut(); + $data = json_decode($output, true); + + self::$createdTeams[$team] = $data['id']; + } + + /** + * @Given /^add user "([^"]*)" to team "([^"]*)"$/ + */ + public function addTeamMember(string $user, string $team): void { + $this->runOcc(['circles:members:add', '--type', '1', self::$createdTeams[$team], $user]); + $this->theCommandWasSuccessful(); + } + + /** + * @Given /^delete team "([^"]*)"$/ + */ + public function deleteTeam(string $team): void { + $this->runOcc(['circles:manage:destroy', self::$createdTeams[$team]]); + $this->theCommandWasSuccessful(); + + unset(self::$createdTeams[$team]); + } + /** * @Given /^user "([^"]*)" is a guest account user/ * @param string $email email address diff --git a/tests/integration/features/bootstrap/SharingContext.php b/tests/integration/features/bootstrap/SharingContext.php index 665e2a2f0..cfcc06f85 100644 --- a/tests/integration/features/bootstrap/SharingContext.php +++ b/tests/integration/features/bootstrap/SharingContext.php @@ -144,6 +144,31 @@ class SharingContext implements Context { $this->theOCSStatusCodeShouldBe($statusCode); } + /** + * @When user :user shares :path with team :sharee + * + * @param string $user + * @param string $path + * @param string $sharee + * @param TableNode|null $body + */ + public function userSharesWithTeam(string $user, string $path, string $sharee, TableNode $body = null) { + $this->userSharesWith($user, $path, 7 /*IShare::TYPE_CIRCLE*/, $sharee, $body); + } + + /** + * @When user :user shares :path with team :sharee with OCS :statusCode + * + * @param string $user + * @param string $path + * @param string $sharee + * @param int $statusCode + */ + public function userSharesWithTeamWithOcs(string $user, string $path, string $sharee, int $statusCode) { + $this->userSharesWithTeam($user, $path, FeatureContext::getTeamIdForLabel($sharee)); + $this->theOCSStatusCodeShouldBe($statusCode); + } + /** * @When user :user shares :path with room :room * diff --git a/tests/integration/features/conversation-2/files.feature b/tests/integration/features/conversation-2/files.feature index d8a4aeb17..a2e16ce64 100644 --- a/tests/integration/features/conversation-2/files.feature +++ b/tests/integration/features/conversation-2/files.feature @@ -83,6 +83,16 @@ Feature: conversation/files And user "participant3" is not participant of room "file welcome (2).txt room" (v4) + Scenario: get room for file shared with team + Given team "team1" exists + And add user "participant1" to team "team1" + And add user "participant2" to team "team1" + And user "participant1" shares "welcome.txt" with team "team1" with OCS 100 + When user "participant1" gets the room for path "welcome.txt" with 200 (v1) + And user "participant2" gets the room for path "welcome (2).txt" with 200 (v1) + Then user "participant1" is not participant of room "file welcome (2).txt room" (v4) + And user "participant2" is not participant of room "file welcome (2).txt room" (v4) + Scenario: get room for link share Given user "participant1" shares "welcome.txt" with user "participant2" with OCS 100 diff --git a/tests/integration/run.sh b/tests/integration/run.sh index c15f037d1..2791caf92 100755 --- a/tests/integration/run.sh +++ b/tests/integration/run.sh @@ -8,6 +8,7 @@ PROCESS_ID=$$ APP_NAME=spreed NOTIFICATIONS_BRANCH="master" GUESTS_BRANCH="master" +CIRCLES_BRANCH="master" CSB_BRANCH="main" APP_INTEGRATION_DIR=$PWD @@ -71,17 +72,20 @@ ${ROOT_DIR}/occ app:getpath spreedcheats # already there or in "apps"). ${ROOT_DIR}/occ app:getpath notifications || (cd ../../../ && git clone --depth 1 --branch ${NOTIFICATIONS_BRANCH} https://github.com/nextcloud/notifications) ${ROOT_DIR}/occ app:getpath guests || (cd ../../../ && git clone --depth 1 --branch ${GUESTS_BRANCH} https://github.com/nextcloud/guests) +${ROOT_DIR}/occ app:getpath circles || (cd ../../../ && git clone --depth 1 --branch ${CIRCLES_BRANCH} https://github.com/nextcloud/circles) ${ROOT_DIR}/occ app:getpath call_summary_bot || (cd ../../../ && git clone --depth 1 --branch ${CSB_BRANCH} https://github.com/nextcloud/call_summary_bot) ${ROOT_DIR}/occ app:enable spreed || exit 1 ${ROOT_DIR}/occ app:enable --force spreedcheats || exit 1 ${ROOT_DIR}/occ app:enable --force notifications || exit 1 ${ROOT_DIR}/occ app:enable --force guests || exit 1 +${ROOT_DIR}/occ app:enable --force circles || exit 1 ${ROOT_DIR}/occ app:enable --force call_summary_bot || exit 1 ${ROOT_DIR}/occ app:list | grep spreed ${ROOT_DIR}/occ app:list | grep notifications ${ROOT_DIR}/occ app:list | grep guests +${ROOT_DIR}/occ app:list | grep circles ${ROOT_DIR}/occ app:list | grep call_summary_bot echo '' -- cgit v1.2.3