summaryrefslogtreecommitdiffstats
path: root/run-all-junit-tests
Commit message (Collapse)AuthorAgeFilesLines
* 148190: reworked code to cope with new module ajde.coreaclement2007-01-112-0/+3
|
* Bug 152982 "org.aspectj Restructure - Phase 2: Move tests" (remove ↵mwebster2006-08-081-6/+4
| | | | unnecessary reflective invocation)
* Eclipse 3.2 (JSE-1.5 and JUnit 3)mwebster2006-08-081-0/+2
|
* Bug 152982 "org.aspectj Restructure - Phase 2: Move tests" (move Java 5 ↵mwebster2006-08-071-9/+8
| | | | dependedent tests to weaver5, reduce use of reflection and conditional execution, remove duplication)
* Bug 113948 "Repackage AspectJ" (move module root suites out of default package)mwebster2006-07-302-3/+22
|
* update license to EPLacolyer2006-06-011-2/+2
|
* sick and tired of checking these classes out of CVS and hacking debug ON. ↵aclement2006-05-171-0/+13
| | | | The only time I want debug off is when running RunTheseBeforeYouCommitTests. So now debug is hard coded ON and I've checked in a launch config for running the tests with debug off.
* updated for weaver5aclement2005-09-262-92/+25
|
* moved some tests with 1.5 dependenciesacolyer2005-07-081-0/+2
|
* fix LTW5/515 stuff as per Wes spotavasseur2005-06-161-1/+1
|
* fixed bug with LTW Xreweavable, fix this reflective issue in ↵avasseur2005-06-131-1/+1
| | | | RunAllBeforeCommit (was misnamed..)
* new logic in AllTests failed unless loadtime5 was on project pathacolyer2005-06-091-22/+92
|
* Now delegating to the two roots: AllTests for unit tests, and ↵wisberg2005-06-081-20/+18
| | | | tests/../TestsModulesTests for compiler tests.
* Root of all all (non-compiler) JUnit tests works under 1.3 and 1.5 in Eclipse.wisberg2005-06-081-8/+20
|
* Module alias does not include compiler tests since tests/ doeswisberg2005-06-081-1/+6
|
* adding ajdoc and loadtime to run those JUnit tests. Not sure why unable to ↵wisberg2005-06-081-80/+22
| | | | add AspectJ project org.aspectj.lib.
* perClause inheritance in @AJ (in ajdt module), fixed FIXME AVavasseur2005-06-031-1/+2
|
* special-casing 1.5 tests - now runs all non-java-5 tests in 1.3, and ↵wisberg2005-06-021-1/+8
| | | | includes java 5 modules if running in a 1.5 VM.
* newbuild.xml replacing build.xml, with Alex okwisberg2005-05-192-114/+3
|
* Name picked up by Ant junit taskwisberg2005-05-111-0/+21
|
* prospective replacements for {module}/build.xml - will move there once ↵wisberg2005-05-111-0/+6
| | | | validated by those who use build.xml.
* needed to add this dependency?aclement2005-04-261-19/+80
|
* fix some build. Move AspectJrt5 test to AllTest15. Add weaver checks for @AJ ↵avasseur2005-04-261-0/+5
| | | | annotations + tests from Andy H
* run the aspectj5rt tests as part of this suiteacolyer2005-04-252-4/+6
|
* From branch: New build scripts that Alex uses under IntelliJ - can be run ↵aclement2005-04-191-0/+106
| | | | individually or via master in build module.
* The JUnit test suite to end all test suites. This should come in pretty ↵acolyer2004-08-042-19/+49
| | | | handy....
* giving in to the out dir...wisberg2004-01-091-0/+4
|
* initial version of common JUnit driver usable from Eclipsewisberg2003-10-313-0/+92
ort/47515/stable29'>backport/47515/stable29 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Remote/Instance.php
blob: ac3233b93c93dddaabfcb54bdc31ca9df0dec539 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/**
 * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OC\Remote;

use OC\Remote\Api\NotFoundException;
use OCP\Http\Client\IClientService;
use OCP\ICache;
use OCP\Remote\IInstance;

/**
 * Provides some basic info about a remote Nextcloud instance
 */
class Instance implements IInstance {
	/** @var string */
	private $url;

	/** @var ICache */
	private $cache;

	/** @var IClientService */
	private $clientService;

	/** @var array|null */
	private $status;

	/**
	 * @param string $url
	 * @param ICache $cache
	 * @param IClientService $clientService
	 */
	public function __construct($url, ICache $cache, IClientService $clientService) {
		$url = str_replace('https://', '', $url);
		$this->url = str_replace('http://', '', $url);
		$this->cache = $cache;
		$this->clientService = $clientService;
	}

	/**
	 * @return string The url of the remote server without protocol
	 */
	public function getUrl() {
		return $this->url;
	}

	/**
	 * @return string The of the remote server with protocol
	 */
	public function getFullUrl() {
		return $this->getProtocol() . '://' . $this->getUrl();
	}

	/**
	 * @return string The full version string in '13.1.2.3' format
	 */
	public function getVersion() {
		$status = $this->getStatus();
		return $status['version'];
	}

	/**
	 * @return string 'http' or 'https'
	 */
	public function getProtocol() {
		$status = $this->getStatus();
		return $status['protocol'];
	}

	/**
	 * Check that the remote server is installed and not in maintenance mode
	 *
	 * @return bool
	 */
	public function isActive() {
		$status = $this->getStatus();
		return $status['installed'] && !$status['maintenance'];
	}

	/**
	 * @return array
	 * @throws NotFoundException
	 * @throws \Exception
	 */
	private function getStatus() {
		if ($this->status) {
			return $this->status;
		}
		$key = 'remote/' . $this->url . '/status';
		$httpsKey = 'remote/' . $this->url . '/https';
		$status = $this->cache->get($key);
		if (!$status) {
			$response = $this->downloadStatus('https://' . $this->getUrl() . '/status.php');
			$protocol = 'https';
			if (!$response) {
				if ($status = $this->cache->get($httpsKey)) {
					throw new \Exception('refusing to connect to remote instance(' . $this->url . ') over http that was previously accessible over https');
				}
				$response = $this->downloadStatus('http://' . $this->getUrl() . '/status.php');
				$protocol = 'http';
			} else {
				$this->cache->set($httpsKey, true, 60 * 60 * 24 * 365);
			}
			$status = json_decode($response, true);
			if ($status) {
				$status['protocol'] = $protocol;
			}
			if ($status) {
				$this->cache->set($key, $status, 5 * 60);
				$this->status = $status;
			} else {
				throw new NotFoundException('Remote server not found at address ' . $this->url);
			}
		}
		return $status;
	}

	/**
	 * @param string $url
	 * @return bool|string
	 */
	private function downloadStatus($url) {
		try {
			$request = $this->clientService->newClient()->get($url);
			return $request->getBody();
		} catch (\Exception $e) {
			return false;
		}
	}
}