aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CardDAV
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-03-23 16:10:53 +0100
committerBjoern Schiessle <bjoern@schiessle.org>2017-03-24 11:27:01 +0100
commitee014bddbdb6d60d78cfdceadfe574197b078a4d (patch)
tree84e4f5d9972f024c3a289d4a18ea35b96d7e00f1 /apps/dav/lib/CardDAV
parent33867f331cdb1d9c678609e4aacc3166ec937629 (diff)
downloadnextcloud-server-ee014bddbdb6d60d78cfdceadfe574197b078a4d.tar.gz
nextcloud-server-ee014bddbdb6d60d78cfdceadfe574197b078a4d.zip
fix tests
calling getAbsoluteBundlePath() in the constructor makes other tests fail Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/dav/lib/CardDAV')
-rw-r--r--apps/dav/lib/CardDAV/SyncService.php33
1 files changed, 26 insertions, 7 deletions
diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php
index b0a4ce81e70..477e912a797 100644
--- a/apps/dav/lib/CardDAV/SyncService.php
+++ b/apps/dav/lib/CardDAV/SyncService.php
@@ -26,6 +26,7 @@ namespace OCA\DAV\CardDAV;
use OC\Accounts\AccountManager;
use OCP\AppFramework\Http;
+use OCP\ICertificateManager;
use OCP\ILogger;
use OCP\IUser;
use OCP\IUserManager;
@@ -68,12 +69,7 @@ class SyncService {
$this->userManager = $userManager;
$this->logger = $logger;
$this->accountManager = $accountManager;
-
- $certManager = \OC::$server->getCertificateManager(null);
- $certPath = $certManager->getAbsoluteBundlePath();
- if (file_exists($certPath)) {
- $this->certPath = $certPath;
- }
+ $this->certPath = '';
}
/**
@@ -142,6 +138,28 @@ class SyncService {
}
/**
+ * Check if there is a valid certPath we should use
+ *
+ * @return string
+ */
+ protected function getCertPath() {
+
+ // we already have a valid certPath
+ if ($this->certPath !== '') {
+ return $this->certPath;
+ }
+
+ /** @var ICertificateManager $certManager */
+ $certManager = \OC::$server->getCertificateManager(null);
+ $certPath = $certManager->getAbsoluteBundlePath();
+ if (file_exists($certPath)) {
+ $this->certPath = $certPath;
+ }
+
+ return $this->certPath;
+ }
+
+ /**
* @param string $url
* @param string $userName
* @param string $sharedSecret
@@ -154,9 +172,10 @@ class SyncService {
'password' => $sharedSecret,
];
$client = new Client($settings);
+ $certPath = $this->getCertPath();
$client->setThrowExceptions(true);
- if (strpos($url, 'http://') !== 0 && $this->certPath) {
+ if ($certPath !== '' && strpos($url, 'http://') !== 0) {
$client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
}