Skip to content

Commit 3bbcb9c

Browse files
Merge pull request #10254 from nextcloud/backport/10229/master
fix(CI): Fix resetting users between tests when a guest was created
2 parents 9c1143a + ffbbe0a commit 3bbcb9c

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

tests/integration/features/bootstrap/FeatureContext.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public function tearDown() {
196196
$this->deleteGroup($group);
197197
}
198198
foreach ($this->createdGuestAccountUsers as $user) {
199-
$this->deleteUser($user);
199+
$this->deleteGuestUser($user);
200200
}
201201
}
202202

@@ -3019,7 +3019,7 @@ public function createGuestUser($email) {
30193019
]);
30203020
Assert::assertEquals(0, $lastCode, 'Guest creation succeeded for ' . $email);
30213021

3022-
$this->createdGuestAccountUsers[] = $email;
3022+
$this->createdGuestAccountUsers[$email] = $email;
30233023
$this->setCurrentUser($currentUser);
30243024
}
30253025

@@ -3045,7 +3045,7 @@ private function createUser($user) {
30453045
$this->sendRequest('GET', '/cloud/users' . '/' . $user);
30463046
$this->assertStatusCode($this->response, 200, 'Failed to do first login');
30473047

3048-
$this->createdUsers[] = $user;
3048+
$this->createdUsers[$user] = $user;
30493049

30503050
$this->setCurrentUser($currentUser);
30513051
}
@@ -3073,7 +3073,18 @@ private function deleteUser($user) {
30733073
$this->sendRequest('DELETE', '/cloud/users/' . $user);
30743074
$this->setCurrentUser($currentUser);
30753075

3076-
unset($this->createdUsers[array_search($user, $this->createdUsers, true)]);
3076+
unset($this->createdUsers[$user]);
3077+
3078+
return $this->response;
3079+
}
3080+
3081+
private function deleteGuestUser($user) {
3082+
$currentUser = $this->currentUser;
3083+
$this->setCurrentUser('admin');
3084+
$this->sendRequest('DELETE', '/cloud/users/' . $user);
3085+
$this->setCurrentUser($currentUser);
3086+
3087+
unset($this->createdGuestAccountUsers[$user]);
30773088

30783089
return $this->response;
30793090
}
@@ -3114,7 +3125,7 @@ public function assureGroupExists($group) {
31143125

31153126
$this->setCurrentUser($currentUser);
31163127

3117-
$this->createdGroups[] = $group;
3128+
$this->createdGroups[$group] = $group;
31183129
}
31193130

31203131
/**
@@ -3139,7 +3150,7 @@ private function deleteGroup($group) {
31393150
$this->sendRequest('DELETE', '/cloud/groups/' . $group);
31403151
$this->setCurrentUser($currentUser);
31413152

3142-
unset($this->createdGroups[array_search($group, $this->createdGroups, true)]);
3153+
unset($this->createdGroups[$group]);
31433154
}
31443155

31453156
/**

tests/integration/run.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ export TEST_REMOTE_URL="http://localhost:8180/"
4545
OVERWRITE_CLI_URL=$(${ROOT_DIR}/occ config:system:get overwrite.cli.url)
4646
${ROOT_DIR}/occ config:system:set overwrite.cli.url --value "http://localhost:8080/"
4747

48+
SKELETON_DIR=$(${ROOT_DIR}/occ config:system:get skeletondirectory)
49+
if [[ "$SKELETON_DIR" ]]; then
50+
echo "Resetting custom skeletondirectory so that tests pass"
51+
${ROOT_DIR}/occ config:system:delete skeletondirectory
52+
fi
53+
4854
echo ''
4955
echo '#'
5056
echo '# Setting up apps'
@@ -96,6 +102,9 @@ kill $PHPPID2
96102

97103
${ROOT_DIR}/occ app:disable spreedcheats
98104
${ROOT_DIR}/occ config:system:set overwrite.cli.url --value $OVERWRITE_CLI_URL
105+
if [[ "$SKELETON_DIR" ]]; then
106+
${ROOT_DIR}/occ config:system:set skeletondirectory --value "$SKELETON_DIR"
107+
fi
99108
rm -rf ../../../spreedcheats
100109

101110
wait $PHPPID1

0 commit comments

Comments
 (0)