summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-11-24 16:24:26 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2014-11-25 11:53:28 +0100
commitc503ecd54495167f97b6602e5b41c1cf95467395 (patch)
treef0d8dfa42dda7c4d8c2e5e64d8ec19204c7fc24e /tests
parent6fb2477fb75d4c982a1568e2392d17fd7cc2fd4b (diff)
downloadnextcloud-server-c503ecd54495167f97b6602e5b41c1cf95467395.tar.gz
nextcloud-server-c503ecd54495167f97b6602e5b41c1cf95467395.zip
Introduce app info xml parser including basic unit test - necessary for #10777
Diffstat (limited to 'tests')
-rw-r--r--tests/data/app/valid-info.xml22
-rw-r--r--tests/lib/app/infoparser.php57
2 files changed, 79 insertions, 0 deletions
diff --git a/tests/data/app/valid-info.xml b/tests/data/app/valid-info.xml
new file mode 100644
index 00000000000..6fcef693bed
--- /dev/null
+++ b/tests/data/app/valid-info.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<info>
+ <id>files_encryption</id>
+ <name>Server-side Encryption</name>
+ <description>
+ This application encrypts all files accessed by ownCloud at rest, wherever they are stored. As an example, with this application enabled, external cloud based Amazon S3 storage will be encrypted, protecting this data on storage outside of the control of the Admin. When this application is enabled for the first time, all files are encrypted as users log in and are prompted for their password. The recommended recovery key option enables recovery of files in case the key is lost.
+ Note that this app encrypts all files that are touched by ownCloud, so external storage providers and applications such as SharePoint will see new files encrypted when they are accessed. Encryption is based on AES 128 or 256 bit keys. More information is available in the Encryption documentation
+ </description>
+ <licence>AGPL</licence>
+ <author>Sam Tuke, Bjoern Schiessle, Florin Peter</author>
+ <requiremin>4</requiremin>
+ <shipped>true</shipped>
+ <documentation>
+ <user>user-encryption</user>
+ <admin>admin-encryption</admin>
+ </documentation>
+ <rememberlogin>false</rememberlogin>
+ <types>
+ <filesystem/>
+ </types>
+ <ocsid>166047</ocsid>
+</info>
diff --git a/tests/lib/app/infoparser.php b/tests/lib/app/infoparser.php
new file mode 100644
index 00000000000..d1b2313e881
--- /dev/null
+++ b/tests/lib/app/infoparser.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * @author Thomas Müller
+ * @copyright 2014 Thomas Müller deepdiver@owncloud.com
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\App;
+
+use OC;
+
+class InfoParser extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @var \OC\App\InfoParser
+ */
+ private $parser;
+
+ public function setUp() {
+ $httpHelper = $this->getMockBuilder('\OC\HTTPHelper')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $httpHelper->expects($this->any())
+ ->method('isHTTPURL')
+ ->will($this->returnCallback(function ($url) {
+ return stripos($url, 'https://') === 0 || stripos($url, 'http://') === 0;
+ }));
+
+ $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ //linkToDocs
+ $httpHelper->expects($this->any())
+ ->method('linkToDocs')
+ ->will($this->returnCallback(function ($url) {
+ return $url;
+ }));
+
+ $this->parser = new \OC\App\InfoParser($httpHelper, $urlGenerator);
+ }
+
+ public function testParsingValidXml() {
+ $data = $this->parser->parse(OC::$SERVERROOT.'/tests/data/app/valid-info.xml');
+
+ $expectedKeys = array(
+ 'id', 'info', 'remote', 'public', 'name', 'description', 'licence', 'author', 'requiremin', 'shipped',
+ 'documentation', 'rememberlogin', 'types', 'ocsid'
+ );
+ foreach($expectedKeys as $expectedKey) {
+ $this->assertArrayHasKey($expectedKey, $data, "ExpectedKey($expectedKey) was missing.");
+ }
+ }
+}