Skip to content

Commit 42284ae

Browse files
committed
Add 'access_key' to obfuscated body key defaults
Add `composer testbench:reset` command
1 parent 78d771b commit 42284ae

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# CHANGELOG
22

3-
## [v1.2.x (Unreleased)](https://github.com/onlime/laravel-http-client-global-logger/compare/v1.2.4...main)
3+
## [v1.2.x (Unreleased)](https://github.com/onlime/laravel-http-client-global-logger/compare/v1.2.5...main)
4+
5+
## [v1.2.5 (2025-06-29)](https://github.com/onlime/laravel-http-client-global-logger/compare/v1.2.4...v1.2.5)
6+
7+
- Add `access_key` to the `HTTP_CLIENT_GLOBAL_LOGGER_OBFUSCATE_BODY_KEYS` defaults, with additional Uri obfuscation testing.
8+
- Added `composer testbench:reset` script to reset the Orchestra Testbench environment, which caches the config.
49

510
## [v1.2.4 (2025-06-16)](https://github.com/onlime/laravel-http-client-global-logger/compare/v1.2.3...v1.2.4)
611

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@
5656
}
5757
},
5858
"scripts": {
59-
"test": "vendor/bin/pest",
59+
"testbench:reset": "echo RESETTING TESTBENCH; rm -rf vendor/orchestra/testbench-core/laravel-foo",
60+
"test": "pest",
61+
"pretest": "@testbench:reset",
6062
"test-coverage": "vendor/bin/pest --coverage",
6163
"format": "vendor/bin/pint"
6264
},

config/http-client-global-logger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
)),
105105
'body_keys' => explode(',', env(
106106
'HTTP_CLIENT_GLOBAL_LOGGER_OBFUSCATE_BODY_KEYS',
107-
'pass,password,token,apikey,access_token,refresh_token,id_token,client_secret'
107+
'pass,password,token,apikey,access_token,access_key,refresh_token,id_token,client_secret'
108108
)),
109109
],
110110

tests/HttpClientLoggerTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,43 @@ function setupLogger(): MockInterface
189189
],
190190
]);
191191

192+
it('obfuscates request uri via body obfuscation', function (string $uri, string $expected) {
193+
$logger = setupLogger();
194+
195+
$logger->shouldReceive('info')->withArgs(function ($message) use ($expected) {
196+
expect($message)->toContain('REQUEST: GET '.$expected);
197+
return true;
198+
})->once();
199+
200+
$logger->shouldReceive('info')->withArgs(function ($message) {
201+
expect($message)->toContain('RESPONSE: HTTP/1.1 200 OK');
202+
return true;
203+
})->once();
204+
205+
Http::fake([
206+
'*' => Http::response('', 200, [
207+
'Content-Type' => 'application/json',
208+
]),
209+
])->get($uri);
210+
})->with([
211+
'no-query-params' => [
212+
'https://example.com',
213+
'https://example.com',
214+
],
215+
'sensitive-query-param' => [
216+
'https://example.com?access_key=1234',
217+
'https://example.com?access_key=**********',
218+
],
219+
'other-query-param' => [
220+
'https://example.com?foo=bar&baz=qux',
221+
'https://example.com?foo=bar&baz=qux',
222+
],
223+
'mixed-query-params' => [
224+
'https://example.com?token=xyz&foo=bar&access_key=1234',
225+
'https://example.com?token=**********&foo=bar&access_key=**********',
226+
],
227+
]);
228+
192229
it('obfuscates response body', function (string $body, string $expected) {
193230
$logger = setupLogger();
194231

0 commit comments

Comments
 (0)