Skip to content

Commit 8f902c7

Browse files
authored
Merge pull request #36777 from owncloud/inactive-users-occ
[Tests-only] cli test to get the list of inactive users
2 parents b73be6d + 51ca4e6 commit 8f902c7

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

tests/acceptance/features/bootstrap/OccUsersGroupsContext.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,20 @@ public function theAdministratorRetrievesAllTheUsersInJsonUsingTheOccCommand() {
303303
);
304304
}
305305

306+
/**
307+
* @When the administrator gets the list of all users inactive for the last :numberOfDays days using the occ command
308+
*
309+
* @param integer $numberOfDays
310+
*
311+
* @return void
312+
* @throws Exception
313+
*/
314+
public function theAdministratorGetsTheListOfAllUsersInactiveForTheLastDays($numberOfDays) {
315+
$this->occContext->invokingTheCommand(
316+
"user:inactive $numberOfDays --output=json"
317+
);
318+
}
319+
306320
/**
307321
* @When the administrator retrieves the information of user :username in JSON format using the occ command
308322
*
@@ -529,6 +543,42 @@ public function theUsersReturnedByTheOccCommandShouldBe(TableNode $useridTable)
529543
}
530544
}
531545

546+
/**
547+
* @Then the inactive users returned by the occ command should be
548+
*
549+
* @param TableNode $userTable
550+
*
551+
* @return void
552+
* @throws Exception
553+
*/
554+
public function theInactiveUsersReturnedByTheOccCommandShouldBe(TableNode $userTable) {
555+
$this->featureContext->verifyTableNodeColumns($userTable, ['uid', 'display name', 'inactive days']);
556+
$lastOutput = $this->featureContext->getStdOutOfOccCommand();
557+
$lastOutputUsers = \json_decode($lastOutput, true);
558+
559+
Assert::assertEquals(\count($userTable->getColumnsHash()), \count($lastOutputUsers));
560+
561+
$found = false;
562+
foreach ($userTable as $row) {
563+
foreach ($lastOutputUsers as $user) {
564+
if ($user['uid'] === $row['uid']) {
565+
$found = true;
566+
Assert::assertEquals(
567+
$user['displayName'],
568+
$row['display name'],
569+
"expected {$row['display name']} but got {$user['displayName']}"
570+
);
571+
Assert::assertEquals(
572+
$user['inactiveSinceDays'],
573+
$row['inactive days'],
574+
"expected {$row['inactive days']} days but got {$user['inactiveSinceDays']} days"
575+
);
576+
}
577+
}
578+
Assert::assertTrue($found);
579+
}
580+
}
581+
532582
/**
533583
* @Then the groups returned by the occ command should be
534584
*

tests/acceptance/features/cliProvisioning/getUsers.feature

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,19 @@ Feature: get users
1212
Then the command should have been successful
1313
And the users returned by the occ command should be
1414
| uid | display name |
15-
| brand-new-user | Just A User |
15+
| brand-new-user | Just A User |
16+
17+
Scenario: admin gets the list of all inactive users
18+
Given these users have been created with default attributes and without skeleton files:
19+
| username |
20+
| user1 |
21+
| user2 |
22+
| user3 |
23+
And the administrator has set the last login date for user "user1" to "7" days ago
24+
And the administrator has set the last login date for user "user2" to "400" days ago
25+
When the administrator gets the list of all users inactive for the last "2" days using the occ command
26+
Then the command should have been successful
27+
And the inactive users returned by the occ command should be
28+
| uid | display name | inactive days |
29+
| user1 | User One | 7 |
30+
| user2 | User Two | 400 |

0 commit comments

Comments
 (0)