find accepted users

This commit is contained in:
Viktor Scharf
2024-07-08 15:16:21 +02:00
parent 1da065f50e
commit cac97c6067
4 changed files with 172 additions and 4 deletions

View File

@@ -91,7 +91,7 @@ class OcmHelper {
string $user,
string $password,
string $token,
string $providerDomain,
string $providerDomain
): ResponseInterface {
$body = [
"token" => $token,
@@ -107,4 +107,29 @@ class OcmHelper {
\json_encode($body)
);
}
/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function findAcceptedUsers(
string $baseUrl,
string $xRequestId,
string $user,
string $password
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'find-accepted-users');
return HttpRequestHelper::get(
$url,
$xRequestId,
$user,
$password,
self::getRequestHeaders()
);
}
}

View File

@@ -89,7 +89,7 @@ Feature: search federation users
"""
Scenario: sers search for federation users by email
Scenario: user search for federation users by email
Given using server "LOCAL"
And "Alice" has created the federation share invitation
And using server "REMOTE"
@@ -209,4 +209,120 @@ Feature: search federation users
"""
And using server "REMOTE"
Scenario: users search all federation users
Given using server "REMOTE"
And "Brian" has created the federation share invitation
And using server "LOCAL"
And "Alice" has accepted invitation
And "Carol" has accepted invitation
When "Alice" searches for accepted users
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"display_name",
"idp",
"user_id",
"mail"
],
"properties": {
"display_name": {
"type": "string",
"const": "Brian Murphy"
},
"idp": {
"type": "string",
"const": "federation-ocis-server"
},
"mail": {
"type": "string",
"pattern": "brian@example.org"
},
"user_id": {
"type": "string",
"pattern": "^%fed_invitation_token_pattern%$"
}
}
}
}
"""
When using server "REMOTE"
And "Brian" searches for accepted users
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "array",
"minItems": 2,
"maxItems": 2,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": [
"display_name",
"idp",
"user_id",
"mail"
],
"properties": {
"display_name": {
"type": "string",
"const": "Alice Hansen"
},
"idp": {
"type": "string",
"const": "https://ocis-server:9200"
},
"mail": {
"type": "string",
"pattern": "alice@example.org"
},
"user_id": {
"type": "string",
"pattern": "^%fed_invitation_token_pattern%$"
}
}
},
{
"type": "object",
"required": [
"display_name",
"idp",
"user_id",
"mail"
],
"properties": {
"display_name": {
"type": "string",
"const": "Carol King"
},
"idp": {
"type": "string",
"const": "https://ocis-server:9200"
},
"mail": {
"type": "string",
"pattern": "carol@example.org"
},
"user_id": {
"type": "string",
"pattern": "^%fed_invitation_token_pattern%$"
}
}
}
]
}
}
"""
# TODO try to find federation users after deleting federated conection

View File

@@ -1229,13 +1229,13 @@ class FeatureContext extends BehatVariablesContext {
}
/**
* @param object $json
* @param object|array $json
* @param object $schema
*
* @return void
* @throws Exception
*/
public function assertJsonDocumentMatchesSchema(object $json, object $schema): void {
public function assertJsonDocumentMatchesSchema(object|array $json, object $schema): void {
$schema = JsonSchema::import($schema);
$this->validateSchemaRequirements($schema);
$schema->in($json);

View File

@@ -176,4 +176,31 @@ class OcmContext implements Context {
$response = $this->acceptInvitation($user);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
}
/**
* @param string $user
*
* @return ResponseInterface
* @throws GuzzleException
*/
public function findAcceptedUsers(string $user): ResponseInterface {
return OcmHelper::findAcceptedUsers(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user)
);
}
/**
* @When :user searches for accepted users
*
* @param string $user
*
* @return void
* @throws GuzzleException
*/
public function userFindsAcceptedUsers(string $user): void {
$this->featureContext->setResponse($this->findAcceptedUsers($user));
}
}