Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(teams): Add a test to check if "Shared with team" allows chatting #12240

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/integration-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down Expand Up @@ -93,6 +94,13 @@ jobs:
path: apps/call_summary_bot
ref: ${{ matrix.call-summary-bot-versions }}

- name: Checkout circles app
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: nextcloud/circles
path: apps/circles
ref: ${{ matrix.circles-versions }}

- name: Checkout guests app
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
Expand Down Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/integration-oci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down Expand Up @@ -105,6 +106,13 @@ jobs:
path: apps/call_summary_bot
ref: ${{ matrix.call-summary-bot-versions }}

- name: Checkout circles app
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: nextcloud/circles
path: apps/circles
ref: ${{ matrix.circles-versions }}

- name: Checkout guests app
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
Expand Down Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/integration-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down Expand Up @@ -96,6 +97,13 @@ jobs:
path: apps/call_summary_bot
ref: ${{ matrix.call-summary-bot-versions }}

- name: Checkout circles app
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: nextcloud/circles
path: apps/circles
ref: ${{ matrix.circles-versions }}

- name: Checkout guests app
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
Expand Down Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/integration-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down Expand Up @@ -84,6 +85,13 @@ jobs:
path: apps/call_summary_bot
ref: ${{ matrix.call-summary-bot-versions }}

- name: Checkout circles app
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: nextcloud/circles
path: apps/circles
ref: ${{ matrix.circles-versions }}

- name: Checkout guests app
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
Expand Down Expand Up @@ -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

Expand Down
41 changes: 41 additions & 0 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
protected static ?array $nextChatRequestParameters = null;
/** @var array<string, int> */
protected static array $modifiedSince;
/** @var array<string, string> */
protected static array $createdTeams = [];


protected static array $permissionsMap = [
Expand Down Expand Up @@ -111,6 +113,10 @@ public static function getTokenForIdentifier(string $identifier) {
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];
}
Expand Down Expand Up @@ -175,6 +181,7 @@ public function setUp() {

$this->createdUsers = [];
$this->createdGroups = [];
self::$createdTeams = [];
$this->createdGuestAccountUsers = [];
}

Expand All @@ -197,6 +204,9 @@ public function tearDown() {
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);
}
Expand Down Expand Up @@ -3623,6 +3633,37 @@ public function assertBruteforceAttempts(TableNode $tableNode = null): void {
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
Expand Down
25 changes: 25 additions & 0 deletions tests/integration/features/bootstrap/SharingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,31 @@ public function userSharesWithGroupWithOcs(string $user, string $path, string $s
$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
*
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/features/conversation-2/files.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ''
Expand Down
Loading