diff --git a/tests/TestHelpers/OcmHelper.php b/tests/TestHelpers/OcmHelper.php index 166200a09..d06fa8a66 100644 --- a/tests/TestHelpers/OcmHelper.php +++ b/tests/TestHelpers/OcmHelper.php @@ -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() + ); + } } diff --git a/tests/acceptance/features/apiOcm/searchFederationUsers.feature b/tests/acceptance/features/apiOcm/searchFederationUsers.feature index 097c0e212..a36fa52ec 100755 --- a/tests/acceptance/features/apiOcm/searchFederationUsers.feature +++ b/tests/acceptance/features/apiOcm/searchFederationUsers.feature @@ -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 \ No newline at end of file diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index d55888243..f1f792e87 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -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); diff --git a/tests/acceptance/features/bootstrap/OcmContext.php b/tests/acceptance/features/bootstrap/OcmContext.php index 417113483..b38ffba1a 100644 --- a/tests/acceptance/features/bootstrap/OcmContext.php +++ b/tests/acceptance/features/bootstrap/OcmContext.php @@ -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)); + } }