datadir; $systemOptions['appstoreenabled'] = false; //it's likely that there is no app folder we can write in $config = $this->getMockBuilder('\OC\SystemConfig') ->disableOriginalConstructor() ->getMock(); $config->expects($this->any()) ->method('getValue') ->willReturnCallback(function ($key, $default) use ($systemOptions) { return $systemOptions[$key] ?? $default; }); return $config; } protected function setUp(): void { parent::setUp(); $this->datadir = \OC::$server->getTempManager()->getTemporaryFolder(); file_put_contents($this->datadir . '/.ncdata', '# Nextcloud data directory'); \OC::$server->getSession()->set('checkServer_succeeded', false); } protected function tearDown(): void { // clean up @unlink($this->datadir . '/.ncdata'); parent::tearDown(); } /** * Test that checkServer() returns no errors in the regular case. */ public function testCheckServer(): void { $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true ])); $this->assertEmpty($result); } /** * Test that checkServer() does not check the data dir validity * when the server is not installed yet (else the setup cannot * be run...) */ public function testCheckServerSkipDataDirValidityOnSetup(): void { // simulate old version that didn't have it unlink($this->datadir . '/.ncdata'); // even though ".ncdata" is missing, the error isn't // triggered to allow setup to run $result = \OC_Util::checkServer($this->getConfig([ 'installed' => false ])); $this->assertEmpty($result); } /** * Test that checkServer() does not check the data dir validity * when an upgrade is required (else the upgrade cannot be * performed...) */ public function testCheckServerSkipDataDirValidityOnUpgrade(): void { // simulate old version that didn't have it unlink($this->datadir . '/.ncdata'); $session = \OC::$server->getSession(); $oldCurrentVersion = $session->get('OC_Version'); // upgrade condition to simulate needUpgrade() === true $session->set('OC_Version', [6, 0, 0, 2]); // even though ".ncdata" is missing, the error isn't // triggered to allow for upgrade $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, 'version' => '6.0.0.1' ])); $this->assertEmpty($result); // restore versions $session->set('OC_Version', $oldCurrentVersion); } /** * Test that checkDataDirectoryValidity returns no error * when ".ncdata" is present. */ public function testCheckDataDirValidity(): void { $result = \OC_Util::checkDataDirectoryValidity($this->datadir); $this->assertEmpty($result); } /** * Test that checkDataDirectoryValidity and checkServer * both return an error when ".ncdata" is missing. */ public function testCheckDataDirValidityWhenFileMissing(): void { unlink($this->datadir . '/.ncdata'); $result = \OC_Util::checkDataDirectoryValidity($this->datadir); $this->assertEquals(1, count($result)); $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, 'version' => implode('.', \OCP\Util::getVersion()) ])); $this->assertCount(1, $result); } /** * Tests that no error is given when the datadir is writable */ public function testDataDirWritable(): void { $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, 'version' => implode('.', \OCP\Util::getVersion()) ])); $this->assertEmpty($result); } /** * Tests an error is given when the datadir is not writable */ public function testDataDirNotWritable(): void { $this->markTestSkipped('TODO: Disable because fails on drone'); chmod($this->datadir, 0300); $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, 'version' => implode('.', \OCP\Util::getVersion()) ])); $this->assertCount(1, $result); } /** * Tests no error is given when the datadir is not writable during setup */ public function testDataDirNotWritableSetup(): void { chmod($this->datadir, 0300); $result = \OC_Util::checkServer($this->getConfig([ 'installed' => false, 'version' => implode('.', \OCP\Util::getVersion()) ])); chmod($this->datadir, 0700); //needed for cleanup $this->assertEmpty($result); } } tonge/feat/add_retry_support_to_query_builder'>artonge/feat/add_retry_support_to_query_builder Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/LargeFileHelper.php
blob: 4d96e79ead4239e593b52d4efe15aa955c7b654e (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185