Skip to content

Commit e62c38a

Browse files
committed
AC-1065: Added validations on choosing image name with Adobe Stock
* Updated unit test case coverage
1 parent 6425e3d commit e62c38a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

AdobeStockImage/Test/Unit/Model/SaveImageTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,43 @@ public function imageDataProvider(): array
120120
]
121121
];
122122
}
123+
124+
/**
125+
* @return array
126+
*/
127+
public function getInvalidPathValues(): array
128+
{
129+
return [
130+
[
131+
$this->createMock(Document::class),
132+
'https://as2.ftcdn.net/jpg/500_FemVonDcttCeKiOXFk.jpg',
133+
'\\invalid chars\\'
134+
],
135+
[
136+
$this->createMock(Document::class),
137+
'https://as2.ftcdn.net/jpg/500_FemVonDcttCeKiOXFk.jpg',
138+
'{*invalid_path/\'chars}'
139+
],
140+
[
141+
$this->createMock(Document::class),
142+
'https://as2.ftcdn.net/jpg/500_FemVonDcttCeKiOXFk.jpg',
143+
'<img src=\"\" onerror=\"alert(0)\">'
144+
]
145+
];
146+
}
147+
148+
/**
149+
* Verify that path validation works if invalid characters are passed.
150+
*
151+
* @dataProvider getInvalidPathValues
152+
* @param Document $document
153+
* @param string $url
154+
* @param string $destinationPath
155+
* @throws LocalizedException
156+
*/
157+
public function testExecuteInvalidPath(Document $document, string $url, string $destinationPath): void
158+
{
159+
$this->expectException('Magento\Framework\Exception\LocalizedException');
160+
$this->saveImage->execute($document, $url, $destinationPath);
161+
}
123162
}

0 commit comments

Comments
 (0)