Compare commits
1 Commits
rakekniven
...
tests/beha
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b02e7fb25 |
@@ -1,12 +1,23 @@
|
||||
{
|
||||
"name": "nextcloud/deck-integration",
|
||||
"description": "Integration tests for the deck app",
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~6.5",
|
||||
"behat/behat": "~3.8.0",
|
||||
"guzzlehttp/guzzle": "6.5.2",
|
||||
"phpunit/phpunit": "^9",
|
||||
"behat/behat": "^3",
|
||||
"guzzlehttp/guzzle": "^7",
|
||||
"jarnaiz/behat-junit-formatter": "^1.3",
|
||||
"sabre/dav": "3.2.3",
|
||||
"symfony/event-dispatcher": "~4.4"
|
||||
"sabre/dav": "^4",
|
||||
"symfony/event-dispatcher": "~4.4",
|
||||
"juliushaertl/nextcloud-behat": "*"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"repositories": [
|
||||
{
|
||||
"type": "path",
|
||||
"url": "/home/jus/repos/nextcloud/nextcloud-behat"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"": [
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
default:
|
||||
autoload:
|
||||
'': '%paths.base%/../features/bootstrap'
|
||||
suites:
|
||||
test:
|
||||
paths:
|
||||
- '%paths.base%/../features/'
|
||||
contexts:
|
||||
- ServerContext:
|
||||
baseUrl: http://localhost:8080/
|
||||
- RequestContext
|
||||
- \JuliusHaertl\NextcloudBehat\Context\ServerContext:
|
||||
servers:
|
||||
default: http://localhost:8080
|
||||
- \JuliusHaertl\NextcloudBehat\Context\SharingContext
|
||||
- \JuliusHaertl\NextcloudBehat\Context\FilesContext
|
||||
- BoardContext
|
||||
- CommentContext
|
||||
- SearchContext
|
||||
- PendingContext
|
||||
|
||||
@@ -8,83 +8,83 @@ Feature: acl
|
||||
And user "user2" exists
|
||||
Given group "group0" exists
|
||||
And group "group1" exists
|
||||
Given user "user1" belongs to group "group1"
|
||||
Given user "user1" is member of group "group1"
|
||||
|
||||
Scenario: Fetch the board list
|
||||
Given Logging in using web as "user0"
|
||||
Given Using web as user "user0"
|
||||
When fetching the board list
|
||||
Then the response should have a status code "200"
|
||||
Then the HTTP status code should be "200"
|
||||
And the response Content-Type should be "application/json; charset=utf-8"
|
||||
|
||||
Scenario: Fetch board details of owned board
|
||||
Given Logging in using web as "admin"
|
||||
Given Using web as user "admin"
|
||||
And creates a board named "MyPrivateAdminBoard" with color "fafafa"
|
||||
When fetches the board named "MyPrivateAdminBoard"
|
||||
Then the response should have a status code "200"
|
||||
Then the HTTP status code should be "200"
|
||||
And the response Content-Type should be "application/json; charset=utf-8"
|
||||
|
||||
Scenario: Fetch board details of an other users board
|
||||
Given Logging in using web as "admin"
|
||||
Given Using web as user "admin"
|
||||
And creates a board named "MyPrivateAdminBoard" with color "ff0000"
|
||||
Given Logging in using web as "user0"
|
||||
Given Using web as user "user0"
|
||||
When fetches the board named "MyPrivateAdminBoard"
|
||||
Then the response should have a status code "403"
|
||||
Then the HTTP status code should be "403"
|
||||
And the response Content-Type should be "application/json; charset=utf-8"
|
||||
|
||||
Scenario: Share a board
|
||||
Given Logging in using web as "user0"
|
||||
Given Using web as user "user0"
|
||||
And creates a board named "Shared board" with color "ff0000"
|
||||
And shares the board with user "user1"
|
||||
| permissionEdit | 0 |
|
||||
| permissionShare | 0 |
|
||||
| permissionManage | 0 |
|
||||
And the response should have a status code 200
|
||||
And the HTTP status code should be 200
|
||||
And shares the board with user "user2"
|
||||
| permissionEdit | 1 |
|
||||
| permissionShare | 1 |
|
||||
| permissionManage | 1 |
|
||||
And the response should have a status code 200
|
||||
And the HTTP status code should be 200
|
||||
|
||||
Given Logging in using web as "user2"
|
||||
Given Using web as user "user2"
|
||||
When fetches the board named "Shared board"
|
||||
Then the current user should have "read" permissions on the board
|
||||
And the current user should have "edit" permissions on the board
|
||||
And the current user should have "share" permissions on the board
|
||||
And the current user should have "manage" permissions on the board
|
||||
And create a stack named "Stack"
|
||||
And the response should have a status code 200
|
||||
And the HTTP status code should be 200
|
||||
And create a card named "Test"
|
||||
And the response should have a status code 200
|
||||
And the HTTP status code should be 200
|
||||
|
||||
|
||||
Given Logging in using web as "user1"
|
||||
Given Using web as user "user1"
|
||||
When fetches the board named "Shared board"
|
||||
And create a card named "Test"
|
||||
And the response should have a status code 403
|
||||
And the HTTP status code should be 403
|
||||
Then the current user should have "read" permissions on the board
|
||||
And the current user should not have "edit" permissions on the board
|
||||
And the current user should not have "share" permissions on the board
|
||||
And the current user should not have "manage" permissions on the board
|
||||
And create a stack named "Stack"
|
||||
And the response should have a status code 403
|
||||
And the HTTP status code should be 403
|
||||
|
||||
|
||||
Scenario: Reshare a board
|
||||
Given Logging in using web as "user0"
|
||||
Given Using web as user "user0"
|
||||
And creates a board named "Reshared board" with color "ff0000"
|
||||
And shares the board with user "user1"
|
||||
| permissionEdit | 0 |
|
||||
| permissionShare | 1 |
|
||||
| permissionManage | 0 |
|
||||
And the response should have a status code 200
|
||||
Given Logging in using web as "user1"
|
||||
And the HTTP status code should be 200
|
||||
Given Using web as user "user1"
|
||||
When fetches the board named "Shared board"
|
||||
And shares the board with user "user2"
|
||||
| permissionEdit | 1 |
|
||||
| permissionShare | 1 |
|
||||
| permissionManage | 1 |
|
||||
And the response should have a status code 200
|
||||
Given Logging in using web as "user2"
|
||||
And the HTTP status code should be 200
|
||||
Given Using web as user "user2"
|
||||
When fetches the board named "Shared board"
|
||||
Then the current user should have "read" permissions on the board
|
||||
And the current user should not have "edit" permissions on the board
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
use Behat\Behat\Context\Context;
|
||||
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
use JuliusHaertl\NextcloudBehat\Context\ServerContext;
|
||||
use JuliusHaertl\NextcloudBehat\Context\SharingContext;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
class BoardContext implements Context {
|
||||
use RequestTrait;
|
||||
|
||||
/** @var array Last board response */
|
||||
private $board = null;
|
||||
@@ -19,12 +20,16 @@ class BoardContext implements Context {
|
||||
|
||||
/** @var ServerContext */
|
||||
private $serverContext;
|
||||
/** @var SharingContext */
|
||||
private $sharingContext;
|
||||
|
||||
/** @BeforeScenario */
|
||||
public function gatherContexts(BeforeScenarioScope $scope) {
|
||||
$environment = $scope->getEnvironment();
|
||||
|
||||
$this->serverContext = $environment->getContext('ServerContext');
|
||||
$this->serverContext = $environment->getContext(ServerContext::class);
|
||||
$this->sharingContext = $environment->getContext(SharingContext::class);
|
||||
|
||||
}
|
||||
|
||||
public function getLastUsedCard() {
|
||||
@@ -35,21 +40,21 @@ class BoardContext implements Context {
|
||||
* @Given /^creates a board named "([^"]*)" with color "([^"]*)"$/
|
||||
*/
|
||||
public function createsABoardNamedWithColor($title, $color) {
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/boards', [
|
||||
$this->serverContext->sendJSONrequest('POST', '/index.php/apps/deck/boards', [
|
||||
'title' => $title,
|
||||
'color' => $color
|
||||
]);
|
||||
$this->getResponse()->getBody()->seek(0);
|
||||
$this->board = json_decode((string)$this->getResponse()->getBody(), true);
|
||||
$this->serverContext->getResponse()->getBody()->seek(0);
|
||||
$this->board = json_decode((string)$this->serverContext->getResponse()->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^fetches the board named "([^"]*)"$/
|
||||
*/
|
||||
public function fetchesTheBoardNamed($boardName) {
|
||||
$this->requestContext->sendJSONrequest('GET', '/index.php/apps/deck/boards/' . $this->board['id'], []);
|
||||
$this->getResponse()->getBody()->seek(0);
|
||||
$this->board = json_decode((string)$this->getResponse()->getBody(), true);
|
||||
$this->serverContext->sendJSONrequest('GET', '/index.php/apps/deck/boards/' . $this->board['id'], []);
|
||||
$this->serverContext->getResponse()->getBody()->seek(0);
|
||||
$this->board = json_decode((string)$this->serverContext->getResponse()->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +68,7 @@ class BoardContext implements Context {
|
||||
];
|
||||
$tableRows = isset($permissions) ? $permissions->getRowsHash() : [];
|
||||
$result = array_merge($defaults, $tableRows);
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/boards/' . $this->board['id'] . '/acl', [
|
||||
$this->serverContext->sendJSONrequest('POST', '/index.php/apps/deck/boards/' . $this->board['id'] . '/acl', [
|
||||
'type' => 0,
|
||||
'participant' => $user,
|
||||
'permissionEdit' => $result['permissionEdit'] === '1',
|
||||
@@ -83,7 +88,7 @@ class BoardContext implements Context {
|
||||
];
|
||||
$tableRows = isset($permissions) ? $permissions->getRowsHash() : [];
|
||||
$result = array_merge($defaults, $tableRows);
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/boards/' . $this->board['id'] . '/acl', [
|
||||
$this->serverContext->sendJSONrequest('POST', '/index.php/apps/deck/boards/' . $this->board['id'] . '/acl', [
|
||||
'type' => 1,
|
||||
'participant' => $group,
|
||||
'permissionEdit' => $result['permissionEdit'] === '1',
|
||||
@@ -97,38 +102,38 @@ class BoardContext implements Context {
|
||||
* @When /^fetching the board list$/
|
||||
*/
|
||||
public function fetchingTheBoardList() {
|
||||
$this->requestContext->sendJSONrequest('GET', '/index.php/apps/deck/boards');
|
||||
$this->serverContext->sendJSONrequest('GET', '/index.php/apps/deck/boards');
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^fetching the board with id "([^"]*)"$/
|
||||
*/
|
||||
public function fetchingTheBoardWithId($id) {
|
||||
$this->requestContext->sendJSONrequest('GET', '/index.php/apps/deck/boards/' . $id);
|
||||
$this->serverContext->sendJSONrequest('GET', '/index.php/apps/deck/boards/' . $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^create a stack named "([^"]*)"$/
|
||||
*/
|
||||
public function createAStackNamed($name) {
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/stacks', [
|
||||
$this->serverContext->sendJSONrequest('POST', '/index.php/apps/deck/stacks', [
|
||||
'title' => $name,
|
||||
'boardId' => $this->board['id']
|
||||
]);
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$this->stack = json_decode((string)$this->getResponse()->getBody(), true);
|
||||
$this->serverContext->getResponse()->getBody()->seek(0);
|
||||
$this->stack = json_decode((string)$this->serverContext->getResponse()->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^create a card named "([^"]*)"$/
|
||||
*/
|
||||
public function createACardNamed($name) {
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/cards', [
|
||||
$this->serverContext->sendJSONrequest('POST', '/index.php/apps/deck/cards', [
|
||||
'title' => $name,
|
||||
'stackId' => $this->stack['id']
|
||||
]);
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$this->card = json_decode((string)$this->getResponse()->getBody(), true);
|
||||
$this->serverContext->getResponse()->getBody()->seek(0);
|
||||
$this->card = json_decode((string)$this->serverContext->getResponse()->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,31 +169,31 @@ class BoardContext implements Context {
|
||||
['shareType', 12],
|
||||
['shareWith', (string)$this->card['id']],
|
||||
]);
|
||||
$this->serverContext->creatingShare($table);
|
||||
$this->sharingContext->createAShareWith($table);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^set the description to "([^"]*)"$/
|
||||
*/
|
||||
public function setTheDescriptionTo($description) {
|
||||
$this->requestContext->sendJSONrequest('PUT', '/index.php/apps/deck/cards/' . $this->card['id'], array_merge(
|
||||
$this->serverContext->sendJSONrequest('PUT', '/index.php/apps/deck/cards/' . $this->card['id'], array_merge(
|
||||
$this->card,
|
||||
['description' => $description]
|
||||
));
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$this->card = json_decode((string)$this->getResponse()->getBody(), true);
|
||||
$this->serverContext->getResponse()->getBody()->seek(0);
|
||||
$this->card = json_decode((string)$this->serverContext->getResponse()->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^set the card attribute "([^"]*)" to "([^"]*)"$/
|
||||
*/
|
||||
public function setCardAttribute($attribute, $value) {
|
||||
$this->requestContext->sendJSONrequest('PUT', '/index.php/apps/deck/cards/' . $this->card['id'], array_merge(
|
||||
$this->serverContext->sendJSONrequest('PUT', '/index.php/apps/deck/cards/' . $this->card['id'], array_merge(
|
||||
$this->card,
|
||||
[$attribute => $value]
|
||||
));
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$this->card = json_decode((string)$this->getResponse()->getBody(), true);
|
||||
$this->serverContext->getResponse()->getBody()->seek(0);
|
||||
$this->card = json_decode((string)$this->serverContext->getResponse()->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,11 +219,11 @@ class BoardContext implements Context {
|
||||
}
|
||||
|
||||
private function assignToCard($participant, $type) {
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/cards/' . $this->card['id'] .'/assign', [
|
||||
$this->serverContext->sendJSONrequest('POST', '/index.php/apps/deck/cards/' . $this->card['id'] .'/assign', [
|
||||
'userId' => $participant,
|
||||
'type' => $type
|
||||
]);
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$this->serverContext->getResponse()->getBody()->seek(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +234,7 @@ class BoardContext implements Context {
|
||||
return $label['title'] === $tag;
|
||||
});
|
||||
$label = array_shift($filteredLabels);
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/cards/' . $this->card['id'] .'/label/' . $label['id']);
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$this->serverContext->sendJSONrequest('POST', '/index.php/apps/deck/cards/' . $this->card['id'] .'/label/' . $label['id']);
|
||||
$this->serverContext->getResponse()->getBody()->seek(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
|
||||
use JuliusHaertl\NextcloudBehat\Context\ServerContext;
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
class CommentContext implements Context {
|
||||
use RequestTrait;
|
||||
|
||||
/** @var ServerContext */
|
||||
protected $serverContext;
|
||||
/** @var BoardContext */
|
||||
protected $boardContext;
|
||||
|
||||
@@ -15,6 +17,7 @@ class CommentContext implements Context {
|
||||
public function gatherContexts(BeforeScenarioScope $scope) {
|
||||
$environment = $scope->getEnvironment();
|
||||
|
||||
$this->serverContext = $environment->getContext(ServerContext::class);
|
||||
$this->boardContext = $environment->getContext('BoardContext');
|
||||
}
|
||||
|
||||
@@ -23,7 +26,7 @@ class CommentContext implements Context {
|
||||
*/
|
||||
public function postACommentWithContentOnTheCard($content) {
|
||||
$card = $this->boardContext->getLastUsedCard();
|
||||
$this->requestContext->sendOCSRequest('POST', '/apps/deck/api/v1.0/cards/' . $card['id'] . '/comments', [
|
||||
$this->serverContext->sendOCSRequest('POST', '/apps/deck/api/v1.0/cards/' . $card['id'] . '/comments', [
|
||||
'message' => $content,
|
||||
'parentId' => null
|
||||
]);
|
||||
|
||||
@@ -21,26 +21,21 @@
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
|
||||
use Behat\Behat\Context\Context;
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
class PendingContext implements Context {
|
||||
|
||||
trait RequestTrait {
|
||||
|
||||
/** @var RequestContext */
|
||||
protected $requestContext;
|
||||
/** @var \JuliusHaertl\NextcloudBehat\Context\ServerContext */
|
||||
private $serverContext;
|
||||
|
||||
/** @BeforeScenario */
|
||||
public function gatherRequestTraitContext(BeforeScenarioScope $scope) {
|
||||
public function gatherContexts(BeforeScenarioScope $scope) {
|
||||
$environment = $scope->getEnvironment();
|
||||
$this->requestContext = $environment->getContext('RequestContext');
|
||||
|
||||
$this->serverContext = $environment->getContext(\JuliusHaertl\NextcloudBehat\Context\ServerContext::class);
|
||||
}
|
||||
|
||||
public function getResponse() {
|
||||
return $this->requestContext->getResponse();
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use Behat\Behat\Context\Context;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
class RequestContext implements Context {
|
||||
private $response;
|
||||
|
||||
/** @var ServerContext */
|
||||
private $serverContext;
|
||||
|
||||
/** @BeforeScenario */
|
||||
public function gatherContexts(BeforeScenarioScope $scope) {
|
||||
$environment = $scope->getEnvironment();
|
||||
|
||||
$this->serverContext = $environment->getContext('ServerContext');
|
||||
}
|
||||
|
||||
private function getBaseUrl() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the response should have a status code :code
|
||||
* @param string $code
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function theResponseShouldHaveStatusCode($code) {
|
||||
$currentCode = $this->response->getStatusCode();
|
||||
if ($currentCode !== (int)$code) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
'Expected %s as code got %s',
|
||||
$code,
|
||||
$currentCode
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the response Content-Type should be "([^"]*)"$/
|
||||
* @param string $contentType
|
||||
*/
|
||||
public function theResponseContentTypeShouldbe($contentType) {
|
||||
Assert::assertEquals($contentType, $this->response->getHeader('Content-Type')[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the response should be a JSON array with the following mandatory values
|
||||
* @param TableNode $table
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function theResponseShouldBeAJsonArrayWithTheFollowingMandatoryValues(TableNode $table) {
|
||||
$this->response->getBody()->seek(0);
|
||||
$expectedValues = $table->getColumnsHash();
|
||||
$realResponseArray = json_decode($this->response->getBody()->getContents(), true);
|
||||
foreach ($expectedValues as $value) {
|
||||
if ((string)$realResponseArray[$value['key']] !== (string)$value['value']) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
'Expected %s for key %s got %s',
|
||||
(string)$value['value'],
|
||||
$value['key'],
|
||||
(string)$realResponseArray[$value['key']]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the response should be a JSON array with a length of :length
|
||||
* @param int $length
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function theResponseShouldBeAJsonArrayWithALengthOf($length) {
|
||||
$this->response->getBody()->seek(0);
|
||||
$realResponseArray = json_decode($this->response->getBody()->getContents(), true);
|
||||
if ((int)count($realResponseArray) !== (int)$length) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
'Expected %d as length got %d',
|
||||
$length,
|
||||
count($realResponseArray)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendJSONrequest($method, $url, $data = []) {
|
||||
$client = new Client;
|
||||
try {
|
||||
$this->response = $client->request(
|
||||
$method,
|
||||
rtrim($this->serverContext->getBaseUrl(), '/') . '/' . ltrim($url, '/'),
|
||||
[
|
||||
'cookies' => $this->serverContext->getCookieJar(),
|
||||
'json' => $data,
|
||||
'headers' => [
|
||||
'requesttoken' => $this->serverContext->getReqestToken(),
|
||||
]
|
||||
]
|
||||
);
|
||||
} catch (ClientException $e) {
|
||||
$this->response = $e->getResponse();
|
||||
}
|
||||
}
|
||||
|
||||
public function sendOCSRequest($method, $url, $data = []) {
|
||||
$client = new Client;
|
||||
try {
|
||||
$this->response = $client->request(
|
||||
$method,
|
||||
rtrim($this->serverContext->getBaseUrl(), '/') . '/ocs/v2.php/' . ltrim($url, '/'),
|
||||
[
|
||||
'cookies' => $this->serverContext->getCookieJar(),
|
||||
'json' => $data,
|
||||
'headers' => [
|
||||
'requesttoken' => $this->serverContext->getReqestToken(),
|
||||
'OCS-APIREQUEST' => 'true',
|
||||
'Accept' => 'application/json'
|
||||
]
|
||||
]
|
||||
);
|
||||
} catch (ClientException $e) {
|
||||
$this->response = $e->getResponse();
|
||||
}
|
||||
}
|
||||
|
||||
public function getResponse(): ResponseInterface {
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,14 @@
|
||||
use Behat\Behat\Context\Context;
|
||||
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use JuliusHaertl\NextcloudBehat\Context\ServerContext;
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
class SearchContext implements Context {
|
||||
use RequestTrait;
|
||||
|
||||
/** @var ServerContext */
|
||||
protected $serverContext;
|
||||
/** @var BoardContext */
|
||||
protected $boardContext;
|
||||
|
||||
@@ -19,6 +21,7 @@ class SearchContext implements Context {
|
||||
public function gatherContexts(BeforeScenarioScope $scope) {
|
||||
$environment = $scope->getEnvironment();
|
||||
|
||||
$this->serverContext = $environment->getContext(ServerContext::class);
|
||||
$this->boardContext = $environment->getContext('BoardContext');
|
||||
}
|
||||
|
||||
@@ -27,10 +30,10 @@ class SearchContext implements Context {
|
||||
* @param string $term
|
||||
*/
|
||||
public function searchingFor(string $term) {
|
||||
$this->requestContext->sendOCSRequest('GET', '/apps/deck/api/v1.0/search?term=' . urlencode($term), []);
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$data = (string)$this->getResponse()->getBody();
|
||||
$this->searchResults = json_decode($data, true);
|
||||
$this->serverContext->sendOCSRequest('GET', '/apps/deck/api/v1.0/search?term=' . urlencode($term), []);
|
||||
$this->serverContext->getResponse()->getBody()->seek(0);
|
||||
$data = (string)$this->serverContext->getResponse()->getBody();
|
||||
$this->searchResults = json_decode($data, true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,9 +42,9 @@ class SearchContext implements Context {
|
||||
* https://cloud.nextcloud.com/ocs/v2.php/search/providers/talk-conversations/search?term=an&from=%2Fapps%2Fdashboard%2F
|
||||
*/
|
||||
public function searchingForComments(string $term) {
|
||||
$this->requestContext->sendOCSRequest('GET', '/search/providers/deck-comment/search?term=' . urlencode($term), []);
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$data = (string)$this->getResponse()->getBody();
|
||||
$this->serverContext->sendOCSRequest('GET', '/search/providers/deck-comment/search?term=' . urlencode($term), []);
|
||||
$this->serverContext->getResponse()->getBody()->seek(0);
|
||||
$data = (string)$this->serverContext->getResponse()->getBody();
|
||||
$this->unifiedSearchResult = json_decode($data, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
class ServerContext implements Context {
|
||||
use WebDav {
|
||||
WebDav::__construct as private __tConstruct;
|
||||
}
|
||||
|
||||
public function __construct($baseUrl) {
|
||||
$this->rawBaseUrl = $baseUrl;
|
||||
$this->__tConstruct($baseUrl . '/index.php/ocs/', ['admin', 'admin'], '123456');
|
||||
}
|
||||
|
||||
/** @var string */
|
||||
private $mappedUserId;
|
||||
|
||||
private $lastInsertIds = [];
|
||||
|
||||
/**
|
||||
* @BeforeSuite
|
||||
*/
|
||||
public static function addFilesToSkeleton() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^acting as user "([^"]*)"$/
|
||||
*/
|
||||
public function actingAsUser($user) {
|
||||
$this->cookieJar = new CookieJar();
|
||||
$this->loggingInUsingWebAs($user);
|
||||
$this->asAn($user);
|
||||
}
|
||||
|
||||
public function getBaseUrl(): string {
|
||||
return $this->rawBaseUrl;
|
||||
}
|
||||
|
||||
public function getCookieJar(): CookieJar {
|
||||
return $this->cookieJar;
|
||||
}
|
||||
|
||||
public function getReqestToken(): string {
|
||||
return $this->requestToken;
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,10 @@ Feature: decks
|
||||
Given user "user0" exists
|
||||
|
||||
Scenario: Create a new board
|
||||
Given Logging in using web as "admin"
|
||||
Given Using web as user "admin"
|
||||
When creates a board named "MyBoard" with color "000000"
|
||||
Then the response should have a status code "200"
|
||||
And the response Content-Type should be "application/json; charset=utf-8"
|
||||
Then the HTTP status code should be "200"
|
||||
And the Content-Type should be "application/json; charset=utf-8"
|
||||
And the response should be a JSON array with the following mandatory values
|
||||
|key|value|
|
||||
|title|MyBoard|
|
||||
|
||||
@@ -3,7 +3,7 @@ Feature: Searching for cards
|
||||
Background:
|
||||
Given user "admin" exists
|
||||
Given user "user0" exists
|
||||
Given Logging in using web as "admin"
|
||||
Given Using web as user "admin"
|
||||
When creates a board named "MyBoard" with color "000000"
|
||||
When create a stack named "ToDo"
|
||||
And create a card named "Example task 1"
|
||||
@@ -83,7 +83,7 @@ Feature: Searching for cards
|
||||
Then the card "Done task 2" is not found
|
||||
|
||||
Scenario: Search on shared boards
|
||||
Given Logging in using web as "user0"
|
||||
Given Using web as user "user0"
|
||||
When searching for "task"
|
||||
Then the card "Example task 1" is found
|
||||
Then the card "Example task 2" is found
|
||||
|
||||
@@ -19,12 +19,11 @@ Feature: File sharing
|
||||
And shares the board with user "user1"
|
||||
Then the HTTP status code should be "200"
|
||||
|
||||
Given using new dav path
|
||||
When User "user0" uploads file "../data/test.txt" to "/user0-file.txt"
|
||||
Then the HTTP status code should be "201"
|
||||
Given acting as user "user0"
|
||||
When share the file "/user0-file.txt" with the card
|
||||
Then the OCS status code should be "100"
|
||||
Then the OCS status code should be "200"
|
||||
And the HTTP status code should be "200"
|
||||
|
||||
And as "user1" the file "/Deck/user0-file.txt" exists
|
||||
@@ -40,12 +39,11 @@ Feature: File sharing
|
||||
| permissionManage | 1 |
|
||||
Then the HTTP status code should be "200"
|
||||
|
||||
Given using new dav path
|
||||
When User "user1" uploads file "../data/test.txt" to "/user1-file.txt"
|
||||
Then the HTTP status code should be "201"
|
||||
Given acting as user "user1"
|
||||
And share the file "/user1-file.txt" with the card
|
||||
Then the OCS status code should be "100"
|
||||
Then the OCS status code should be "200"
|
||||
And the HTTP status code should be "200"
|
||||
|
||||
And as "user0" the file "/Deck/user1-file.txt" exists
|
||||
@@ -59,13 +57,11 @@ Feature: File sharing
|
||||
And shares the board with user "user1"
|
||||
Then the HTTP status code should be "200"
|
||||
|
||||
Given using new dav path
|
||||
Given acting as user "user1"
|
||||
When User "user1" uploads file "../data/test.txt" to "/user1-file.txt"
|
||||
Then the HTTP status code should be "201"
|
||||
Given acting as user "user1"
|
||||
And share the file "/user1-file.txt" with the card
|
||||
When share the file "/user1-file.txt" with the card
|
||||
Then the OCS status code should be "404"
|
||||
And the HTTP status code should be "200"
|
||||
And as "user0" the file "/Deck/user1-file.txt" does not exist
|
||||
|
||||
Scenario: Share a file with a card by another user through a group
|
||||
@@ -76,12 +72,11 @@ Feature: File sharing
|
||||
And shares the board with group "group1"
|
||||
Then the HTTP status code should be "200"
|
||||
|
||||
Given using new dav path
|
||||
When User "user0" uploads file "../data/test.txt" to "/user0-file2.txt"
|
||||
Then the HTTP status code should be "201"
|
||||
Given acting as user "user0"
|
||||
When share the file "/user0-file2.txt" with the card
|
||||
Then the OCS status code should be "100"
|
||||
Then the OCS status code should be "200"
|
||||
And the HTTP status code should be "200"
|
||||
|
||||
And as "user2" the file "/Deck/user0-file2.txt" exists
|
||||
@@ -95,12 +90,11 @@ Feature: File sharing
|
||||
And shares the board with group "group1"
|
||||
Then the HTTP status code should be "200"
|
||||
|
||||
Given using new dav path
|
||||
When User "user0" uploads file "../data/test.txt" to "/user0-file2.txt"
|
||||
Then the HTTP status code should be "201"
|
||||
Given acting as user "user0"
|
||||
When share the file "/user0-file2.txt" with the card
|
||||
Then the OCS status code should be "100"
|
||||
Then the OCS status code should be "200"
|
||||
And the HTTP status code should be "200"
|
||||
|
||||
And as "user2" the file "/Deck/user0-file2.txt" exists
|
||||
@@ -119,12 +113,11 @@ Feature: File sharing
|
||||
And shares the board with group "group1"
|
||||
Then the HTTP status code should be "200"
|
||||
|
||||
Given using new dav path
|
||||
When User "user0" uploads file "../data/test.txt" to "/user0-file2.txt"
|
||||
Then the HTTP status code should be "201"
|
||||
Given acting as user "user0"
|
||||
When share the file "/user0-file2.txt" with the card
|
||||
Then the OCS status code should be "100"
|
||||
Then the OCS status code should be "200"
|
||||
And the HTTP status code should be "200"
|
||||
|
||||
And as "user2" the file "/Deck/user0-file2.txt" exists
|
||||
|
||||
@@ -5,11 +5,6 @@ OCC=${OC_PATH}occ
|
||||
SCENARIO_TO_RUN=$1
|
||||
HIDE_OC_LOGS=$2
|
||||
|
||||
# Nextcloud integration tests composer
|
||||
(
|
||||
cd ${OC_PATH}build/integration
|
||||
composer install
|
||||
)
|
||||
INSTALLED=$($OCC status | grep installed: | cut -d " " -f 5)
|
||||
|
||||
if [ "$INSTALLED" == "true" ]; then
|
||||
@@ -24,11 +19,11 @@ composer dump-autoload
|
||||
|
||||
# avoid port collision on jenkins - use $EXECUTOR_NUMBER
|
||||
if [ -z "$EXECUTOR_NUMBER" ]; then
|
||||
EXECUTOR_NUMBER=0
|
||||
EXECUTOR_NUMBER=1
|
||||
fi
|
||||
PORT=$((8080 + $EXECUTOR_NUMBER))
|
||||
echo $PORT
|
||||
php -S localhost:$PORT -t $OC_PATH &
|
||||
PHP_CLI_SERVER_WORKERS=10 php -S localhost:$PORT -t $OC_PATH &
|
||||
PHPPID=$!
|
||||
echo $PHPPID
|
||||
|
||||
|
||||
Reference in New Issue
Block a user