diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-10-17 02:23:15 -0700 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-10-17 02:23:15 -0700 |
commit | b70d67d49abd814f6722803f0787f7d9fa908735 (patch) | |
tree | 017a0605a07c061d0ee0d11ec70a741e43c495b0 | |
parent | 186c6a56d13206f03bbc80ecac59ff8c6df63840 (diff) | |
parent | 7caf011b9aa8fba455a528dac694a3d5eb697547 (diff) | |
download | nextcloud-server-b70d67d49abd814f6722803f0787f7d9fa908735.tar.gz nextcloud-server-b70d67d49abd814f6722803f0787f7d9fa908735.zip |
Merge pull request #5237 from owncloud/coverage-on-windows-master
PHP Code Coverage on windows master
-rw-r--r-- | autotest.cmd | 4 | ||||
-rw-r--r-- | lib/private/preview/movies.php | 52 | ||||
-rw-r--r-- | lib/private/preview/office-cl.php | 160 | ||||
-rw-r--r-- | lib/private/preview/office.php | 25 | ||||
-rw-r--r-- | tests/data/openssl.cnf | 350 | ||||
-rw-r--r-- | tests/preseed-config.php | 5 | ||||
-rw-r--r-- | tests/win32-phpunit.php | 347 |
7 files changed, 483 insertions, 460 deletions
diff --git a/autotest.cmd b/autotest.cmd index a511faef9c6..969e4a1ff38 100644 --- a/autotest.cmd +++ b/autotest.cmd @@ -6,7 +6,6 @@ :: :: @copyright 2012, 2013 Thomas Müller thomas.mueller@tmit.eu :: -@echo off set DATADIR=data-autotest set BASEDIR=%~dp0 @@ -119,7 +118,8 @@ goto:eof md coverage-html-%~1 php -f enable_all.php - php win32-phpunit.php --bootstrap bootstrap.php --configuration phpunit-autotest.xml --log-junit autotest-results-%~1.xml --coverage-clover autotest-clover-%~1.xml --coverage-html coverage-html-%~1 + call phpunit --bootstrap bootstrap.php --configuration phpunit-autotest.xml --log-junit autotest-results-%~1.xml --coverage-clover autotest-clover-%~1.xml --coverage-html coverage-html-%~1 + echo "Done with testing %~1 ..." cd %BASEDIR% goto:eof diff --git a/lib/private/preview/movies.php b/lib/private/preview/movies.php index c318137ff0e..dc50d160346 100644 --- a/lib/private/preview/movies.php +++ b/lib/private/preview/movies.php @@ -8,40 +8,44 @@ */ namespace OC\Preview; -$isShellExecEnabled = !in_array('shell_exec', explode(', ', ini_get('disable_functions'))); -$whichAVCONV = shell_exec('which avconv'); -$isAVCONVAvailable = !empty($whichAVCONV); +// movie preview is currently not supported on Windows +if (!\OC_Util::runningOnWindows()) { + $isShellExecEnabled = !in_array('shell_exec', explode(', ', ini_get('disable_functions'))); + $whichAVCONV = shell_exec('which avconv'); + $isAVCONVAvailable = !empty($whichAVCONV); -if($isShellExecEnabled && $isAVCONVAvailable) { + if($isShellExecEnabled && $isAVCONVAvailable) { - class Movie extends Provider { + class Movie extends Provider { - public function getMimeType() { - return '/video\/.*/'; - } + public function getMimeType() { + return '/video\/.*/'; + } + + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + $absPath = \OC_Helper::tmpFile(); + $tmpPath = \OC_Helper::tmpFile(); - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - $absPath = \OC_Helper::tmpFile(); - $tmpPath = \OC_Helper::tmpFile(); + $handle = $fileview->fopen($path, 'rb'); - $handle = $fileview->fopen($path, 'rb'); + $firstmb = stream_get_contents($handle, 1048576); //1024 * 1024 = 1048576 + file_put_contents($absPath, $firstmb); - $firstmb = stream_get_contents($handle, 1048576); //1024 * 1024 = 1048576 - file_put_contents($absPath, $firstmb); + //$cmd = 'ffmpeg -y -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmpPath; + $cmd = 'avconv -an -y -ss 1 -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 ' . escapeshellarg($tmpPath); - //$cmd = 'ffmpeg -y -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmpPath; - $cmd = 'avconv -an -y -ss 1 -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 ' . escapeshellarg($tmpPath); - - shell_exec($cmd); + shell_exec($cmd); - $image = new \OC_Image($tmpPath); + $image = new \OC_Image($tmpPath); - unlink($absPath); - unlink($tmpPath); + unlink($absPath); + unlink($tmpPath); - return $image->valid() ? $image : false; + return $image->valid() ? $image : false; + } } + + \OC\Preview::registerProvider('OC\Preview\Movie'); } +} - \OC\Preview::registerProvider('OC\Preview\Movie'); -}
\ No newline at end of file diff --git a/lib/private/preview/office-cl.php b/lib/private/preview/office-cl.php index 112909d6523..8f2e06c050b 100644 --- a/lib/private/preview/office-cl.php +++ b/lib/private/preview/office-cl.php @@ -7,128 +7,132 @@ */ namespace OC\Preview; -//we need imagick to convert -class Office extends Provider { +// office preview is currently not supported on Windows +if (!\OC_Util::runningOnWindows()) { - private $cmd; + //we need imagick to convert + class Office extends Provider { - public function getMimeType() { - return null; - } + private $cmd; - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - $this->initCmd(); - if(is_null($this->cmd)) { - return false; + public function getMimeType() { + return null; } - $absPath = $fileview->toTmpFile($path); + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + $this->initCmd(); + if(is_null($this->cmd)) { + return false; + } + + $absPath = $fileview->toTmpFile($path); + + $tmpDir = get_temp_dir(); - $tmpDir = get_temp_dir(); + $defaultParameters = ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir '; + $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters); - $defaultParameters = ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir '; - $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters); + $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath); + $export = 'export HOME=/' . $tmpDir; - $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath); - $export = 'export HOME=/' . $tmpDir; + shell_exec($export . "\n" . $exec); - shell_exec($export . "\n" . $exec); + //create imagick object from pdf + try{ + $pdf = new \imagick($absPath . '.pdf' . '[0]'); + $pdf->setImageFormat('jpg'); + } catch (\Exception $e) { + unlink($absPath); + unlink($absPath . '.pdf'); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + return false; + } + + $image = new \OC_Image($pdf); - //create imagick object from pdf - try{ - $pdf = new \imagick($absPath . '.pdf' . '[0]'); - $pdf->setImageFormat('jpg'); - } catch (\Exception $e) { unlink($absPath); unlink($absPath . '.pdf'); - \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); - return false; + + return $image->valid() ? $image : false; } - $image = new \OC_Image($pdf); + private function initCmd() { + $cmd = ''; - unlink($absPath); - unlink($absPath . '.pdf'); + if(is_string(\OC_Config::getValue('preview_libreoffice_path', null))) { + $cmd = \OC_Config::getValue('preview_libreoffice_path', null); + } - return $image->valid() ? $image : false; - } + $whichLibreOffice = shell_exec('which libreoffice'); + if($cmd === '' && !empty($whichLibreOffice)) { + $cmd = 'libreoffice'; + } - private function initCmd() { - $cmd = ''; + $whichOpenOffice = shell_exec('which openoffice'); + if($cmd === '' && !empty($whichOpenOffice)) { + $cmd = 'openoffice'; + } - if(is_string(\OC_Config::getValue('preview_libreoffice_path', null))) { - $cmd = \OC_Config::getValue('preview_libreoffice_path', null); - } + if($cmd === '') { + $cmd = null; + } - $whichLibreOffice = shell_exec('which libreoffice'); - if($cmd === '' && !empty($whichLibreOffice)) { - $cmd = 'libreoffice'; + $this->cmd = $cmd; } + } - $whichOpenOffice = shell_exec('which openoffice'); - if($cmd === '' && !empty($whichOpenOffice)) { - $cmd = 'openoffice'; - } + //.doc, .dot + class MSOfficeDoc extends Office { - if($cmd === '') { - $cmd = null; + public function getMimeType() { + return '/application\/msword/'; } - $this->cmd = $cmd; - } -} - -//.doc, .dot -class MSOfficeDoc extends Office { - - public function getMimeType() { - return '/application\/msword/'; } -} + \OC\Preview::registerProvider('OC\Preview\MSOfficeDoc'); -\OC\Preview::registerProvider('OC\Preview\MSOfficeDoc'); + //.docm, .dotm, .xls(m), .xlt(m), .xla(m), .ppt(m), .pot(m), .pps(m), .ppa(m) + class MSOffice2003 extends Office { -//.docm, .dotm, .xls(m), .xlt(m), .xla(m), .ppt(m), .pot(m), .pps(m), .ppa(m) -class MSOffice2003 extends Office { + public function getMimeType() { + return '/application\/vnd.ms-.*/'; + } - public function getMimeType() { - return '/application\/vnd.ms-.*/'; } -} + \OC\Preview::registerProvider('OC\Preview\MSOffice2003'); -\OC\Preview::registerProvider('OC\Preview\MSOffice2003'); + //.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx + class MSOffice2007 extends Office { -//.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx -class MSOffice2007 extends Office { + public function getMimeType() { + return '/application\/vnd.openxmlformats-officedocument.*/'; + } - public function getMimeType() { - return '/application\/vnd.openxmlformats-officedocument.*/'; } -} + \OC\Preview::registerProvider('OC\Preview\MSOffice2007'); -\OC\Preview::registerProvider('OC\Preview\MSOffice2007'); + //.odt, .ott, .oth, .odm, .odg, .otg, .odp, .otp, .ods, .ots, .odc, .odf, .odb, .odi, .oxt + class OpenDocument extends Office { -//.odt, .ott, .oth, .odm, .odg, .otg, .odp, .otp, .ods, .ots, .odc, .odf, .odb, .odi, .oxt -class OpenDocument extends Office { + public function getMimeType() { + return '/application\/vnd.oasis.opendocument.*/'; + } - public function getMimeType() { - return '/application\/vnd.oasis.opendocument.*/'; } -} + \OC\Preview::registerProvider('OC\Preview\OpenDocument'); -\OC\Preview::registerProvider('OC\Preview\OpenDocument'); + //.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm + class StarOffice extends Office { -//.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm -class StarOffice extends Office { + public function getMimeType() { + return '/application\/vnd.sun.xml.*/'; + } - public function getMimeType() { - return '/application\/vnd.sun.xml.*/'; } + \OC\Preview::registerProvider('OC\Preview\StarOffice'); } - -\OC\Preview::registerProvider('OC\Preview\StarOffice');
\ No newline at end of file diff --git a/lib/private/preview/office.php b/lib/private/preview/office.php index 5287bbd6ac1..673b16edc19 100644 --- a/lib/private/preview/office.php +++ b/lib/private/preview/office.php @@ -8,15 +8,22 @@ //both, libreoffice backend and php fallback, need imagick if (extension_loaded('imagick')) { $isShellExecEnabled = !in_array('shell_exec', explode(', ', ini_get('disable_functions'))); - $whichLibreOffice = shell_exec('which libreoffice'); - $isLibreOfficeAvailable = !empty($whichLibreOffice); - $whichOpenOffice = shell_exec('which libreoffice'); - $isOpenOfficeAvailable = !empty($whichOpenOffice); - //let's see if there is libreoffice or openoffice on this machine - if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) { - require_once('office-cl.php'); - }else{ + + // movie preview is currently not supported on Windows + if (!\OC_Util::runningOnWindows()) { + $whichLibreOffice = shell_exec('which libreoffice'); + $isLibreOfficeAvailable = !empty($whichLibreOffice); + $whichOpenOffice = shell_exec('which libreoffice'); + $isOpenOfficeAvailable = !empty($whichOpenOffice); + //let's see if there is libreoffice or openoffice on this machine + if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) { + require_once('office-cl.php'); + }else{ + //in case there isn't, use our fallback + require_once('office-fallback.php'); + } + } else { //in case there isn't, use our fallback require_once('office-fallback.php'); } -}
\ No newline at end of file +} diff --git a/tests/data/openssl.cnf b/tests/data/openssl.cnf new file mode 100644 index 00000000000..1eb86c40126 --- /dev/null +++ b/tests/data/openssl.cnf @@ -0,0 +1,350 @@ +# +# OpenSSL example configuration file. +# This is mostly being used for generation of certificate requests. +# + +# This definition stops the following lines choking if HOME isn't +# defined. +HOME = . +RANDFILE = $ENV::HOME/.rnd + +# Extra OBJECT IDENTIFIER info: +#oid_file = $ENV::HOME/.oid +oid_section = new_oids + +# To use this configuration file with the "-extfile" option of the +# "openssl x509" utility, name here the section containing the +# X.509v3 extensions to use: +# extensions = +# (Alternatively, use a configuration file that has only +# X.509v3 extensions in its main [= default] section.) + +[ new_oids ] + +# We can add new OIDs in here for use by 'ca', 'req' and 'ts'. +# Add a simple OID like this: +# testoid1=1.2.3.4 +# Or use config file substitution like this: +# testoid2=${testoid1}.5.6 + +# Policies used by the TSA examples. +tsa_policy1 = 1.2.3.4.1 +tsa_policy2 = 1.2.3.4.5.6 +tsa_policy3 = 1.2.3.4.5.7 + +#################################################################### +[ ca ] +default_ca = CA_default # The default ca section + +#################################################################### +[ CA_default ] + +dir = ./demoCA # Where everything is kept +certs = $dir/certs # Where the issued certs are kept +crl_dir = $dir/crl # Where the issued crl are kept +database = $dir/index.txt # database index file. +#unique_subject = no # Set to 'no' to allow creation of + # several ctificates with same subject. +new_certs_dir = $dir/newcerts # default place for new certs. + +certificate = $dir/cacert.pem # The CA certificate +serial = $dir/serial # The current serial number +crlnumber = $dir/crlnumber # the current crl number + # must be commented out to leave a V1 CRL +crl = $dir/crl.pem # The current CRL +private_key = $dir/private/cakey.pem# The private key +RANDFILE = $dir/private/.rand # private random number file + +x509_extensions = usr_cert # The extentions to add to the cert + +# Comment out the following two lines for the "traditional" +# (and highly broken) format. +name_opt = ca_default # Subject Name options +cert_opt = ca_default # Certificate field options + +# Extension copying option: use with caution. +# copy_extensions = copy + +# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs +# so this is commented out by default to leave a V1 CRL. +# crlnumber must also be commented out to leave a V1 CRL. +# crl_extensions = crl_ext + +default_days = 365 # how long to certify for +default_crl_days= 30 # how long before next CRL +default_md = default # use public key default MD +preserve = no # keep passed DN ordering + +# A few difference way of specifying how similar the request should look +# For type CA, the listed attributes must be the same, and the optional +# and supplied fields are just that :-) +policy = policy_match + +# For the CA policy +[ policy_match ] +countryName = match +stateOrProvinceName = match +organizationName = match +organizationalUnitName = optional +commonName = supplied +emailAddress = optional + +# For the 'anything' policy +# At this point in time, you must list all acceptable 'object' +# types. +[ policy_anything ] +countryName = optional +stateOrProvinceName = optional +localityName = optional +organizationName = optional +organizationalUnitName = optional +commonName = supplied +emailAddress = optional + +#################################################################### +[ req ] +default_bits = 2048 +default_keyfile = privkey.pem +distinguished_name = req_distinguished_name +attributes = req_attributes +x509_extensions = v3_ca # The extentions to add to the self signed cert + +# Passwords for private keys if not present they will be prompted for +# input_password = secret +# output_password = secret + +# This sets a mask for permitted string types. There are several options. +# default: PrintableString, T61String, BMPString. +# pkix : PrintableString, BMPString (PKIX recommendation before 2004) +# utf8only: only UTF8Strings (PKIX recommendation after 2004). +# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings). +# MASK:XXXX a literal mask value. +# WARNING: ancient versions of Netscape crash on BMPStrings or UTF8Strings. +string_mask = utf8only + +# req_extensions = v3_req # The extensions to add to a certificate request + +[ req_distinguished_name ] +countryName = Country Name (2 letter code) +countryName_default = AU +countryName_min = 2 +countryName_max = 2 + +stateOrProvinceName = State or Province Name (full name) +stateOrProvinceName_default = Some-State + +localityName = Locality Name (eg, city) + +0.organizationName = Organization Name (eg, company) +0.organizationName_default = Internet Widgits Pty Ltd + +# we can do this but it is not needed normally :-) +#1.organizationName = Second Organization Name (eg, company) +#1.organizationName_default = World Wide Web Pty Ltd + +organizationalUnitName = Organizational Unit Name (eg, section) +#organizationalUnitName_default = + +commonName = Common Name (e.g. server FQDN or YOUR name) +commonName_max = 64 + +emailAddress = Email Address +emailAddress_max = 64 + +# SET-ex3 = SET extension number 3 + +[ req_attributes ] +challengePassword = A challenge password +challengePassword_min = 4 +challengePassword_max = 20 + +unstructuredName = An optional company name + +[ usr_cert ] + +# These extensions are added when 'ca' signs a request. + +# This goes against PKIX guidelines but some CAs do it and some software +# requires this to avoid interpreting an end user certificate as a CA. + +basicConstraints=CA:FALSE + +# Here are some examples of the usage of nsCertType. If it is omitted +# the certificate can be used for anything *except* object signing. + +# This is OK for an SSL server. +# nsCertType = server + +# For an object signing certificate this would be used. +# nsCertType = objsign + +# For normal client use this is typical +# nsCertType = client, email + +# and for everything including object signing: +# nsCertType = client, email, objsign + +# This is typical in keyUsage for a client certificate. +# keyUsage = nonRepudiation, digitalSignature, keyEncipherment + +# This will be displayed in Netscape's comment listbox. +nsComment = "OpenSSL Generated Certificate" + +# PKIX recommendations harmless if included in all certificates. +subjectKeyIdentifier=hash +authorityKeyIdentifier=keyid,issuer + +# This stuff is for subjectAltName and issuerAltname. +# Import the email address. +# subjectAltName=email:copy +# An alternative to produce certificates that aren't +# deprecated according to PKIX. +# subjectAltName=email:move + +# Copy subject details +# issuerAltName=issuer:copy + +#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem +#nsBaseUrl +#nsRevocationUrl +#nsRenewalUrl +#nsCaPolicyUrl +#nsSslServerName + +# This is required for TSA certificates. +# extendedKeyUsage = critical,timeStamping + +[ v3_req ] + +# Extensions to add to a certificate request + +basicConstraints = CA:FALSE +keyUsage = nonRepudiation, digitalSignature, keyEncipherment + +[ v3_ca ] + + +# Extensions for a typical CA + + +# PKIX recommendation. + +subjectKeyIdentifier=hash + +authorityKeyIdentifier=keyid:always,issuer + +# This is what PKIX recommends but some broken software chokes on critical +# extensions. +#basicConstraints = critical,CA:true +# So we do this instead. +basicConstraints = CA:true + +# Key usage: this is typical for a CA certificate. However since it will +# prevent it being used as an test self-signed certificate it is best +# left out by default. +# keyUsage = cRLSign, keyCertSign + +# Some might want this also +# nsCertType = sslCA, emailCA + +# Include email address in subject alt name: another PKIX recommendation +# subjectAltName=email:copy +# Copy issuer details +# issuerAltName=issuer:copy + +# DER hex encoding of an extension: beware experts only! +# obj=DER:02:03 +# Where 'obj' is a standard or added object +# You can even override a supported extension: +# basicConstraints= critical, DER:30:03:01:01:FF + +[ crl_ext ] + +# CRL extensions. +# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL. + +# issuerAltName=issuer:copy +authorityKeyIdentifier=keyid:always + +[ proxy_cert_ext ] +# These extensions should be added when creating a proxy certificate + +# This goes against PKIX guidelines but some CAs do it and some software +# requires this to avoid interpreting an end user certificate as a CA. + +basicConstraints=CA:FALSE + +# Here are some examples of the usage of nsCertType. If it is omitted +# the certificate can be used for anything *except* object signing. + +# This is OK for an SSL server. +# nsCertType = server + +# For an object signing certificate this would be used. +# nsCertType = objsign + +# For normal client use this is typical +# nsCertType = client, email + +# and for everything including object signing: +# nsCertType = client, email, objsign + +# This is typical in keyUsage for a client certificate. +# keyUsage = nonRepudiation, digitalSignature, keyEncipherment + +# This will be displayed in Netscape's comment listbox. +nsComment = "OpenSSL Generated Certificate" + +# PKIX recommendations harmless if included in all certificates. +subjectKeyIdentifier=hash +authorityKeyIdentifier=keyid,issuer + +# This stuff is for subjectAltName and issuerAltname. +# Import the email address. +# subjectAltName=email:copy +# An alternative to produce certificates that aren't +# deprecated according to PKIX. +# subjectAltName=email:move + +# Copy subject details +# issuerAltName=issuer:copy + +#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem +#nsBaseUrl +#nsRevocationUrl +#nsRenewalUrl +#nsCaPolicyUrl +#nsSslServerName + +# This really needs to be in place for it to be a proxy certificate. +proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo + +#################################################################### +[ tsa ] + +default_tsa = tsa_config1 # the default TSA section + +[ tsa_config1 ] + +# These are used by the TSA reply generation only. +dir = ./demoCA # TSA root directory +serial = $dir/tsaserial # The current serial number (mandatory) +crypto_device = builtin # OpenSSL engine to use for signing +signer_cert = $dir/tsacert.pem # The TSA signing certificate + # (optional) +certs = $dir/cacert.pem # Certificate chain to include in reply + # (optional) +signer_key = $dir/private/tsakey.pem # The TSA private key (optional) + +default_policy = tsa_policy1 # Policy if request did not specify it + # (optional) +other_policies = tsa_policy2, tsa_policy3 # acceptable policies (optional) +digests = md5, sha1 # Acceptable message digests (mandatory) +accuracy = secs:1, millisecs:500, microsecs:100 # (optional) +clock_precision_digits = 0 # number of digits after dot. (optional) +ordering = yes # Is ordering defined for timestamps? + # (optional, default: no) +tsa_name = yes # Must the TSA name be included in the reply? + # (optional, default: no) +ess_cert_id_chain = no # Must the ESS cert id chain be included? + # (optional, default: no) diff --git a/tests/preseed-config.php b/tests/preseed-config.php index 9791e713dac..95ffb4514bf 100644 --- a/tests/preseed-config.php +++ b/tests/preseed-config.php @@ -16,4 +16,9 @@ $CONFIG = array ( 'writable' => false, ) ), + ); + +if(substr(strtolower(PHP_OS), 0, 3) == "win") { + $CONFIG['openssl'] = array( 'config' => OC::$SERVERROOT.'/tests/data/openssl.cnf'); +} diff --git a/tests/win32-phpunit.php b/tests/win32-phpunit.php deleted file mode 100644 index ac8f95efcbf..00000000000 --- a/tests/win32-phpunit.php +++ /dev/null @@ -1,347 +0,0 @@ -<?php -OC_PHPUnit_Loader::checkIncludePath(); -OC_PHPUnit_Loader::detectPHPUnitVersionId(); - -//load PHPUnit -switch (OC_PHPUnit_Loader::$PHPUnitVersionId) { - case "36": { - OC_PHPUnit_Loader::load36(); - break; - } - case "37": { - OC_PHPUnit_Loader::load37(); - break; - } -} - -//load custom implementation of the PHPUnit_TextUI_ResultPrinter -switch (OC_PHPUnit_Loader::$PHPUnitVersionId) { - case "36": - case "37": { - class OC_PHPUnit_TextUI_ResultPrinter extends PHPUnit_TextUI_ResultPrinter - { - function __construct() - { - parent::__construct('php://stderr'); - } - - public function printResult(PHPUnit_Framework_TestResult $result) - { - $this->printHeader(); - $this->printFooter($result); - } - - protected function writeProgress($progress) - { - //ignore - } - } - break; - } -} - -//loading of OC_PHPUnit_TextUI_Command -switch (OC_PHPUnit_Loader::$PHPUnitVersionId) { - case "36": - case "37": { - class OC_PHPUnit_TextUI_Command extends PHPUnit_TextUI_Command - { - - public static function main($exit = TRUE) - { - $command = new OC_PHPUnit_TextUI_Command(); - $command->run($_SERVER['argv'], $exit); - } - - protected function handleArguments(array $argv) - { - parent::handleArguments($argv); - $this->arguments['listeners'][] = new OC_PHPUnit_Framework_TestListener(); - $this->arguments['printer'] = new OC_PHPUnit_TextUI_ResultPrinter(); - } - - protected function createRunner() - { - $coverage_Filter = new PHP_CodeCoverage_Filter(); - $coverage_Filter->addFileToBlacklist(__FILE__); - $runner = new PHPUnit_TextUI_TestRunner($this->arguments['loader'], $coverage_Filter); - return $runner; - } - } - break; - } -} - -class OC_PHPUnit_Loader -{ - - const SUCCESS_EXIT = 0; - const FAILURE_EXIT = 1; - const EXCEPTION_EXIT = 2; - - public static $PHPUnitVersionId; - - /** - * @return void - */ - public static function checkIncludePath() - { - //check include path - $PHPUnitParentDirectory = self::getPHPUnitParentDirectory(); - if (is_null($PHPUnitParentDirectory)) { - echo "Cannot find PHPUnit in include path (" . ini_get('include_path') . ")"; - exit(OC_PHPUnit_Loader::FAILURE_EXIT); - } - } - - /** - * @return null | string - */ - private static function getPHPUnitParentDirectory() - { - $pathArray = explode(PATH_SEPARATOR, ini_get('include_path')); - foreach ($pathArray as $path) - { - if (file_exists($path . DIRECTORY_SEPARATOR . 'PHPUnit/')) { - return $path; - } - } - return null; - } - - /** - * @return void - */ - public static function detectPHPUnitVersionId() - { - require_once 'PHPUnit/Runner/Version.php'; - - $PHPUnitVersion = PHPUnit_Runner_Version::id(); - - if ($PHPUnitVersion === "@package_version@") { - - self::$PHPUnitVersionId = "37"; - } - else if (version_compare($PHPUnitVersion, '3.7.0') >= 0) { - - self::$PHPUnitVersionId = "37"; - } - else if (version_compare($PHPUnitVersion, '3.6.0') >= 0) { - - self::$PHPUnitVersionId = "36"; - } - else if (version_compare($PHPUnitVersion, '3.6.0') >= 0) { - - echo "unsupported PHPUnit version: $PHPUnitVersion"; - exit(OC_PHPUnit_Loader::FAILURE_EXIT); - } - } - - /** - * @return void - */ - public static function load37() - { - - require 'PHPUnit/Autoload.php'; - - } - - - /** - * @return void - */ - public static function load36() - { - define('PHPUnit_MAIN_METHOD', 'OC_PHPUnit_TextUI_Command::main'); - - require 'PHPUnit/Autoload.php'; - - } -} - -class OC_PHPUnit_Framework_TestListener implements PHPUnit_Framework_TestListener -{ - - private $isSummaryTestCountPrinted = false; - - public static function printEvent($eventName, $params = array()) - { - self::printText("\n[$eventName"); - foreach ($params as $key => $value) { - self::printText(" $key='$value'"); - } - self::printText("]\n"); - } - - public static function printText($text) - { - file_put_contents('php://stderr', $text); - } - - private static function getMessage(Exception $e) - { - $message = ""; - if (strlen(get_class($e)) != 0) { - $message = $message . get_class($e); - } - if (strlen($message) != 0 && strlen($e->getMessage()) != 0) { - $message = $message . " : "; - } - $message = $message . $e->getMessage(); - return self::escapeValue($message); - } - - private static function getDetails(Exception $e) - { - return self::escapeValue($e->getTraceAsString()); - } - - public static function getValueAsString($value) - { - if (is_null($value)) { - return "null"; - } - else if (is_bool($value)) { - return $value == true ? "true" : "false"; - } - else if (is_array($value) || is_string($value)) { - $valueAsString = print_r($value, true); - if (strlen($valueAsString) > 10000) { - return null; - } - return $valueAsString; - } - else if (is_scalar($value)){ - return print_r($value, true); - } - return null; - } - - private static function escapeValue($text) { - $text = str_replace("|", "||", $text); - $text = str_replace("'", "|'", $text); - $text = str_replace("\n", "|n", $text); - $text = str_replace("\r", "|r", $text); - $text = str_replace("]", "|]", $text); - return $text; - } - - public static function getFileName($className) - { - $reflectionClass = new ReflectionClass($className); - $fileName = $reflectionClass->getFileName(); - return $fileName; - } - - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - self::printEvent("testFailed", array( - "name" => $test->getName(), - "message" => self::getMessage($e), - "details" => self::getDetails($e) - )); - } - - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - $params = array( - "name" => $test->getName(), - "message" => self::getMessage($e), - "details" => self::getDetails($e) - ); - if ($e instanceof PHPUnit_Framework_ExpectationFailedException) { - $comparisonFailure = $e->getComparisonFailure(); - if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure) { - $actualResult = $comparisonFailure->getActual(); - $expectedResult = $comparisonFailure->getExpected(); - $actualString = self::getValueAsString($actualResult); - $expectedString = self::getValueAsString($expectedResult); - if (!is_null($actualString) && !is_null($expectedString)) { - $params['actual'] = self::escapeValue($actualString); - $params['expected'] = self::escapeValue($expectedString); - } - } - } - self::printEvent("testFailed", $params); - } - - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - self::printEvent("testIgnored", array( - "name" => $test->getName(), - "message" => self::getMessage($e), - "details" => self::getDetails($e) - )); - } - - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - self::printEvent("testIgnored", array( - "name" => $test->getName(), - "message" => self::getMessage($e), - "details" => self::getDetails($e) - )); - } - - public function startTest(PHPUnit_Framework_Test $test) - { - $testName = $test->getName(); - $params = array( - "name" => $testName - ); - if ($test instanceof PHPUnit_Framework_TestCase) { - $className = get_class($test); - $fileName = self::getFileName($className); - $params['locationHint'] = "php_qn://$fileName::\\$className::$testName"; - } - self::printEvent("testStarted", $params); - } - - public function endTest(PHPUnit_Framework_Test $test, $time) - { - self::printEvent("testFinished", array( - "name" => $test->getName(), - "duration" => (int)(round($time, 2) * 1000) - )); - } - - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - if (!$this->isSummaryTestCountPrinted) { - $this->isSummaryTestCountPrinted = true; - //print tests count - self::printEvent("testCount", array( - "count" => count($suite) - )); - } - - $suiteName = $suite->getName(); - if (empty($suiteName)) { - return; - } - $params = array( - "name" => $suiteName, - ); - if (class_exists($suiteName, false)) { - $fileName = self::getFileName($suiteName); - $params['locationHint'] = "php_qn://$fileName::\\$suiteName"; - } - self::printEvent("testSuiteStarted", $params); - } - - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $suiteName = $suite->getName(); - if (empty($suiteName)) { - return; - } - self::printEvent("testSuiteFinished", - array( - "name" => $suite->getName() - )); - } - -} - -OC_PHPUnit_TextUI_Command::main(); |