summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-01-22 13:13:41 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-01-22 13:13:41 +0100
commite3013a99ef5e9c44ef4f0661a2fb450f89df8d05 (patch)
tree47700b141506059d12599a0300f0c1ced5eac736 /tests
parent969581cc6850f3323066059bcdcda2dc21d8b019 (diff)
parentea367b598a98f8889383c917ceb7a6deb0c6ab7f (diff)
downloadnextcloud-server-e3013a99ef5e9c44ef4f0661a2fb450f89df8d05.tar.gz
nextcloud-server-e3013a99ef5e9c44ef4f0661a2fb450f89df8d05.zip
Merge pull request #21816 from owncloud/require-a-specific-path-instead-of-autoguessing
Use path instead of app id for occ app signing
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/command/integrity/SignAppTest.php32
-rw-r--r--tests/lib/integritycheck/checkertest.php9
2 files changed, 21 insertions, 20 deletions
diff --git a/tests/lib/command/integrity/SignAppTest.php b/tests/lib/command/integrity/SignAppTest.php
index b7c34585c5c..44a644c45df 100644
--- a/tests/lib/command/integrity/SignAppTest.php
+++ b/tests/lib/command/integrity/SignAppTest.php
@@ -23,6 +23,7 @@ namespace Test\Command\Integrity;
use OC\Core\Command\Integrity\SignApp;
use OC\IntegrityCheck\Checker;
use OC\IntegrityCheck\Helpers\FileAccessHelper;
+use OCP\IURLGenerator;
use Test\TestCase;
class SignAppTest extends TestCase {
@@ -32,6 +33,8 @@ class SignAppTest extends TestCase {
private $signApp;
/** @var FileAccessHelper */
private $fileAccessHelper;
+ /** @var IURLGenerator */
+ private $urlGenerator;
public function setUp() {
parent::setUp();
@@ -39,20 +42,23 @@ class SignAppTest extends TestCase {
->disableOriginalConstructor()->getMock();
$this->fileAccessHelper = $this->getMockBuilder('\OC\IntegrityCheck\Helpers\FileAccessHelper')
->disableOriginalConstructor()->getMock();
+ $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ ->disableOriginalConstructor()->getMock();
$this->signApp = new SignApp(
$this->checker,
- $this->fileAccessHelper
+ $this->fileAccessHelper,
+ $this->urlGenerator
);
}
- public function testExecuteWithMissingAppId() {
+ public function testExecuteWithMissingPath() {
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
$inputInterface
->expects($this->at(0))
->method('getOption')
- ->with('appId')
+ ->with('path')
->will($this->returnValue(null));
$inputInterface
->expects($this->at(1))
@@ -68,7 +74,7 @@ class SignAppTest extends TestCase {
$outputInterface
->expects($this->at(0))
->method('writeln')
- ->with('--appId, --privateKey and --certificate are required.');
+ ->with('This command requires the --path, --privateKey and --certificate.');
$this->invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]);
}
@@ -80,7 +86,7 @@ class SignAppTest extends TestCase {
$inputInterface
->expects($this->at(0))
->method('getOption')
- ->with('appId')
+ ->with('path')
->will($this->returnValue('AppId'));
$inputInterface
->expects($this->at(1))
@@ -94,9 +100,9 @@ class SignAppTest extends TestCase {
->will($this->returnValue('Certificate'));
$outputInterface
- ->expects($this->at(0))
- ->method('writeln')
- ->with('--appId, --privateKey and --certificate are required.');
+ ->expects($this->at(0))
+ ->method('writeln')
+ ->with('This command requires the --path, --privateKey and --certificate.');
$this->invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]);
}
@@ -108,7 +114,7 @@ class SignAppTest extends TestCase {
$inputInterface
->expects($this->at(0))
->method('getOption')
- ->with('appId')
+ ->with('path')
->will($this->returnValue('AppId'));
$inputInterface
->expects($this->at(1))
@@ -124,7 +130,7 @@ class SignAppTest extends TestCase {
$outputInterface
->expects($this->at(0))
->method('writeln')
- ->with('--appId, --privateKey and --certificate are required.');
+ ->with('This command requires the --path, --privateKey and --certificate.');
$this->invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]);
}
@@ -136,7 +142,7 @@ class SignAppTest extends TestCase {
$inputInterface
->expects($this->at(0))
->method('getOption')
- ->with('appId')
+ ->with('path')
->will($this->returnValue('AppId'));
$inputInterface
->expects($this->at(1))
@@ -170,7 +176,7 @@ class SignAppTest extends TestCase {
$inputInterface
->expects($this->at(0))
->method('getOption')
- ->with('appId')
+ ->with('path')
->will($this->returnValue('AppId'));
$inputInterface
->expects($this->at(1))
@@ -209,7 +215,7 @@ class SignAppTest extends TestCase {
$inputInterface
->expects($this->at(0))
->method('getOption')
- ->with('appId')
+ ->with('path')
->will($this->returnValue('AppId'));
$inputInterface
->expects($this->at(1))
diff --git a/tests/lib/integritycheck/checkertest.php b/tests/lib/integritycheck/checkertest.php
index eee9299e6af..c4b952da924 100644
--- a/tests/lib/integritycheck/checkertest.php
+++ b/tests/lib/integritycheck/checkertest.php
@@ -77,7 +77,7 @@ class CheckerTest extends TestCase {
/**
* @expectedException \Exception
- * @expectedExceptionMessage Directory name must not be empty.
+ * @expectedExceptionMessage Directory does not exist.
*/
public function testWriteAppSignatureOfNotExistingApp() {
$keyBundle = file_get_contents(__DIR__ .'/../../data/integritycheck/SomeApp.crt');
@@ -98,11 +98,6 @@ class CheckerTest extends TestCase {
"signature": "Y5yvXvcGHVPuRRatKVDUONWq1FpLXugZd6Km\/+aEHsQj7coVl9FeMj9OsWamBf7yRIw3dtNLguTLlAA9QAv\/b0uHN3JnbNZN+dwFOve4NMtqXfSDlWftqKN00VS+RJXpG1S2IIx9Poyp2NoghL\/5AuTv4GHiNb7zU\/DT\/kt71pUGPgPR6IIFaE+zHOD96vjYkrH+GfWZzKR0FCdLib9yyNvk+EGrcjKM6qjs2GKfS\/XFjj\/\/neDnh\/0kcPuKE3ZbofnI4TIDTv0CGqvOp7PtqVNc3Vy\/UKa7uF1PT0MAUKMww6EiMUSFZdUVP4WWF0Y72W53Qdtf1hrAZa2kfKyoK5kd7sQmCSKUPSU8978AUVZlBtTRlyT803IKwMV0iHMkw+xYB1sN2FlHup\/DESADqxhdgYuK35bCPvgkb4SBe4B8Voz\/izTvcP7VT5UvkYdAO+05\/jzdaHEmzm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w9bpZ\r\nSOoNq2pCF9igftDWpSIXQ38pVpKLWowjjg3DVRmVKBgivHnUnVLyzYBahHPj0vaz\r\ntFtUFRaqXDnt+4qyUGyrT5h5pjZaTcHIcSB4PiarYwdVvgslgwnQzOUcGAzRWBD4\r\n6jV2brP5vFY3g6iPAgMBAAEwDQYJKoZIhvcNAQEFBQADggIBACTY3CCHC+Z28gCf\r\nFWGKQ3wAKs+k4+0yoti0qm2EKX7rSGQ0PHSas6uW79WstC4Rj+DYkDtIhGMSg8FS\r\nHVGZHGBCc0HwdX+BOAt3zi4p7Sf3oQef70\/4imPoKxbAVCpd\/cveVcFyDC19j1yB\r\nBapwu87oh+muoeaZxOlqQI4UxjBlR\/uRSMhOn2UGauIr3dWJgAF4pGt7TtIzt+1v\r\n0uA6FtN1Y4R5O8AaJPh1bIG0CVvFBE58esGzjEYLhOydgKFnEP94kVPgJD5ds9C3\r\npPhEpo1dRpiXaF7WGIV1X6DI\/ipWvfrF7CEy6I\/kP1InY\/vMDjQjeDnJ\/VrXIWXO\r\nyZvHXVaN\/m+1RlETsH7YO\/QmxRue9ZHN3gvvWtmpCeA95sfpepOk7UcHxHZYyQbF\r\n49\/au8j+5tsr4A83xzsT1JbcKRxkAaQ7WDJpOnE5O1+H0fB+BaLakTg6XX9d4Fo7\r\n7Gin7hVWX7pL+JIyxMzME3LhfI61+CRcqZQIrpyaafUziPQbWIPfEs7h8tCOWyvW\r\nUO8ZLervYCB3j44ivkrxPlcBklDCqqKKBzDP9dYOtS\/P4RB1NkHA9+NTvmBpTonS\r\nSFXdg9fFMD7VfjDE3Vnk+8DWkVH5wBYowTAD7w9Wuzr7DumiAULexnP\/Y7xwxLv7\r\n4B+pXTAcRK0zECDEaX3npS8xWzrB\r\n-----END CERTIFICATE-----"
}';
- $this->appLocator
- ->expects($this->once())
- ->method('getAppPath')
- ->with('SomeExistingApp')
- ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/app/'));
$this->fileAccessHelper
->expects($this->once())
->method('file_put_contents')
@@ -117,7 +112,7 @@ class CheckerTest extends TestCase {
$rsa->loadKey($rsaPrivateKey);
$x509 = new X509();
$x509->loadX509($keyBundle);
- $this->checker->writeAppSignature('SomeExistingApp', $x509, $rsa);
+ $this->checker->writeAppSignature(\OC::$SERVERROOT . '/tests/data/integritycheck/app/', $x509, $rsa);
}
public function testVerifyAppSignatureWithoutSignatureData() {