File tree Expand file tree Collapse file tree
tests/php/Unit/Service/File Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,4 +53,33 @@ public function fopen($mode) {
5353 $ this ->assertIsArray ($ result );
5454 $ this ->assertArrayHasKey ('chain ' , $ result );
5555 }
56+
57+ public function testGetCertificateChainHandlesInvalidResourceGracefully (): void {
58+ $ fileNode = new class () {
59+ public function fopen ($ mode ) {
60+ return false ;
61+ }
62+ };
63+
64+ $ libreSignFile = new File ();
65+ $ libreSignFile ->setSignedNodeId (1 );
66+
67+ $ pkcs12 = $ this ->createMock (Pkcs12Handler::class);
68+ $ pkcs12 ->expects ($ this ->never ())->method ('getCertificateChain ' );
69+
70+ $ logger = $ this ->createMock (LoggerInterface::class);
71+ $ logger
72+ ->expects ($ this ->once ())
73+ ->method ('warning ' )
74+ ->with ($ this ->stringContains ('unable to open signed file stream ' ));
75+
76+ $ service = new CertificateChainService ($ pkcs12 , $ logger );
77+
78+ $ options = new FileResponseOptions ();
79+ $ options ->validateFile (true );
80+
81+ $ result = $ service ->getCertificateChain ($ fileNode , $ libreSignFile , $ options );
82+
83+ $ this ->assertSame ([], $ result );
84+ }
5685}
You can’t perform that action at this time.
0 commit comments