◆ buildTestingObject()
| CustomIconTempUploadPathTest::buildTestingObject |
( |
string |
$temp_file_name, |
|
|
string |
$ilias_data_dir |
|
) |
| |
|
private |
Definition at line 42 of file CustomIconTempUploadPathTest.php.
46 return new class (
47 $temp_file_name,
48 $ilias_data_dir
50 #[\Override]
51 protected function getRealPath(
53 ): string|false {
54 $normalized = str_replace(
'\\',
'/',
$path);
56 return rtrim($normalized, '/');
57 }
58
60 return $normalized;
61 }
62
63 return false;
64 }
65 };
66 }
Resolves a user-supplied temp file identifier to an absolute path that is guaranteed to refer to a re...
◆ invalidTemporaryFileNameProvider()
| static CustomIconTempUploadPathTest::invalidTemporaryFileNameProvider |
( |
| ) |
|
|
static |
- Returns
- Generator<string, array{0: string}>
Definition at line 153 of file CustomIconTempUploadPathTest.php.
153 : Generator
154 {
155 yield 'parent directory segment' => ['..'];
156 yield 'current directory segment' => ['.'];
157 }
◆ skipIfVfsStreamNotAvailable()
| CustomIconTempUploadPathTest::skipIfVfsStreamNotAvailable |
( |
| ) |
|
|
private |
◆ testAbsentTempUploadFileIsRejected()
| CustomIconTempUploadPathTest::testAbsentTempUploadFileIsRejected |
( |
| ) |
|
Definition at line 115 of file CustomIconTempUploadPathTest.php.
115 : void
116 {
118
119 vfs\vfsStream::setup();
120 vfs\vfsStream::create([
121 'data' => [
122 'temp' => [],
123 ],
124 ]);
125
126 $data_dir = vfs\vfsStream::url(
'root/data');
127
128 $this->expectException(InvalidArgumentException::class);
129 $this->expectExceptionMessage('Temporary upload file not found.');
130
132 'missing.svg',
134 );
135 }
skipIfVfsStreamNotAvailable()
buildTestingObject(string $temp_file_name, string $ilias_data_dir)
References $data_dir.
◆ testInvalidTemporaryFileNameIsRejected()
| CustomIconTempUploadPathTest::testInvalidTemporaryFileNameIsRejected |
( |
string |
$malicious_input | ) |
|
Definition at line 138 of file CustomIconTempUploadPathTest.php.
140 : void {
141 $this->expectException(InvalidArgumentException::class);
142 $this->expectExceptionMessage('Invalid temporary upload file name.');
143
145 $malicious_input,
146 '/does/not/matter'
147 );
148 }
◆ testParentDirectorySegmentsInUserInputAreRejected()
| CustomIconTempUploadPathTest::testParentDirectorySegmentsInUserInputAreRejected |
( |
| ) |
|
Definition at line 92 of file CustomIconTempUploadPathTest.php.
92 : void
93 {
95
96 vfs\vfsStream::setup();
97 vfs\vfsStream::create([
98 'data' => [
99 'secret.txt' => 'sensitive',
100 'temp' => [],
101 ],
102 ]);
103
104 $data_dir = vfs\vfsStream::url(
'root/data');
105
106 $this->expectException(InvalidArgumentException::class);
107 $this->expectExceptionMessage('Temporary upload file not found.');
108
110 '../secret.txt',
112 );
113 }
References $data_dir.
◆ testTrustedTempUploadFileIsResolved()
| CustomIconTempUploadPathTest::testTrustedTempUploadFileIsResolved |
( |
| ) |
|
Definition at line 68 of file CustomIconTempUploadPathTest.php.
68 : void
69 {
71
72 vfs\vfsStream::setup();
73 vfs\vfsStream::create([
74 'data' => [
75 'temp' => [
76 'icon_upload.svg' => '<svg xmlns="http://www.w3.org/2000/svg"/>',
77 ],
78 ],
79 ]);
80
81 $data_dir = vfs\vfsStream::url(
'root/data');
82 $expected_file = vfs\vfsStream::url('root/data/temp/icon_upload.svg');
83
85 'icon_upload.svg',
87 );
88
89 self::assertSame($expected_file,
$path->getAbsolutePath());
90 }
References $data_dir, and $path.
◆ vfsStreamIsAvailable()
| CustomIconTempUploadPathTest::vfsStreamIsAvailable |
( |
| ) |
|
|
private |
The documentation for this class was generated from the following file: