summaryrefslogtreecommitdiffstats
path: root/lib/redmine/activity
Commit message (Expand)AuthorAgeFilesLines
* Use anonymous block forwarding introduced in Ruby 3.1 (#38585).Go MAEDA2024-08-211-1/+1
* Adds the date of the last activity to the list of available columns for Proje...Marius Balteanu2024-05-031-3/+8
* Remove current year from source file copyright headers and update year in foo...Marius Balteanu2024-02-261-1/+1
* Fix RuboCop offense Lint/SymbolConversion (#39887).Go MAEDA2023-12-201-1/+1
* Update copyright year to 2023 (#38141).Go MAEDA2023-01-011-1/+1
* Update copyright year in source files to 2022 (#36379).Go MAEDA2022-01-021-1/+1
* Update copyright year in source files to 2021 (#33069).Go MAEDA2021-03-251-1/+1
* remove spaces inside {} of lib/redmine/activity/fetcher.rbToshi MARUYAMA2020-11-151-1/+1
* add space after comma to lib/redmine/activity/fetcher.rbToshi MARUYAMA2020-11-151-1/+1
* Update copyright year in source files to 2020 (#33069).Go MAEDA2020-03-031-1/+1
* Update copyright year.Go MAEDA2019-05-251-1/+1
* Enable frozen_string_literal for some files under app and lib directory (#265...Go MAEDA2019-03-161-1/+1
* Add "frozen_string_literal: false" for all files (#26561).Go MAEDA2019-03-151-0/+2
* Update copyright.Jean-Philippe Lang2017-06-251-1/+1
* Updates copyright for 2016.Jean-Philippe Lang2016-03-131-1/+1
* Fixed that Redmine::Activity::Fetcher should consider activity provider permi...Jean-Philippe Lang2015-01-181-5/+20
* Copyright update.Jean-Philippe Lang2015-01-111-1/+1
* update copyright year (#15977)Toshi MARUYAMA2014-01-291-1/+1
* Copyright for 2013 (#12788).Jean-Philippe Lang2013-01-121-1/+1
* Copyright update.Jean-Philippe Lang2012-05-051-1/+1
* remove trailing white-spaces from lib/redmine/activity/fetcher.rb.Toshi MARUYAMA2011-09-011-17/+17
* Include visible subprojects when checking for available Activity event types....Eric Davis2010-07-061-1/+1
* Add etag check on the activity view to avoid rendering when not modified.Jean-Philippe Lang2009-10-251-1/+3
* Makes activity view accept a user_id param to show user's activity (#1002).Jean-Philippe Lang2008-11-301-1/+9
* Display latest user's activity on account/show view.Jean-Philippe Lang2008-11-301-2/+8
* Activity refactoring.Jean-Philippe Lang2008-07-271-0/+79
backport/47339/stable30'>backport/47339/stable30 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/FilesTest.php
blob: 1d26984ee72189b4eff2c9030e0468bde91f3e5e (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
132
133
134
135
136
137
<?php
/**
 * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
 *
 * @copyright Copyright (c) 2015, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

namespace Test;

class FilesTest extends \Test\TestCase {

	const UPLOAD_LIMIT_DEFAULT_STR = '511M';
	const UPLOAD_LIMIT_SETTING_STR = '2M';
	const UPLOAD_LIMIT_SETTING_BYTES = 2097152;

	/** @var array $tmpDirs */
	private $tmpDirs = [];

	/**
	 * @return array
	 */
	private function getUploadLimitTestFiles() {
		$dir = \OC::$server->getTempManager()->getTemporaryFolder();
		$this->tmpDirs[] = $dir;
		$result = [
			'.htaccess' => $dir . '/htaccess',
			'.user.ini' => $dir . '/user.ini'
		];
		copy(\OC::$SERVERROOT . '/tests/data/setUploadLimit/htaccess', $result['.htaccess']);
		copy(\OC::$SERVERROOT . '/tests/data/setUploadLimit/user.ini', $result['.user.ini']);
		return $result;
	}

	protected function tearDown() {
		foreach ($this->tmpDirs as $dir) {
			\OC_Helper::rmdirr($dir);
		}
		parent::tearDown();
	}

	public function testSetUploadLimitSizeSanity() {
		$this->assertFalse(\OC_Files::setUploadLimit(PHP_INT_MAX + 10));
		$this->assertFalse(\OC_Files::setUploadLimit(\OC_Files::UPLOAD_MIN_LIMIT_BYTES - 10));
		$this->assertFalse(\OC_Files::setUploadLimit('foobar'));
	}

	public function setUploadLimitWriteProvider() {
		return [
			[
				// both files writable
				true, true,
				self::UPLOAD_LIMIT_SETTING_BYTES, self::UPLOAD_LIMIT_SETTING_BYTES,
				self::UPLOAD_LIMIT_SETTING_STR, self::UPLOAD_LIMIT_SETTING_STR
			],
			[
				// neither file writable
				false, false,
				self::UPLOAD_LIMIT_SETTING_BYTES, false,
				self::UPLOAD_LIMIT_DEFAULT_STR, self::UPLOAD_LIMIT_DEFAULT_STR
			],
			[
				// only .htaccess writable
				true, false,
				self::UPLOAD_LIMIT_SETTING_BYTES, false,
				self::UPLOAD_LIMIT_SETTING_STR, self::UPLOAD_LIMIT_DEFAULT_STR
			],
			[
				// only .user.ini writable
				false, true,
				self::UPLOAD_LIMIT_SETTING_BYTES, false,
				self::UPLOAD_LIMIT_DEFAULT_STR, self::UPLOAD_LIMIT_SETTING_STR
			],
			[
				// test rounding of values
				true, true,
				self::UPLOAD_LIMIT_SETTING_BYTES + 20, self::UPLOAD_LIMIT_SETTING_BYTES,
				self::UPLOAD_LIMIT_SETTING_STR, self::UPLOAD_LIMIT_SETTING_STR
			]
		];
	}

	/**
	 * @dataProvider setUploadLimitWriteProvider
	 */
	public function testSetUploadLimitWrite(
		$htaccessWritable, $userIniWritable,
		$setSize, $expectedSize,
		$htaccessStr, $userIniStr
	) {
		$this->markTestSkipped('TODO: Disable because fails on drone');

		$files = $this->getUploadLimitTestFiles();
		chmod($files['.htaccess'], ($htaccessWritable ? 0644 : 0444));
		chmod($files['.user.ini'], ($userIniWritable ? 0644 : 0444));

		$htaccessSize = filesize($files['.htaccess']);
		$userIniSize = filesize($files['.user.ini']);
		$htaccessSizeMod = 2*(strlen($htaccessStr) - strlen(self::UPLOAD_LIMIT_DEFAULT_STR));
		$userIniSizeMod = 2*(strlen($userIniStr) - strlen(self::UPLOAD_LIMIT_DEFAULT_STR));

		$this->assertEquals($expectedSize, \OC_Files::setUploadLimit($setSize, $files));

		// check file contents
		$htaccess = file_get_contents($files['.htaccess']);
		$this->assertEquals(1,
			preg_match('/php_value upload_max_filesize '.$htaccessStr.'/', $htaccess)
		);
		$this->assertEquals(1,
			preg_match('/php_value post_max_size '.$htaccessStr.'/', $htaccess)
		);
		$this->assertEquals($htaccessSize + $htaccessSizeMod, filesize($files['.htaccess']));

		$userIni = file_get_contents($files['.user.ini']);
		$this->assertEquals(1,
			preg_match('/upload_max_filesize='.$userIniStr.'/', $userIni)
		);
		$this->assertEquals(1,
			preg_match('/post_max_size='.$userIniStr.'/', $userIni)
		);
		$this->assertEquals($userIniSize + $userIniSizeMod, filesize($files['.user.ini']));
	}
}