| @@ 192-212 (lines=21) @@ | ||
| 189 | $this->assertEquals('testItCreatesFile-v2.txt', $newFile2->Name); |
|
| 190 | } |
|
| 191 | ||
| 192 | public function testItRestrictsCreateFileOnCanCreate() |
|
| 193 | { |
|
| 194 | $folder = $this->objFromFixture(Folder::class, 'folder1'); |
|
| 195 | ||
| 196 | $fileData = array('Upload' => $this->getUploadFile('Upload', 'disallowCanCreate.txt')); |
|
| 197 | $_FILES = $fileData; |
|
| 198 | $response = Director::test( |
|
| 199 | 'admin/assets/api/createFile', |
|
| 200 | array_merge( |
|
| 201 | $fileData, |
|
| 202 | [ |
|
| 203 | 'ParentID' => $folder->ID, |
|
| 204 | 'SecurityID' => SecurityToken::inst()->getValue(), |
|
| 205 | ] |
|
| 206 | ), |
|
| 207 | $this->session, |
|
| 208 | 'POST' |
|
| 209 | ); |
|
| 210 | $this->assertTrue($response->isError()); |
|
| 211 | $this->assertEquals(403, $response->getStatusCode()); |
|
| 212 | } |
|
| 213 | ||
| 214 | public function testItRestrictsCreateFileOnCanAddChildren() |
|
| 215 | { |
|
| @@ 214-235 (lines=22) @@ | ||
| 211 | $this->assertEquals(403, $response->getStatusCode()); |
|
| 212 | } |
|
| 213 | ||
| 214 | public function testItRestrictsCreateFileOnCanAddChildren() |
|
| 215 | { |
|
| 216 | $folder = $this->objFromFixture(Folder::class, 'disallowCanAddChildren'); |
|
| 217 | ||
| 218 | /** @skipUpgrade */ |
|
| 219 | $fileData = array('Upload' => $this->getUploadFile('Upload', 'test.txt')); |
|
| 220 | $_FILES = $fileData; |
|
| 221 | $response = Director::test( |
|
| 222 | 'admin/assets/api/createFile', |
|
| 223 | array_merge( |
|
| 224 | $fileData, |
|
| 225 | [ |
|
| 226 | 'ParentID' => $folder->ID, |
|
| 227 | 'SecurityID' => SecurityToken::inst()->getValue(), |
|
| 228 | ] |
|
| 229 | ), |
|
| 230 | $this->session, |
|
| 231 | 'POST' |
|
| 232 | ); |
|
| 233 | $this->assertTrue($response->isError()); |
|
| 234 | $this->assertEquals(403, $response->getStatusCode()); |
|
| 235 | } |
|
| 236 | ||
| 237 | public function testItRestrictsCreateFileOnExtension() |
|
| 238 | { |
|