@@ -18,24 +18,21 @@ public function testApiFailedMessageFormat(): void
1818
1919 $ exception = InvalidArgumentException::apiFailed ($ guzzleException );
2020
21- self ::assertSame (
22- 'API call returned an invalid response: Connection refused. ' ,
23- $ exception ->getMessage ()
24- );
21+ self ::assertSame ('API call failed: 0 ' , $ exception ->getMessage ());
22+ self ::assertSame ($ guzzleException , $ exception ->getPrevious ());
2523 }
2624
27- public function testApiFailedPreservesExceptionMessage (): void
25+ public function testApiFailedDoesNotExposeRequestDetails (): void
2826 {
2927 $ guzzleException = new RequestException (
30- 'Timeout exceeded ' ,
31- new Request ('POST ' , 'https://example.com ' )
28+ 'Error with https://secret.example.com/api?key=abc123 ' ,
29+ new Request ('POST ' , 'https://secret. example.com/api?key=abc123 ' )
3230 );
3331
3432 $ exception = InvalidArgumentException::apiFailed ($ guzzleException );
3533
36- self ::assertStringStartsWith ('API call returned an invalid response: ' , $ exception ->getMessage ());
37- self ::assertStringEndsWith ('. ' , $ exception ->getMessage ());
38- self ::assertStringContainsString ('Timeout exceeded ' , $ exception ->getMessage ());
34+ self ::assertStringNotContainsString ('secret.example.com ' , $ exception ->getMessage ());
35+ self ::assertStringNotContainsString ('abc123 ' , $ exception ->getMessage ());
3936 }
4037
4138 public function testConfigVariableNotAString (): void
0 commit comments