Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXheni Myrtaj <myrtajxheni@gmail.com>2019-05-29 23:19:41 +0300
committerXheni Myrtaj <myrtajxheni@gmail.com>2019-07-04 11:35:36 +0300
commit9211e34aecb726b3c26e46a9fc93304903de3efc (patch)
tree25d4bf47ebf942228008c0ad01a613479f9eb1bb /tests/lib/IntegrityCheck
parent1d434cbac62d2734fe88093a0e32c50da68711e1 (diff)
Added Tests for modified mimetypelist
Signed-off-by: Xheni Myrtaj <myrtajxheni@gmail.com>
Diffstat (limited to 'tests/lib/IntegrityCheck')
-rw-r--r--tests/lib/IntegrityCheck/CheckerTest.php261
1 files changed, 258 insertions, 3 deletions
diff --git a/tests/lib/IntegrityCheck/CheckerTest.php b/tests/lib/IntegrityCheck/CheckerTest.php
index f9695323b39..7f67f405ac7 100644
--- a/tests/lib/IntegrityCheck/CheckerTest.php
+++ b/tests/lib/IntegrityCheck/CheckerTest.php
@@ -32,7 +32,6 @@ use OC\IntegrityCheck\Helpers\AppLocator;
use OCP\IConfig;
use OCP\ICacheFactory;
use OCP\App\IAppManager;
-use OCP\Files\IMimeTypeDetector;
class CheckerTest extends TestCase {
/** @var EnvironmentHelper|\PHPUnit_Framework_MockObject_MockObject */
@@ -49,7 +48,7 @@ class CheckerTest extends TestCase {
private $cacheFactory;
/** @var IAppManager|\PHPUnit_Framework_MockObject_MockObject */
private $appManager;
- /** @var IMimeTypeDetector|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OC\Files\Type\Detection|\PHPUnit_Framework_MockObject_MockObject */
private $mimeTypeDetector;
public function setUp() {
@@ -60,7 +59,7 @@ class CheckerTest extends TestCase {
$this->config = $this->createMock(IConfig::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->appManager = $this->createMock(IAppManager::class);
- $this->mimeTypeDetector = $this->createMock(IMimeTypeDetector::class);
+ $this->mimeTypeDetector = $this->createMock(\OC\Files\Type\Detection::class);
$this->config->method('getAppValue')
->will($this->returnArgument(2));
@@ -766,6 +765,262 @@ class CheckerTest extends TestCase {
$this->assertSame([], $this->checker->verifyCoreSignature());
}
+ public function testVerifyCoreSignatureWithModifiedMimetypelistSignatureData() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
+ $this->mimeTypeDetector
+ ->expects($this->once())
+ ->method('getOnlyDefaultAliases')
+ ->willReturn(
+ array (
+ '_comment' => 'Array of mimetype aliases.',
+ '_comment2' => 'Any changes you make here will be overwritten on an update of Nextcloud.',
+ '_comment3' => 'Put any custom mappings in a new file mimetypealiases.json in the config/ folder of Nextcloud',
+ '_comment4' => 'After any change to mimetypealiases.json run:',
+ '_comment5' => './occ maintenance:mimetype:update-js',
+ '_comment6' => 'Otherwise your update won\'t propagate through the system.',
+ 'application/coreldraw' => 'image',
+ 'application/epub+zip' => 'text',
+ 'application/font-sfnt' => 'image',
+ 'application/font-woff' => 'image',
+ 'application/gpx+xml' => 'location',
+ 'application/illustrator' => 'image',
+ 'application/javascript' => 'text/code',
+ 'application/json' => 'text/code',
+ 'application/msaccess' => 'file',
+ 'application/msexcel' => 'x-office/spreadsheet',
+ 'application/msonenote' => 'x-office/document',
+ 'application/mspowerpoint' => 'x-office/presentation',
+ 'application/msword' => 'x-office/document',
+ 'application/octet-stream' => 'file',
+ 'application/postscript' => 'image',
+ 'application/rss+xml' => 'application/xml',
+ 'application/vnd.android.package-archive' => 'package/x-generic',
+ 'application/vnd.lotus-wordpro' => 'x-office/document',
+ 'application/vnd.garmin.tcx+xml' => 'location',
+ 'application/vnd.google-earth.kml+xml' => 'location',
+ 'application/vnd.google-earth.kmz' => 'location',
+ 'application/vnd.ms-excel' => 'x-office/spreadsheet',
+ 'application/vnd.ms-excel.addin.macroEnabled.12' => 'x-office/spreadsheet',
+ 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => 'x-office/spreadsheet',
+ 'application/vnd.ms-excel.sheet.macroEnabled.12' => 'x-office/spreadsheet',
+ 'application/vnd.ms-excel.template.macroEnabled.12' => 'x-office/spreadsheet',
+ 'application/vnd.ms-fontobject' => 'image',
+ 'application/vnd.ms-powerpoint' => 'x-office/presentation',
+ 'application/vnd.ms-powerpoint.addin.macroEnabled.12' => 'x-office/presentation',
+ 'application/vnd.ms-powerpoint.presentation.macroEnabled.12' => 'x-office/presentation',
+ 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => 'x-office/presentation',
+ 'application/vnd.ms-powerpoint.template.macroEnabled.12' => 'x-office/presentation',
+ 'application/vnd.ms-visio.drawing.macroEnabled.12' => 'application/vnd.visio',
+ 'application/vnd.ms-visio.drawing' => 'application/vnd.visio',
+ 'application/vnd.ms-visio.stencil.macroEnabled.12' => 'application/vnd.visio',
+ 'application/vnd.ms-visio.stencil' => 'application/vnd.visio',
+ 'application/vnd.ms-visio.template.macroEnabled.12' => 'application/vnd.visio',
+ 'application/vnd.ms-visio.template' => 'application/vnd.visio',
+ 'application/vnd.ms-word.document.macroEnabled.12' => 'x-office/document',
+ 'application/vnd.ms-word.template.macroEnabled.12' => 'x-office/document',
+ 'application/vnd.oasis.opendocument.presentation' => 'x-office/presentation',
+ 'application/vnd.oasis.opendocument.presentation-template' => 'x-office/presentation',
+ 'application/vnd.oasis.opendocument.spreadsheet' => 'x-office/spreadsheet',
+ 'application/vnd.oasis.opendocument.spreadsheet-template' => 'x-office/spreadsheet',
+ 'application/vnd.oasis.opendocument.text' => 'x-office/document',
+ 'application/vnd.oasis.opendocument.text-master' => 'x-office/document',
+ 'application/vnd.oasis.opendocument.text-template' => 'x-office/document',
+ 'application/vnd.oasis.opendocument.text-web' => 'x-office/document',
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'x-office/presentation',
+ 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'x-office/presentation',
+ 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'x-office/presentation',
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'x-office/spreadsheet',
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'x-office/spreadsheet',
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'x-office/document',
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'x-office/document',
+ 'application/vnd.visio' => 'x-office/document',
+ 'application/vnd.wordperfect' => 'x-office/document',
+ 'application/x-7z-compressed' => 'package/x-generic',
+ 'application/x-bzip2' => 'package/x-generic',
+ 'application/x-cbr' => 'text',
+ 'application/x-compressed' => 'package/x-generic',
+ 'application/x-dcraw' => 'image',
+ 'application/x-deb' => 'package/x-generic',
+ 'application/x-fictionbook+xml' => 'text',
+ 'application/x-font' => 'image',
+ 'application/x-gimp' => 'image',
+ 'application/x-gzip' => 'package/x-generic',
+ 'application/x-iwork-keynote-sffkey' => 'x-office/presentation',
+ 'application/x-iwork-numbers-sffnumbers' => 'x-office/spreadsheet',
+ 'application/x-iwork-pages-sffpages' => 'x-office/document',
+ 'application/x-mobipocket-ebook' => 'text',
+ 'application/x-perl' => 'text/code',
+ 'application/x-photoshop' => 'image',
+ 'application/x-php' => 'text/code',
+ 'application/x-rar-compressed' => 'package/x-generic',
+ 'application/x-tar' => 'package/x-generic',
+ 'application/x-tex' => 'text',
+ 'application/xml' => 'text/html',
+ 'application/yaml' => 'text/code',
+ 'application/zip' => 'package/x-generic',
+ 'database' => 'file',
+ 'httpd/unix-directory' => 'dir',
+ 'text/css' => 'text/code',
+ 'text/csv' => 'x-office/spreadsheet',
+ 'text/html' => 'text/code',
+ 'text/x-c' => 'text/code',
+ 'text/x-c++src' => 'text/code',
+ 'text/x-h' => 'text/code',
+ 'text/x-java-source' => 'text/code',
+ 'text/x-ldif' => 'text/code',
+ 'text/x-python' => 'text/code',
+ 'text/x-shellscript' => 'text/code',
+ 'web' => 'text/code',
+ 'application/internet-shortcut' => 'link',
+ ));
+
+ $this->mimeTypeDetector
+ ->expects($this->once())
+ ->method('getAllAliases')
+ ->willReturn(
+ array (
+ '_comment' => 'Array of mimetype aliases.',
+ '_comment2' => 'Any changes you make here will be overwritten on an update of Nextcloud.',
+ '_comment3' => 'Put any custom mappings in a new file mimetypealiases.json in the config/ folder of Nextcloud',
+ '_comment4' => 'After any change to mimetypealiases.json run:',
+ '_comment5' => './occ maintenance:mimetype:update-js',
+ '_comment6' => 'Otherwise your update won\'t propagate through the system.',
+ 'application/coreldraw' => 'image',
+ 'application/test' => 'image',
+ 'application/epub+zip' => 'text',
+ 'application/font-sfnt' => 'image',
+ 'application/font-woff' => 'image',
+ 'application/gpx+xml' => 'location',
+ 'application/illustrator' => 'image',
+ 'application/javascript' => 'text/code',
+ 'application/json' => 'text/code',
+ 'application/msaccess' => 'file',
+ 'application/msexcel' => 'x-office/spreadsheet',
+ 'application/msonenote' => 'x-office/document',
+ 'application/mspowerpoint' => 'x-office/presentation',
+ 'application/msword' => 'x-office/document',
+ 'application/octet-stream' => 'file',
+ 'application/postscript' => 'image',
+ 'application/rss+xml' => 'application/xml',
+ 'application/vnd.android.package-archive' => 'package/x-generic',
+ 'application/vnd.lotus-wordpro' => 'x-office/document',
+ 'application/vnd.garmin.tcx+xml' => 'location',
+ 'application/vnd.google-earth.kml+xml' => 'location',
+ 'application/vnd.google-earth.kmz' => 'location',
+ 'application/vnd.ms-excel' => 'x-office/spreadsheet',
+ 'application/vnd.ms-excel.addin.macroEnabled.12' => 'x-office/spreadsheet',
+ 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => 'x-office/spreadsheet',
+ 'application/vnd.ms-excel.sheet.macroEnabled.12' => 'x-office/spreadsheet',
+ 'application/vnd.ms-excel.template.macroEnabled.12' => 'x-office/spreadsheet',
+ 'application/vnd.ms-fontobject' => 'image',
+ 'application/vnd.ms-powerpoint' => 'x-office/presentation',
+ 'application/vnd.ms-powerpoint.addin.macroEnabled.12' => 'x-office/presentation',
+ 'application/vnd.ms-powerpoint.presentation.macroEnabled.12' => 'x-office/presentation',
+ 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => 'x-office/presentation',
+ 'application/vnd.ms-powerpoint.template.macroEnabled.12' => 'x-office/presentation',
+ 'application/vnd.ms-visio.drawing.macroEnabled.12' => 'application/vnd.visio',
+ 'application/vnd.ms-visio.drawing' => 'application/vnd.visio',
+ 'application/vnd.ms-visio.stencil.macroEnabled.12' => 'application/vnd.visio',
+ 'application/vnd.ms-visio.stencil' => 'application/vnd.visio',
+ 'application/vnd.ms-visio.template.macroEnabled.12' => 'application/vnd.visio',
+ 'application/vnd.ms-visio.template' => 'application/vnd.visio',
+ 'application/vnd.ms-word.document.macroEnabled.12' => 'x-office/document',
+ 'application/vnd.ms-word.template.macroEnabled.12' => 'x-office/document',
+ 'application/vnd.oasis.opendocument.presentation' => 'x-office/presentation',
+ 'application/vnd.oasis.opendocument.presentation-template' => 'x-office/presentation',
+ 'application/vnd.oasis.opendocument.spreadsheet' => 'x-office/spreadsheet',
+ 'application/vnd.oasis.opendocument.spreadsheet-template' => 'x-office/spreadsheet',
+ 'application/vnd.oasis.opendocument.text' => 'x-office/document',
+ 'application/vnd.oasis.opendocument.text-master' => 'x-office/document',
+ 'application/vnd.oasis.opendocument.text-template' => 'x-office/document',
+ 'application/vnd.oasis.opendocument.text-web' => 'x-office/document',
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'x-office/presentation',
+ 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'x-office/presentation',
+ 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'x-office/presentation',
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'x-office/spreadsheet',
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'x-office/spreadsheet',
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'x-office/document',
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'x-office/document',
+ 'application/vnd.visio' => 'x-office/document',
+ 'application/vnd.wordperfect' => 'x-office/document',
+ 'application/x-7z-compressed' => 'package/x-generic',
+ 'application/x-bzip2' => 'package/x-generic',
+ 'application/x-cbr' => 'text',
+ 'application/x-compressed' => 'package/x-generic',
+ 'application/x-dcraw' => 'image',
+ 'application/x-deb' => 'package/x-generic',
+ 'application/x-fictionbook+xml' => 'text',
+ 'application/x-font' => 'image',
+ 'application/x-gimp' => 'image',
+ 'application/x-gzip' => 'package/x-generic',
+ 'application/x-iwork-keynote-sffkey' => 'x-office/presentation',
+ 'application/x-iwork-numbers-sffnumbers' => 'x-office/spreadsheet',
+ 'application/x-iwork-pages-sffpages' => 'x-office/document',
+ 'application/x-mobipocket-ebook' => 'text',
+ 'application/x-perl' => 'text/code',
+ 'application/x-photoshop' => 'image',
+ 'application/x-php' => 'text/code',
+ 'application/x-rar-compressed' => 'package/x-generic',
+ 'application/x-tar' => 'package/x-generic',
+ 'application/x-tex' => 'text',
+ 'application/xml' => 'text/html',
+ 'application/yaml' => 'text/code',
+ 'application/zip' => 'package/x-generic',
+ 'database' => 'file',
+ 'httpd/unix-directory' => 'dir',
+ 'text/css' => 'text/code',
+ 'text/csv' => 'x-office/spreadsheet',
+ 'text/html' => 'text/code',
+ 'text/x-c' => 'text/code',
+ 'text/x-c++src' => 'text/code',
+ 'text/x-h' => 'text/code',
+ 'text/x-java-source' => 'text/code',
+ 'text/x-ldif' => 'text/code',
+ 'text/x-python' => 'text/code',
+ 'text/x-shellscript' => 'text/code',
+ 'web' => 'text/code',
+ 'application/internet-shortcut' => 'link',
+ ));
+
+ $this->environmentHelper
+ ->expects($this->any())
+ ->method('getServerRoot')
+ ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/mimetypeListModified'));
+ $signatureDataFile = '{
+ "hashes": {
+ "mimetypelist.js": "dc48de7ad4baa030c5e563350c9a80b274bad783f6f5adbf1595ecef6c6a32e52890a24cb26cddb0aa20193ba52c001150c68d8bfb567f0aed566f4029a190a3"
+ },
+ "signature": "dtNDyufRB1jOG3e\/\/Ng6O3ZPnX5wgt3rrD9SpRQ66cpWlixwvGaI6knH85MkWm3q1c+hTYBipJ\/o+nJxHWoxydMXm+F6mC5MvXWfESB\/ag4fvKe0fg25yKstzlrpIyWwcnmOhLE\/sd7D8LZOQXk72PXsIJw4vX2YPyf3peHLevlUkVhB+mfYGDQJfrtPHjJII0Do+TV2MA0qm42q7SO\/zf7Ly24nZP3AoY5bYDMewlrczS2xz9tMN2ikZZcDgHvmC2W4RkaFP9E8ZeAZphKVjyQn6HdSu7EDlJgJ1YtoqTetFzNy\/q7+ODiJDB0KUzKocEDcXF2n2cTKXKCrklB6tEhEnjADhhQNxQouq2soc0ouIujifyH2zBL0sawNxGje5wpuchhCPnWcvQnSJbK1oXnv\/0wSGsp0iSslvx9NXAZ+nQbJnIuodLBl7XuTxxPVa8jDwFdJ7mLrs79ZfN2Op4qF10PiFRoz5VztJm4KWcaWnm\/Xqxke\/6yxY+gU2c6aH\/plwzkcxhdDJjNI\/d+G+b6NSadfcrduO+gTeHK\/go68mx0k1XxCln4Qu31nPmJZcboTvAtHvHXoeqZVAzMpT+jrq+vZ3oVAvFfNpvH4CA3eZebfkV13wV4RaSETyz5QNbnBL24C26aAhkzdShKHJc4NSNV9XdFqN74XEzSZGoc=",
+ "certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEvjCCAqagAwIBAgIUc\/0FxYrsgSs9rDxp03EJmbjN0NwwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIxMDMzM1oXDTE2MTEwMzIxMDMzM1owDzENMAsGA1UEAwwEY29yZTCCAiIwDQYJ\r\nKoZIhvcNAQEBBQADggIPADCCAgoCggIBALb6EgHpkAqZbO5vRO8XSh7G7XGWHw5s\r\niOf4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sOsDOu\/tpnaRWlvv5ib4+SzG5wWFT5UUEo4Wg2STQiiX\r\nuVSRQxK1LE1yg84bs3NZk9FSQh4B8vZVuRr5FaJsZZkwlFlhRO\/\/+TJtXRbyNgsf\r\noMRZGi8DLGU2SGEAHcRH\/QZHq\/XDUWVzdxrSBYcy7GSpT7UDVzGv1rEJUrn5veP1\r\n0KmauAqtiIaYRm4f6YBsn0INcZxzIPZ0p8qFtVZBPeHhvQtvOt0iXI\/XUxEWOa2F\r\nK2EqhErgMK\/N07U1JJJay5tYZRtvkGq46oP\/5kQG8hYST0MDK6VihJoPpvCmAm4E\r\npEYKQ96x6A4EH9Y9mZlYozH\/eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
+}';
+ $this->fileAccessHelper
+ ->expects($this->at(0))
+ ->method('file_get_contents')
+ ->with(
+ \OC::$SERVERROOT . '/tests/data/integritycheck/mimetypeListModified/core/signature.json'
+ )
+ ->will($this->returnValue($signatureDataFile));
+ $this->fileAccessHelper
+ ->expects($this->at(1))
+ ->method('file_get_contents')
+ ->with(
+ \OC::$SERVERROOT . '/tests/data/integritycheck/mimetypeListModified/resources/codesigning/root.crt'
+ )
+ ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')));
+
+ $this->assertSame([], $this->checker->verifyCoreSignature());
+
+ }
+
public function testVerifyCoreSignatureWithValidSignatureDataAndNotAlphabeticOrder() {
$this->environmentHelper
->expects($this->once())