summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2017-01-02 14:52:34 +0100
committerGitHub <noreply@github.com>2017-01-02 14:52:34 +0100
commit60a8a1a84484fd0f3ae8a7f46212850cd43b6c5c (patch)
treebf8b5650f886fa13dbaf30e1071e1560fc0785b5
parent61720bfbd3641618ab0603d491426170df7fbc12 (diff)
parent02359c79fdf9a46a3cd6eaf01ca60c406e96fd48 (diff)
downloadnextcloud-server-60a8a1a84484fd0f3ae8a7f46212850cd43b6c5c.tar.gz
nextcloud-server-60a8a1a84484fd0f3ae8a7f46212850cd43b6c5c.zip
Merge pull request #2909 from nextcloud/tests/remember-me-integration-test
Test remember-me login
-rw-r--r--build/integration/features/auth.feature10
-rw-r--r--build/integration/features/bootstrap/Auth.php40
-rw-r--r--build/integration/features/bootstrap/BasicStructure.php15
3 files changed, 45 insertions, 20 deletions
diff --git a/build/integration/features/auth.feature b/build/integration/features/auth.feature
index 43aa618bd00..a3af28f25c8 100644
--- a/build/integration/features/auth.feature
+++ b/build/integration/features/auth.feature
@@ -75,4 +75,12 @@ Feature: auth
Scenario: using OCS with browser session
Given a new browser session is started
When requesting "/ocs/v1.php/apps/files_sharing/api/v1/remote_shares" with "GET" using browser session
- Then the OCS status code should be "100" \ No newline at end of file
+ Then the OCS status code should be "100"
+
+ # REMEMBER ME
+ Scenario: remember login
+ Given a new remembered browser session is started
+ When the session cookie expires
+ And requesting "/index.php/apps/files" with "GET" using browser session
+ Then the HTTP status code should be "200"
+
diff --git a/build/integration/features/bootstrap/Auth.php b/build/integration/features/bootstrap/Auth.php
index f4b1a3e5b47..61cad0dc145 100644
--- a/build/integration/features/bootstrap/Auth.php
+++ b/build/integration/features/bootstrap/Auth.php
@@ -1,4 +1,5 @@
<?php
+
/**
*
@@ -47,7 +48,7 @@ trait Auth {
try {
if ($useCookies) {
$request = $this->client->createRequest($method, $fullUrl, [
- 'cookies' => $this->cookieJar,
+ 'cookies' => $this->cookieJar,
]);
} else {
$request = $this->client->createRequest($method, $fullUrl);
@@ -116,30 +117,43 @@ trait Auth {
/**
* @Given a new browser session is started
*/
- public function aNewBrowserSessionIsStarted() {
+ public function aNewBrowserSessionIsStarted($remember = false) {
$loginUrl = substr($this->baseUrl, 0, -5) . '/login';
// Request a new session and extract CSRF token
$client = new Client();
- $response = $client->get(
- $loginUrl, [
- 'cookies' => $this->cookieJar,
- ]
- );
+ $response = $client->get($loginUrl, [
+ 'cookies' => $this->cookieJar,
+ ]);
$this->extracRequestTokenFromResponse($response);
// Login and extract new token
$client = new Client();
$response = $client->post(
$loginUrl, [
- 'body' => [
- 'user' => 'user0',
- 'password' => '123456',
- 'requesttoken' => $this->requestToken,
- ],
- 'cookies' => $this->cookieJar,
+ 'body' => [
+ 'user' => 'user0',
+ 'password' => '123456',
+ 'remember_login' => $remember ? '1' : '0',
+ 'requesttoken' => $this->requestToken,
+ ],
+ 'cookies' => $this->cookieJar,
]
);
$this->extracRequestTokenFromResponse($response);
}
+ /**
+ * @Given a new remembered browser session is started
+ */
+ public function aNewRememberedBrowserSessionIsStarted() {
+ $this->aNewBrowserSessionIsStarted(true);
+ }
+
+ /**
+ * @When the session cookie expires
+ */
+ public function whenTheSessionCookieExpires() {
+ $this->cookieJar->clearSessionCookies();
+ }
+
}
diff --git a/build/integration/features/bootstrap/BasicStructure.php b/build/integration/features/bootstrap/BasicStructure.php
index 24428b6c9d9..8e1fcf86ba1 100644
--- a/build/integration/features/bootstrap/BasicStructure.php
+++ b/build/integration/features/bootstrap/BasicStructure.php
@@ -24,7 +24,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
use GuzzleHttp\Client;
+use GuzzleHttp\Cookie\CookieJar;
+use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Message\ResponseInterface;
require __DIR__ . '/../../vendor/autoload.php';
@@ -48,7 +51,7 @@ trait BasicStructure {
/** @var ResponseInterface */
private $response = null;
- /** @var \GuzzleHttp\Cookie\CookieJar */
+ /** @var CookieJar */
private $cookieJar;
/** @var string */
@@ -63,7 +66,7 @@ trait BasicStructure {
$this->localBaseUrl = $this->baseUrl;
$this->remoteBaseUrl = $this->baseUrl;
$this->currentServer = 'LOCAL';
- $this->cookieJar = new \GuzzleHttp\Cookie\CookieJar();
+ $this->cookieJar = new CookieJar();
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
@@ -174,7 +177,7 @@ trait BasicStructure {
try {
$this->response = $client->send($client->createRequest($verb, $fullUrl, $options));
- } catch (\GuzzleHttp\Exception\ClientException $ex) {
+ } catch (ClientException $ex) {
$this->response = $ex->getResponse();
}
}
@@ -204,7 +207,7 @@ trait BasicStructure {
try {
$this->response = $client->send($client->createRequest($verb, $fullUrl, $options));
- } catch (\GuzzleHttp\Exception\ClientException $ex) {
+ } catch (ClientException $ex) {
$this->response = $ex->getResponse();
}
}
@@ -298,7 +301,7 @@ trait BasicStructure {
$request->addHeader('requesttoken', $this->requestToken);
try {
$this->response = $client->send($request);
- } catch (\GuzzleHttp\Exception\ClientException $e) {
+ } catch (ClientException $e) {
$this->response = $e->getResponse();
}
}
@@ -321,7 +324,7 @@ trait BasicStructure {
);
try {
$this->response = $client->send($request);
- } catch (\GuzzleHttp\Exception\ClientException $e) {
+ } catch (ClientException $e) {
$this->response = $e->getResponse();
}
}