@@ -260,7 +260,7 @@ public async Task GetSubmodelRefByIdAsync_InvalidBase64_ThrowsInvalidUserInputEx
260260 [ Fact ]
261261 public async Task GetThumbnailAsync_ShouldReturnFileAttachmentResult ( )
262262 {
263- var expectedResult = new FileAttachmentResult ( new MemoryStream ( ) , "image/png" , "test.png" ) ;
263+ var expectedResult = new FileAttachmentResult ( new MemoryStream ( ) , "image/png" , "test.png" , 100 * 1024 * 1024 ) ;
264264 _aasRepositoryService . GetThumbnailAsync ( "https://example.com/aas" , Arg . Any < CancellationToken > ( ) )
265265 . Returns ( expectedResult ) ;
266266
@@ -270,6 +270,59 @@ public async Task GetThumbnailAsync_ShouldReturnFileAttachmentResult()
270270 Assert . Equal ( expectedResult , result ) ;
271271 }
272272
273+ [ Fact ]
274+ public async Task GetThumbnailAsync_CallsServiceWithDecodedAasIdentifier_WhenInputIsValid ( )
275+ {
276+ const string aasIdentifier = "https://example.com/aas" ;
277+ var encodedId = aasIdentifier . EncodeBase64Url ( ) ;
278+ var request = new GetThumbnailRequest ( encodedId ) ;
279+ var expectedResult = new FileAttachmentResult ( Stream . Null , "image/png" , "thumbnail.png" , 100 * 1024 * 1024 ) ;
280+
281+ _aasRepositoryService
282+ . GetThumbnailAsync ( aasIdentifier , Arg . Any < CancellationToken > ( ) )
283+ . Returns ( expectedResult ) ;
284+
285+ await _sut . GetThumbnailAsync ( request , CancellationToken . None ) ;
286+
287+ await _aasRepositoryService . Received ( 1 )
288+ . GetThumbnailAsync ( aasIdentifier , Arg . Any < CancellationToken > ( ) ) ;
289+ }
290+
291+ [ Fact ]
292+ public async Task GetThumbnailAsync_InvalidBase64AasIdentifier_ThrowsInvalidUserInputException ( )
293+ {
294+ const string invalidEncodedId = "!!invalid_base64@@" ;
295+ var request = new GetThumbnailRequest ( invalidEncodedId ) ;
296+
297+ await Assert . ThrowsAsync < InvalidUserInputException > ( ( ) =>
298+ _sut . GetThumbnailAsync ( request , CancellationToken . None ) ) ;
299+ }
300+
301+ [ Theory ]
302+ [ InlineData ( "../../../etc/passwd" ) ]
303+ [ InlineData ( "..\\ ..\\ ..\\ windows\\ system32" ) ]
304+ public async Task GetThumbnailAsync_MaliciousDecodedIdentifier_ThrowsInvalidUserInputException ( string maliciousIdentifier )
305+ {
306+ var request = new GetThumbnailRequest ( maliciousIdentifier . EncodeBase64Url ( ) ) ;
307+
308+ await Assert . ThrowsAsync < InvalidUserInputException > ( ( ) =>
309+ _sut . GetThumbnailAsync ( request , CancellationToken . None ) ) ;
310+ }
311+
312+ [ Fact ]
313+ public async Task GetThumbnailAsync_ServiceReturnsNull_ThrowsTemplateNotFoundException ( )
314+ {
315+ const string aasIdentifier = "https://example.com/aas" ;
316+ var request = new GetThumbnailRequest ( aasIdentifier . EncodeBase64Url ( ) ) ;
317+
318+ _aasRepositoryService
319+ . GetThumbnailAsync ( aasIdentifier , Arg . Any < CancellationToken > ( ) ) !
320+ . Returns ( ( FileAttachmentResult ) null ! ) ;
321+
322+ await Assert . ThrowsAsync < TemplateNotFoundException > ( ( ) =>
323+ _sut . GetThumbnailAsync ( request , CancellationToken . None ) ) ;
324+ }
325+
273326 private static AssetInformation CreateAssetInformation ( )
274327 {
275328 var thumbnail = Substitute . For < IResource > ( ) ;
0 commit comments