Forward port json drill apispaces (#5818)
* Added json schema for response check in apiSpaces suite Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com> * Review Address * Added schema for space management feature * Added new schema asper change in master * fix feature file --------- Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>
This commit is contained in:
@@ -1576,15 +1576,16 @@ class FeatureContext extends BehatVariablesContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PyStringNode $schemaString
|
||||
* @param PyStringNode|string $schemaString
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function getJSONSchema(PyStringNode $schemaString) {
|
||||
$schemaRawString = $schemaString->getRaw();
|
||||
// substitute the inline codes or values
|
||||
$schemaRawString = $this->substituteInLineCodes($schemaRawString);
|
||||
$schema = json_decode($schemaRawString);
|
||||
public function getJSONSchema($schemaString) {
|
||||
if (\gettype($schemaString) !== 'string') {
|
||||
$schemaString = $schemaString->getRaw();
|
||||
}
|
||||
$schemaString = $this->substituteInLineCodes($schemaString);
|
||||
$schema = \json_decode($schemaString);
|
||||
Assert::assertNotNull($schema, 'schema is not valid JSON');
|
||||
return $schema;
|
||||
}
|
||||
@@ -1605,6 +1606,25 @@ class FeatureContext extends BehatVariablesContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the ocs JSON data of the response should match
|
||||
*
|
||||
* @param PyStringNode $schemaString
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theOcsDataOfTheResponseShouldMatch(
|
||||
PyStringNode $schemaString
|
||||
): void {
|
||||
$jsonResponse = $this->getJsonDecodedResponseBodyContent();
|
||||
JsonAssertions::assertJsonDocumentMatchesSchema(
|
||||
$jsonResponse->ocs->data,
|
||||
$this->getJSONSchema($schemaString)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the JSON data of the response should match
|
||||
*
|
||||
@@ -1614,12 +1634,10 @@ class FeatureContext extends BehatVariablesContext {
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theDataOfTheResponseShouldMatch(
|
||||
PyStringNode $schemaString
|
||||
): void {
|
||||
$jsonResponse = $this->getJsonDecodedResponseBodyContent();
|
||||
public function theDataOfTheResponseShouldMatch(PyStringNode $schemaString): void {
|
||||
$responseBody = $this->getJsonDecodedResponseBodyContent();
|
||||
JsonAssertions::assertJsonDocumentMatchesSchema(
|
||||
$jsonResponse->ocs->data,
|
||||
$responseBody,
|
||||
$this->getJSONSchema($schemaString)
|
||||
);
|
||||
}
|
||||
@@ -3204,16 +3222,26 @@ class FeatureContext extends BehatVariablesContext {
|
||||
"parameter" => []
|
||||
],
|
||||
[
|
||||
"code" => "%user_id%",
|
||||
"function" =>
|
||||
[$this, "getUserIdByUserName"],
|
||||
"parameter" => [$userName]
|
||||
"code" => "%group_id_pattern%",
|
||||
"function" => [
|
||||
__NAMESPACE__ . '\TestHelpers\GraphHelper',
|
||||
"getUUIDv4Regex"
|
||||
],
|
||||
"parameter" => []
|
||||
],
|
||||
[
|
||||
"code" => "%group_id%",
|
||||
"function" =>
|
||||
[$this, "getGroupIdByGroupName"],
|
||||
"parameter" => [$group]
|
||||
"code" => "%user_id%",
|
||||
"function" => [
|
||||
$this, "getUserIdByUserName"
|
||||
],
|
||||
"parameter" => [$userName]
|
||||
],
|
||||
[
|
||||
"code" => "%group_id%",
|
||||
"function" => [
|
||||
$this, "getGroupIdByGroupName"
|
||||
],
|
||||
"parameter" => [$group]
|
||||
]
|
||||
];
|
||||
if ($user !== null) {
|
||||
|
||||
Reference in New Issue
Block a user