test: check application/octet-stream MIME Type absence on /app/list endpoint

This commit is contained in:
pradip
2024-10-17 17:08:03 +05:45
committed by Niraj Acharya
parent 9ac104f32a
commit 1e412ba4b7
2 changed files with 38 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Gherkin\Node\TableNode;
use GuzzleHttp\Exception\GuzzleException;
use PHPUnit\Framework\Assert;
use TestHelpers\HttpRequestHelper;
use TestHelpers\WebDavHelper;
use TestHelpers\CollaborationHelper;
@@ -324,4 +325,34 @@ class CollaborationContext implements Context {
)
);
}
/**
* @Then /^the response (should|should not) contain the following MIME types:$/
*
* @param string $shouldOrNot
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function theFollowingMimeTypesShouldExistForUser(string $shouldOrNot, TableNode $table):void {
$rows = $table->getRows();
$responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['mime-types'];
$mimeTypes = \array_column($responseArray, 'mime_type');
foreach ($rows as $row) {
if ($shouldOrNot === "should not") {
Assert::assertFalse(
\in_array($row[0], $mimeTypes),
"the response should not contain the mimetype $row[0].\nMime Types found in response:\n"
. print_r($mimeTypes, true)
);
} else {
Assert::assertTrue(
\in_array($row[0], $mimeTypes),
"the response does not contain the mimetype $row[0].\nMime Types found in response:\n"
. print_r($mimeTypes, true)
);
}
}
}
}

View File

@@ -1855,3 +1855,10 @@ Feature: check file info with different wopi apps
| Collabora |
| FakeOffice |
| OnlyOffice |
@issue-10086
Scenario: check that '/app/list' doesn't contain 'application/octet-stream' MIME type
When user "Alice" sends HTTP method "GET" to URL "/app/list"
Then the HTTP status code should be "200"
And the response should not contain the following MIME types:
| application/octet-stream |