Skip to content

cliTest for userLastSeen #33244

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

Merged
merged 1 commit into from
Oct 23, 2018
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
44 changes: 44 additions & 0 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,19 @@ public function theAdministratorGetsTheGroupsOfUserInJsonUsingTheOccCommand($use
);
}

/**
* @When the administrator retrieves the time when user :username was last seen using the occ command
*
* @param string $username
*
* @return void
*/
public function theAdministratorRetrievesTheTimeWhenUserWasLastSeenUsingTheOccCommand($username) {
$this->featureContext->invokingTheCommand(
"user:lastseen $username"
);
}

/**
* @When the administrator sends a group creation request for group :group using the occ command
*
Expand Down Expand Up @@ -500,6 +513,37 @@ public function theDisplayNameReturnedByTheOccCommandShouldBe($displayName) {
PHPUnit_Framework_Assert::assertEquals($displayName, $lastOutputDisplayName);
}

/**
* @Then the command output of user last seen should be recently
*
* @return void
* @throws \Exception
*/
public function theCommandOutputOfUserLastSeenShouldBeRecently() {
$currentTime = \gmdate('d.m.Y H:i');
$currentTimeStamp = \strtotime($currentTime);
$lastOutput = $this->featureContext->getStdOutOfOccCommand();
\preg_match("/([\d.]+ [\d:]+)/", $lastOutput, $userCreatedTime);
$useCreatedTimeStamp = \strtotime(($userCreatedTime[0]));
$delta = $currentTimeStamp - $useCreatedTimeStamp;
if ($delta > 60) {
throw new Exception(__METHOD__ . "User was expected to be seen recently but wasn't");
}
}

/**
* @Then the command output of user last seen should be never
*
* @return void
*/
public function theCommandOutputOfUserLastSeenShouldBeNever() {
$lastOutput = $this->featureContext->getStdOutOfOccCommand();
PHPUnit_Framework_Assert::assertContains(
"has never logged in, yet.",
$lastOutput
);
}

/**
* @When the administrator sets the log level to :level using the occ command
*
Expand Down
19 changes: 19 additions & 0 deletions tests/acceptance/features/cliProvisioning/userLastSeen.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@cli @skipOnLDAP
Feature: get user last seen
As an admin
I want to be able get user last seen
So that I can see when the user has last logged in the owncloud server

Scenario: admin gets last seen of a user
Given user "brand-new-user" has been created
When the administrator retrieves the time when user "brand-new-user" was last seen using the occ command
Then the command should have been successful
And the command output of user last seen should be recently

Scenario: admin gets last seen of a user who has not been initialized
Given these users have been created but not initialized:
| username |
| brand-new-user |
When the administrator retrieves the time when user "brand-new-user" was last seen using the occ command
Then the command should have been successful
And the command output of user last seen should be never