[tests-only][full-ci] test: backport fix flakiness in apiVault (#12864)
test: fix user mfa setup for vauld Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>
This commit is contained in:
1 parent
2eff54dcb2
commit
b623e7dbe7
7 files changed
+266
-239
No files matched your search
+1
-3
@@ -11,8 +11,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-simplexml": "*",
|
||||
"bamarni/composer-bin-plugin": "^1.8",
|
||||
"playwright-php/playwright": "^1.2"
|
||||
"bamarni/composer-bin-plugin": "^1.8"
|
||||
},
|
||||
"extra": {
|
||||
"bamarni-bin": {
|
||||
@@ -20,7 +19,6 @@
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"khanamiryan/qrcode-detector-decoder": "^2.0",
|
||||
"spomky-labs/otphp": "^11.5"
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,14 @@
|
||||
|
||||
namespace TestHelpers;
|
||||
|
||||
require_once __DIR__ . '/../../../vendor-php/autoload.php';
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
use JsonException;
|
||||
use OTPHP\TOTP;
|
||||
use ParagonIE\ConstantTime\Base32;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
@@ -45,6 +49,11 @@ class KeycloakHelper {
|
||||
'ocisGuest' => '7eedfa6d-a2d9-4296-b6db-e75e4e9c0963',
|
||||
'offline_access' => 'e2145b30-bf6f-49fb-af3f-1b40168bfcef',
|
||||
];
|
||||
// Longest known step sequence in getCode()'s MFA loop, with one spare step of headroom:
|
||||
// password POST -> TOTP setup form -> submit -> intermediate redirect -> GET-follow ->
|
||||
// OTP challenge form -> submit -> final redirect (7 steps), so 8 never truncates a real
|
||||
// flow while still bounding it against an infinite loop.
|
||||
private const MAX_MFA_FLOW_STEPS = 8;
|
||||
private static ?string $adminAccessToken = null;
|
||||
|
||||
/**
|
||||
@@ -293,10 +302,12 @@ class KeycloakHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $acrValues
|
||||
*
|
||||
* @return array
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public static function getAuthorizationEndPoint(): array {
|
||||
public static function getAuthorizationEndPoint(?string $acrValues = null): array {
|
||||
$loginParams = [
|
||||
'client_id' => 'web',
|
||||
'redirect_uri' => OcisHelper::getServerUrl() . '/oidc-callback.html',
|
||||
@@ -304,6 +315,9 @@ class KeycloakHelper {
|
||||
'response_type' => 'code',
|
||||
'scope' => 'openid profile email acr',
|
||||
];
|
||||
if ($acrValues !== null) {
|
||||
$loginParams['acr_values'] = $acrValues;
|
||||
}
|
||||
$queryString = \http_build_query($loginParams);
|
||||
$authUrl = self::getKeycloakUrl() . "/realms/oCIS/protocol/openid-connect/auth?" . $queryString;
|
||||
$response = HttpRequestHelper::get(
|
||||
@@ -325,9 +339,14 @@ class KeycloakHelper {
|
||||
*
|
||||
* @return string
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getCode(array $user, string $authorizationUrl, string $cookie): string {
|
||||
$authCodeResponse = HttpRequestHelper::post(
|
||||
public static function getCode(
|
||||
array $user,
|
||||
string $authorizationUrl,
|
||||
string $cookie,
|
||||
): string {
|
||||
$response = HttpRequestHelper::post(
|
||||
$authorizationUrl,
|
||||
null,
|
||||
null,
|
||||
@@ -339,9 +358,120 @@ class KeycloakHelper {
|
||||
'password' => $user['password'],
|
||||
],
|
||||
);
|
||||
$locationHeader = $authCodeResponse->getHeader('Location');
|
||||
$queryString = parse_url($locationHeader[0], PHP_URL_QUERY);
|
||||
parse_str($queryString, $urlParams);
|
||||
|
||||
// Whatever step-up Keycloak asks for next (first-time "configure TOTP", since this
|
||||
// user has no credential yet, or a login challenge against one that already exists) is
|
||||
// handled here purely over HTTP, mirroring what a browser driving the same flow would do.
|
||||
// Keycloak's required-action flow follows Post/Redirect/Get: after accepting a form
|
||||
// submission it redirects back to its own login-actions endpoint (to be GET-followed)
|
||||
// rather than straight to our redirect_uri, so a Location header alone doesn't mean the
|
||||
// flow is finished - only a redirect that actually targets redirect_uri does.
|
||||
$redirectUriPrefix = OcisHelper::getServerUrl() . '/oidc-callback.html';
|
||||
$stepsTaken = [];
|
||||
for ($i = 0; $i < self::MAX_MFA_FLOW_STEPS; $i++) {
|
||||
$locationHeader = $response->getHeader('Location');
|
||||
if (!empty($locationHeader)) {
|
||||
$location = $locationHeader[0];
|
||||
if (\str_starts_with($location, $redirectUriPrefix)) {
|
||||
return self::extractCodeFromLocationHeader($location);
|
||||
}
|
||||
$stepsTaken[] = 'redirect: ' . $location;
|
||||
$cookie = $response->getHeader('Set-Cookie')[0] ?? $cookie;
|
||||
$response = HttpRequestHelper::get($location, null, null, [ 'Cookie' => $cookie ]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$html = $response->getBody()->getContents();
|
||||
// Keycloak may rotate the session cookie at every step of the flow
|
||||
$cookie = $response->getHeader('Set-Cookie')[0] ?? $cookie;
|
||||
|
||||
if (\preg_match('/id="kc-totp-settings-form"/i', $html)) {
|
||||
$stepsTaken[] = 'kc-totp-settings-form';
|
||||
[$formUrl, $fields] = self::parseForm($html, 'kc-totp-settings-form');
|
||||
$rawSecret = $fields['totpSecret'] ?? null;
|
||||
if ($rawSecret === null) {
|
||||
throw new Exception('Could not find the "totpSecret" hidden field on the TOTP setup form.');
|
||||
}
|
||||
$knownTotpSecret = Base32::encodeUnpadded($rawSecret);
|
||||
$fields['totp'] = TOTP::createFromSecret($knownTotpSecret)->now();
|
||||
$fields['userLabel'] = 'test';
|
||||
} else {
|
||||
throw new Exception(
|
||||
'Unexpected response after username/password submission - no redirect, and '
|
||||
. 'neither a TOTP setup nor a TOTP login form was found. Status: '
|
||||
. $response->getStatusCode() . ', body: ' . $html,
|
||||
);
|
||||
}
|
||||
|
||||
$response = HttpRequestHelper::post($formUrl, null, null, [ 'Cookie' => $cookie ], $fields);
|
||||
}
|
||||
throw new Exception(
|
||||
'Too many MFA steps without reaching a redirect to redirect_uri. Steps taken: '
|
||||
. \implode(' -> ', $stepsTaken) . '. Last response status: ' . $response->getStatusCode()
|
||||
. ', body: ' . $response->getBody()->getContents(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the named form out of the given HTML, returning its action url and every field it
|
||||
* carries (name/value pairs from every <input>/<button>, including hidden ones such as
|
||||
* "credentialId" or "totpSecret") - a real browser submission sends all of them, and
|
||||
* Keycloak's authenticators can silently re-render the same form (200, no redirect) if a
|
||||
* required hidden field is missing from the submission.
|
||||
*
|
||||
* @param string $html
|
||||
* @param string $formId
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function parseForm(string $html, string $formId): array {
|
||||
// Capture the opening tag's attributes as one group so "id" and "action" can be pulled
|
||||
// out independent of which order Keycloak's template happens to render them in.
|
||||
if (!preg_match(
|
||||
'/<form\b([^>]*\bid="' . preg_quote($formId, '/') . '"[^>]*)>(.*?)<\/form>/is',
|
||||
$html,
|
||||
$formMatch,
|
||||
)
|
||||
) {
|
||||
throw new Exception("Could not find the \"$formId\" form in the HTML response body.");
|
||||
}
|
||||
$openingTagAttrs = $formMatch[1];
|
||||
$formBody = $formMatch[2];
|
||||
|
||||
if (!preg_match('/\baction="([^"]+)"/i', $openingTagAttrs, $actionMatch)) {
|
||||
throw new Exception("No action url found on the \"$formId\" form.");
|
||||
}
|
||||
$formUrl = \html_entity_decode($actionMatch[1]);
|
||||
|
||||
$fields = [];
|
||||
if (preg_match_all('/<(?:input|button)\b[^>]*>/i', $formBody, $fieldMatches)) {
|
||||
foreach ($fieldMatches[0] as $fieldTag) {
|
||||
if (!preg_match('/\bname="([^"]+)"/i', $fieldTag, $nameMatch)) {
|
||||
continue;
|
||||
}
|
||||
$value = '';
|
||||
if (preg_match('/\bvalue="([^"]*)"/i', $fieldTag, $valueMatch)) {
|
||||
$value = \html_entity_decode($valueMatch[1]);
|
||||
}
|
||||
$fields[$nameMatch[1]] = $value;
|
||||
}
|
||||
}
|
||||
return [$formUrl, $fields];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $location
|
||||
*
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function extractCodeFromLocationHeader(string $location): string {
|
||||
$queryString = parse_url($location, PHP_URL_QUERY);
|
||||
parse_str((string)$queryString, $urlParams);
|
||||
if (!isset($urlParams['code'])) {
|
||||
throw new Exception("No 'code' parameter found in redirect location: $location");
|
||||
}
|
||||
return $urlParams['code'];
|
||||
}
|
||||
|
||||
@@ -379,13 +509,18 @@ class KeycloakHelper {
|
||||
|
||||
/**
|
||||
* @param array $user
|
||||
* @param string|null $acrValues
|
||||
*
|
||||
* @return array
|
||||
* @throws GuzzleException
|
||||
* @throws JsonException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setAccessTokenForKeycloakOcisUser(array $user): array {
|
||||
[$authorizationUrl, $cookie] = self::getAuthorizationEndPoint();
|
||||
public static function setAccessTokenForKeycloakOcisUser(
|
||||
array $user,
|
||||
?string $acrValues = null,
|
||||
): array {
|
||||
[$authorizationUrl, $cookie] = self::getAuthorizationEndPoint($acrValues);
|
||||
$authorizationCode = self::getCode($user, $authorizationUrl, $cookie);
|
||||
$tokenResponse = self::getToken($authorizationCode);
|
||||
return json_decode($tokenResponse->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* ownCloud
|
||||
*
|
||||
* @author Prajwol Amatya <prajwol@jankaritech.com>
|
||||
* @copyright Copyright (c) 2022 Prajwol Amatya prajwol@jankaritech.com
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License,
|
||||
* as published by the Free Software Foundation;
|
||||
* either version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace TestHelpers;
|
||||
|
||||
require __DIR__ . '/../../../vendor-php/autoload.php';
|
||||
use Exception;
|
||||
use Playwright\Playwright;
|
||||
use Zxing\QrReader;
|
||||
use OTPHP\TOTP;
|
||||
|
||||
/**
|
||||
* A helper class for setting up user and store user access token using web UI
|
||||
*/
|
||||
class WebUIHelper {
|
||||
private static int $defaultTimeout = 5000;
|
||||
private static string $keycloakHeader = '#kc-header';
|
||||
private static string $usernameInput = '#username';
|
||||
private static string $passwordInput = '#password';
|
||||
private static string $loginButton = '#kc-login';
|
||||
private static string $filesView = '#files-view';
|
||||
private static string $modeSwitchButton = '#oc-topbar-mode-switch-btn';
|
||||
private static string $vaultModeSelector
|
||||
= "//button[contains(@class, 'oc-topbar-mode-switch-option')][.//span[text()='Vault']]";
|
||||
private static string $qrCode = '#kc-totp-secret-qr-code';
|
||||
private static string $totpInput = '#totp';
|
||||
private static string $userLabel = '#userLabel';
|
||||
private static string $saveTotpButton = '#saveTOTPBtn';
|
||||
|
||||
/**
|
||||
* @param string $ocisUrl
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setUpUser(string $ocisUrl, string $username, string $password): array {
|
||||
$context = Playwright::chromium(
|
||||
[
|
||||
'headless' => true,
|
||||
'args' => ['--ignore-certificate-errors', '--no-sandbox'],
|
||||
],
|
||||
);
|
||||
$screenshotPath = '/tmp/qr_' . uniqid() . '.png';
|
||||
try {
|
||||
$page = $context->newPage();
|
||||
$page->goto($ocisUrl, ['waitUntil' => 'networkidle']);
|
||||
$page->waitForSelector(self::$keycloakHeader, ['timeout' => self::$defaultTimeout]);
|
||||
$page->locator(self::$usernameInput)->fill($username);
|
||||
$page->locator(self::$passwordInput)->fill($password);
|
||||
$page->locator(self::$loginButton)->click();
|
||||
$page->waitForSelector(self::$filesView, ['timeout' => self::$defaultTimeout]);
|
||||
|
||||
// change to vault mode
|
||||
$page->locator(self::$modeSwitchButton)->click();
|
||||
$page->locator(self::$vaultModeSelector)->click();
|
||||
$page->waitForSelector(self::$qrCode, ['timeout' => self::$defaultTimeout]);
|
||||
$qrLocator = $page->locator(self::$qrCode);
|
||||
|
||||
// Wait until QR actually finished loading
|
||||
$page->waitForFunction(
|
||||
"(sel) => {\n" .
|
||||
" const img = document.querySelector(sel);\n" .
|
||||
" return img && img.complete && img.naturalWidth > 0;\n" .
|
||||
"}",
|
||||
self::$qrCode,
|
||||
['timeout' => self::$defaultTimeout],
|
||||
);
|
||||
|
||||
// setup mfa
|
||||
$qrLocator->screenshot($screenshotPath);
|
||||
if (!file_exists($screenshotPath)) {
|
||||
throw new Exception("Failed to save QR code screenshot to: " . $screenshotPath);
|
||||
}
|
||||
$otp = self::extractOtpFromQr($screenshotPath);
|
||||
$page->locator(self::$totpInput)->fill((string)$otp);
|
||||
$page->locator(self::$userLabel)->fill('test');
|
||||
$page->locator(self::$saveTotpButton)->click();
|
||||
$page->waitForSelector(self::$filesView, ['timeout' => self::$defaultTimeout]);
|
||||
return $context->storageState();
|
||||
} catch (\Exception $e) {
|
||||
throw new Exception("Login failed for user '$username': " . $e->getMessage(), 0, $e);
|
||||
} finally {
|
||||
if (file_exists($screenshotPath)) {
|
||||
unlink($screenshotPath);
|
||||
}
|
||||
$context->close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $imagePath
|
||||
*
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function extractOtpFromQr(string $imagePath): string {
|
||||
$qrReader = new QrReader($imagePath);
|
||||
$qrData = $qrReader->text();
|
||||
|
||||
if (empty($qrData)) {
|
||||
throw new Exception("Could not decode QR code from image: " . $imagePath);
|
||||
}
|
||||
|
||||
$parsedUrl = parse_url($qrData);
|
||||
if (!isset($parsedUrl['query'])) {
|
||||
throw new Exception("QR code data does not contain a valid otpauth URL: " . $qrData);
|
||||
}
|
||||
|
||||
parse_str($parsedUrl['query'], $queryParams);
|
||||
$secret = $queryParams['secret'] ?? null;
|
||||
|
||||
if ($secret === null) {
|
||||
throw new Exception("No 'secret' parameter found in QR code URL: " . $qrData);
|
||||
}
|
||||
|
||||
$totp = TOTP::createFromSecret($secret);
|
||||
|
||||
return $totp->now();
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ use TestHelpers\GraphHelper;
|
||||
use TestHelpers\KeycloakHelper;
|
||||
use Laminas\Ldap\Exception\LdapException;
|
||||
use Laminas\Ldap\Ldap;
|
||||
use TestHelpers\WebUIHelper;
|
||||
|
||||
/**
|
||||
* Functions for provisioning of users and groups
|
||||
@@ -48,6 +47,10 @@ trait Provisioning {
|
||||
private array $createdGroups = [];
|
||||
private array $userTokens = [];
|
||||
private array $createdKeycloakUsers = [];
|
||||
// the acr_values requested at Keycloak's authorize endpoint in userHasLoggedInViaWebUI();
|
||||
// override via setAcrValuesToRequest() in scenarios that reconfigure OCIS_MFA_AUTH_LEVEL_NAMES
|
||||
// to something other than the "advanced" default (see VaultContext)
|
||||
private string $acrValuesToRequest = 'advanced';
|
||||
|
||||
/**
|
||||
* @param array $user
|
||||
@@ -634,46 +637,24 @@ trait Provisioning {
|
||||
"email" => "admin@example.org",
|
||||
"actualUsername" => "admin",
|
||||
];
|
||||
$state = WebUIHelper::setUpUser(
|
||||
$this->getBaseUrl(),
|
||||
$adminUser["actualUsername"],
|
||||
$adminUser["password"],
|
||||
);
|
||||
$tokenData = \json_decode($state['origins'][0]['localStorage'][2]['value']);
|
||||
$tokenData = KeycloakHelper::setAccessTokenForKeycloakOcisUser($adminUser, $this->acrValuesToRequest);
|
||||
$this->setOcisUserToken($adminUser, $tokenData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up Keycloak user in oCIS
|
||||
* User is logged in via web UI and user access token is extracted
|
||||
*
|
||||
* @Given user :user has logged in via web UI
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $acrValues
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userHasLoggedInViaWebUI(string $user): void {
|
||||
$createdUsers = $this->getCreatedKeycloakUsers();
|
||||
$userAttribute = $createdUsers[strtolower($user)];
|
||||
$state = WebUIHelper::setUpUser(
|
||||
$this->getBaseUrl(),
|
||||
$userAttribute["actualUsername"],
|
||||
$userAttribute["password"],
|
||||
);
|
||||
$stateData = \json_decode($state['origins'][0]['localStorage'][2]['value']);
|
||||
$this->setOcisUserToken($userAttribute, $stateData);
|
||||
$response = $this->graphContext->adminHasRetrievedUserUsingTheGraphApi($user);
|
||||
$userAttribute['id'] = $this->getJsonDecodedResponse($response)['id'];
|
||||
$this->addUserToCreatedUsersList(
|
||||
$user,
|
||||
$userAttribute['password'],
|
||||
$userAttribute['displayName'],
|
||||
$userAttribute['email'],
|
||||
$userAttribute['id'],
|
||||
);
|
||||
public function setAcrValuesToRequest(string $acrValues): void {
|
||||
$this->acrValuesToRequest = $acrValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAcrValuesToRequest(): string {
|
||||
return $this->acrValuesToRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,8 @@ use Behat\Behat\Hook\Scope\BeforeScenarioScope;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use TestHelpers\BehatHelper;
|
||||
use TestHelpers\GraphHelper;
|
||||
use TestHelpers\HttpRequestHelper;
|
||||
use TestHelpers\KeycloakHelper;
|
||||
|
||||
require_once 'bootstrap.php';
|
||||
@@ -73,6 +75,10 @@ class VaultContext implements Context {
|
||||
$response->getStatusCode(),
|
||||
"Failed to update Keycloak realm attribute $key. Response: " . $response->getBody()->getContents(),
|
||||
);
|
||||
// Decode the JSON map
|
||||
$acrLoaMap = \json_decode($value, true);
|
||||
$acrValue = array_keys($acrLoaMap, "2");
|
||||
$this->featureContext->setAcrValuesToRequest($acrValue[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,4 +126,58 @@ class VaultContext implements Context {
|
||||
"Expected acr value to be $acr but got $actualAcr",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticates a Keycloak-backed user directly via the OIDC token endpoint (no browser,
|
||||
* no MFA/vault-mode UI setup) so that the user's oCIS account (and id) is provisioned even
|
||||
* for roles that don't have vault UI elements to interact with, e.g. User Light.
|
||||
*
|
||||
* @param string $user
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @throws JsonException
|
||||
* @throws Exception
|
||||
*/
|
||||
private function setUpKeycloakUserInOcis(string $user): void {
|
||||
if ($this->featureContext->getAttributeOfCreatedUser($user, 'id')) {
|
||||
return;
|
||||
}
|
||||
$userAttribute = $this->featureContext->getCreatedKeycloakUsers()[strtolower($user)];
|
||||
$tokenData = KeycloakHelper::setAccessTokenForKeycloakOcisUser(
|
||||
$userAttribute,
|
||||
$this->featureContext->getAcrValuesToRequest(),
|
||||
);
|
||||
$this->featureContext->setOcisUserToken($userAttribute, $tokenData);
|
||||
|
||||
$response = HttpRequestHelper::get(
|
||||
GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'me'),
|
||||
null,
|
||||
null,
|
||||
['Authorization' => 'Bearer ' . $tokenData['access_token']],
|
||||
);
|
||||
$userAttribute['id'] = $this->featureContext->getJsonDecodedResponse($response)['id'];
|
||||
$this->featureContext->addUserToCreatedUsersList(
|
||||
$user,
|
||||
$userAttribute['password'],
|
||||
$userAttribute['displayName'],
|
||||
$userAttribute['email'],
|
||||
$userAttribute['id'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up a Keycloak user in oCIS
|
||||
*
|
||||
* @Given user :user has been set up in oCIS
|
||||
*
|
||||
* @param string $user
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function userHasBeenSetUpInOcis(string $user): void {
|
||||
$this->setUpKeycloakUserInOcis($user);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: user can create folders and files in personal space in vault
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
When user "Alice" creates a folder "vaultFolder" in space "Personal" in vault using the WebDav Api
|
||||
Then the HTTP status code should be "201"
|
||||
When user "Alice" uploads a file inside space "Personal" with content "some content" to "vaultFile.txt" in vault using the WebDAV API
|
||||
@@ -23,7 +23,7 @@ Feature: vault
|
||||
|
||||
Scenario: user can create folders and files in project space in vault
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a space "vault-space" in vault with the default quota using the Graph API
|
||||
When user "Alice" creates a folder "vaultFolder" in space "vault-space" in vault using the WebDav Api
|
||||
Then the HTTP status code should be "201"
|
||||
@@ -35,7 +35,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: resources in drive and vault are isolated
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a folder "driveFolder" in space "Personal"
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "some content" to "driveFile.txt"
|
||||
And user "Alice" has created a folder "vaultFolder" in space "Personal" in vault
|
||||
@@ -58,7 +58,7 @@ Feature: vault
|
||||
Scenario: user can set custom auth level names
|
||||
Given the administrator has set the Keycloak realm attribute "acr.loa.map" to '{"regular":"1","testing":"2"}'
|
||||
And the config "OCIS_MFA_AUTH_LEVEL_NAMES" has been set to "testing"
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
When user "Alice" uploads a file inside space "Personal" with content "some content" to "vaultFile.txt" in vault using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And user "Alice" should have a JWT token with an ACR value "testing"
|
||||
@@ -66,7 +66,7 @@ Feature: vault
|
||||
|
||||
Scenario: check capabilities endpoint for vault
|
||||
Given using OCS API version "2"
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
When user "Alice" retrieves the vault mode capabilities using the capabilities API
|
||||
Then the OCS status code should be "200"
|
||||
And the HTTP status code should be "200"
|
||||
@@ -185,7 +185,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: user copies folder from drive to vault
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a folder "driveFolder" in space "Personal"
|
||||
When user "Alice" copies folder "driveFolder" from space "Personal" to "driveFolder" inside space "Personal" in vault using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
@@ -196,7 +196,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: user copies file from drive to vault
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "some content" to "testfile.txt"
|
||||
When user "Alice" copies file "testfile.txt" from space "Personal" to "testfile.txt" inside space "Personal" in vault using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
@@ -206,7 +206,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: user tries to copy folder from vault to drive
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a folder "vaultFolder" in space "Personal" in vault
|
||||
When user "Alice" copies folder "vaultFolder" from space "Personal" in vault to "vaultFolder" inside space "Personal" using the WebDAV API
|
||||
Then the HTTP status code should be "409"
|
||||
@@ -217,7 +217,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: user tries to copy file from vault to drive
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "some content" to "testfile.txt" in vault
|
||||
When user "Alice" copies file "testfile.txt" from space "Personal" in vault to "testfile.txt" inside space "Personal" using the WebDAV API
|
||||
Then the HTTP status code should be "409"
|
||||
@@ -228,7 +228,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: user copies sub-folder from drive to vault
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a folder "driveFolder" in space "Personal"
|
||||
And user "Alice" has created a folder "driveFolder/subFolder" in space "Personal"
|
||||
When user "Alice" copies folder "driveFolder/subFolder" from space "Personal" to "subFolder" inside space "Personal" in vault using the WebDAV API
|
||||
@@ -240,7 +240,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: user copies file inside folder from drive to vault
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a folder "driveFolder" in space "Personal"
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "some content" to "driveFolder/testfile.txt"
|
||||
When user "Alice" copies file "driveFolder/testfile.txt" from space "Personal" to "testfile.txt" inside space "Personal" in vault using the WebDAV API
|
||||
@@ -251,7 +251,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: user copies sub-folder from drive to a folder in vault
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a folder "driveFolder" in space "Personal"
|
||||
And user "Alice" has created a folder "driveFolder/subFolder" in space "Personal"
|
||||
And user "Alice" has created a folder "vaultFolder" in space "Personal" in vault
|
||||
@@ -264,7 +264,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: user copies file inside folder from drive to a folder in vault
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a folder "driveFolder" in space "Personal"
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "some content" to "driveFolder/testfile.txt"
|
||||
And user "Alice" has created a folder "vaultFolder" in space "Personal" in vault
|
||||
@@ -276,7 +276,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: user tries to create a public link of a folder inside vault
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a folder "vaultFolder" in space "Personal" in vault
|
||||
When user "Alice" creates the following resource link share using the Graph API:
|
||||
| resource | vaultFolder |
|
||||
@@ -315,7 +315,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: user tries to create a public link of a file inside vault
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "some content" to "testfile.txt" in vault
|
||||
When user "Alice" creates the following resource link share using the Graph API:
|
||||
| resource | testfile.txt |
|
||||
@@ -355,7 +355,7 @@ Feature: vault
|
||||
|
||||
Scenario: user tries to create a public link of a space root inside vault
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a space "vault-space" in vault with the default quota using the Graph API
|
||||
When user "Alice" tries to create the following space link share using permissions endpoint of the Graph API:
|
||||
| space | vault-space |
|
||||
@@ -394,9 +394,9 @@ Feature: vault
|
||||
|
||||
Scenario Outline: send share invitation for project space in vault to user with different roles (permissions endpoint)
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Brian" has been created with default attributes
|
||||
And user "Brian" has logged in via web UI
|
||||
And user "Brian" has been set up in oCIS
|
||||
And user "Alice" has created a space "new-space" in vault with the default quota using the Graph API
|
||||
When user "Alice" sends the following space share invitation using permissions endpoint of the Graph API:
|
||||
| space | new-space |
|
||||
@@ -472,9 +472,9 @@ Feature: vault
|
||||
|
||||
Scenario Outline: send share invitation for disabled project space in vault to user with different roles (permissions endpoint)
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Brian" has been created with default attributes
|
||||
And user "Brian" has logged in via web UI
|
||||
And user "Brian" has been set up in oCIS
|
||||
And user "Alice" has created a space "new-space" in vault with the default quota using the Graph API
|
||||
And user "Admin" has disabled a space "new-space" in vault
|
||||
When user "Alice" sends the following space share invitation using permissions endpoint of the Graph API:
|
||||
@@ -520,9 +520,9 @@ Feature: vault
|
||||
|
||||
Scenario Outline: send share invitation for deleted project space in vault to user with different roles (permissions endpoint)
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Brian" has been created with default attributes
|
||||
And user "Brian" has logged in via web UI
|
||||
And user "Brian" has been set up in oCIS
|
||||
And user "Alice" has created a space "new-space" in vault with the default quota using the Graph API
|
||||
And user "Admin" has disabled a space "new-space" in vault
|
||||
And user "Admin" has deleted a space "new-space" in vault
|
||||
@@ -567,9 +567,9 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario Outline: try to send share invitation for personal space in vault to user with different roles (permissions endpoint)
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Brian" has been created with default attributes
|
||||
And user "Brian" has logged in via web UI
|
||||
And user "Brian" has been set up in oCIS
|
||||
When user "Alice" sends the following space share invitation using permissions endpoint of the Graph API:
|
||||
| space | Personal |
|
||||
| sharee | Brian |
|
||||
@@ -613,9 +613,9 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario Outline: try to share Shares space in vault with a user (permissions endpoint)
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Brian" has been created with default attributes
|
||||
And user "Brian" has logged in via web UI
|
||||
And user "Brian" has been set up in oCIS
|
||||
When user "Alice" sends the following space share invitation using permissions endpoint of the Graph API:
|
||||
| space | Shares |
|
||||
| sharee | Brian |
|
||||
@@ -660,9 +660,9 @@ Feature: vault
|
||||
|
||||
Scenario Outline: invite user to a project space in vault with different roles using root endpoint
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Brian" has been created with default attributes
|
||||
And user "Brian" has logged in via web UI
|
||||
And user "Brian" has been set up in oCIS
|
||||
And user "Alice" has created a space "new-space" in vault with the default quota using the Graph API
|
||||
When user "Alice" sends the following space share invitation using root endpoint of the Graph API:
|
||||
| space | new-space |
|
||||
@@ -738,9 +738,9 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario Outline: try to invite user to personal drive in vault with different roles using root endpoint
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Brian" has been created with default attributes
|
||||
And user "Brian" has logged in via web UI
|
||||
And user "Brian" has been set up in oCIS
|
||||
When user "Alice" tries to send the following space share invitation using root endpoint of the Graph API:
|
||||
| space | Personal |
|
||||
| sharee | Brian |
|
||||
@@ -784,9 +784,9 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario Outline: try to invite user to Shares drive in vault with different roles using root endpoint
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Brian" has been created with default attributes
|
||||
And user "Brian" has logged in via web UI
|
||||
And user "Brian" has been set up in oCIS
|
||||
When user "Alice" tries to send the following space share invitation using root endpoint of the Graph API:
|
||||
| space | Shares |
|
||||
| sharee | Brian |
|
||||
@@ -830,7 +830,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: search results for resources in Personal space should be isolated between vault and drive
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a folder "testDriveFolder" in space "Personal"
|
||||
And user "Alice" has created a folder "testVaultFolder" in space "Personal" in vault
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "some content" to "testDriveFile.txt"
|
||||
@@ -850,7 +850,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: search results for resources inside folder with same name should be isolated between vault and drive
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a folder "newFolder" in space "Personal"
|
||||
And user "Alice" has created a folder "newFolder" in space "Personal" in vault
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "some content" to "newFolder/testDriveFile.txt"
|
||||
@@ -869,7 +869,7 @@ Feature: vault
|
||||
|
||||
Scenario: search result for resources inside project spaces with same name should be isolated between vault and drive
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a space "new-space" with the default quota using the Graph API
|
||||
And user "Alice" has created a space "new-space" in vault with the default quota using the Graph API
|
||||
And user "Alice" has created a folder "testDriveFolder" in space "new-space"
|
||||
@@ -891,7 +891,7 @@ Feature: vault
|
||||
|
||||
@tikaServiceNeeded
|
||||
Scenario: search result by content of file should be isolated between vault and drive
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "content of file in drive" to "testDriveFile.txt"
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "content of file in vault" to "testVaultFile.txt" in vault
|
||||
When user "Alice" searches for "Content:content" in vault using the WebDAV API
|
||||
@@ -908,7 +908,7 @@ Feature: vault
|
||||
@tikaServiceNeeded
|
||||
Scenario: search result by content of file inside project space should be isolated between vault and drive
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a space "new-space" with the default quota using the Graph API
|
||||
And user "Alice" has created a space "new-space" in vault with the default quota using the Graph API
|
||||
And user "Alice" has uploaded a file inside space "new-space" with content "content of file in drive" to "testDriveFile.txt"
|
||||
@@ -926,7 +926,7 @@ Feature: vault
|
||||
|
||||
|
||||
Scenario: search results by resource tags should be isolated between vault and drive
|
||||
Given user "Alice" has logged in via web UI
|
||||
Given user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a folder "driveFolder" in space "Personal"
|
||||
And user "Alice" has created a folder "vaultFolder" in space "Personal" in vault
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "some content" to "testDriveFile.txt"
|
||||
@@ -959,7 +959,7 @@ Feature: vault
|
||||
|
||||
Scenario: search results by resource tags inside project space should be isolated between vault and drive
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Alice" has created a space "new-space" with the default quota using the Graph API
|
||||
And user "Alice" has created a space "new-space" in vault with the default quota using the Graph API
|
||||
And user "Alice" has created a folder "driveFolder" in space "new-space"
|
||||
@@ -994,8 +994,8 @@ Feature: vault
|
||||
|
||||
Scenario Outline: folder share received from vault and drive personal space should be isolated
|
||||
Given user "Brian" has been created with default attributes
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Brian" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Brian" has been set up in oCIS
|
||||
And user "Alice" has created a folder "driveFolder" in space "Personal"
|
||||
And user "Alice" has created a folder "vaultFolder" in space "Personal" in vault
|
||||
And user "Alice" has sent the following resource share invitation:
|
||||
@@ -1028,8 +1028,8 @@ Feature: vault
|
||||
|
||||
Scenario Outline: file share received from vault and drive personal space should be isolated
|
||||
Given user "Brian" has been created with default attributes
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Brian" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Brian" has been set up in oCIS
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "some content" to "driveFile.txt"
|
||||
And user "Alice" has uploaded a file inside space "Personal" with content "some content" to "vaultFile.txt" in vault
|
||||
And user "Alice" has sent the following resource share invitation:
|
||||
@@ -1062,8 +1062,8 @@ Feature: vault
|
||||
Scenario Outline: folder share received from vault and drive project space should be isolated
|
||||
Given user "Brian" has been created with default attributes
|
||||
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Brian" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Brian" has been set up in oCIS
|
||||
And user "Alice" has created a space "new-space" with the default quota using the Graph API
|
||||
And user "Alice" has created a space "new-space" in vault with the default quota using the Graph API
|
||||
And user "Alice" has created a folder "driveFolder" in space "new-space"
|
||||
@@ -1099,8 +1099,8 @@ Feature: vault
|
||||
Scenario Outline: folder share received from vault and drive project space should be isolated
|
||||
Given user "Brian" has been created with default attributes
|
||||
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has logged in via web UI
|
||||
And user "Brian" has logged in via web UI
|
||||
And user "Alice" has been set up in oCIS
|
||||
And user "Brian" has been set up in oCIS
|
||||
And user "Alice" has created a space "new-space" with the default quota using the Graph API
|
||||
And user "Alice" has created a space "new-space" in vault with the default quota using the Graph API
|
||||
And user "Alice" has uploaded a file inside space "new-space" with content "some content" to "driveFile.txt"
|
||||
|
||||
@@ -506,12 +506,6 @@ def main() -> int:
|
||||
cfg["extraServerEnvironment"]["OCM_OCM_PROVIDER_AUTHORIZER_PROVIDERS_FILE"] = providers_tmp.name
|
||||
|
||||
if cfg["keycloakNeeded"]:
|
||||
# Install Playwright runtime and browsers (required for web UI tests)
|
||||
print("Installing Playwright...")
|
||||
run([str(repo_root / "vendor-php/bin/playwright-install")])
|
||||
run([str(repo_root / "vendor-php/bin/playwright-install"), "--browsers"])
|
||||
print("Playwright ready.")
|
||||
|
||||
# Generate TLS certs for keycloak
|
||||
print("Generating keycloak certs...")
|
||||
keycloak_certs_dir = repo_root / "keycloak-certs"
|
||||
|
||||
Reference in new issue
Block a user