Skip to content

Commit 3dc4482

Browse files
authored
Release/2.0.3 (#10)
1 parent 71d1ffc commit 3dc4482

2 files changed

Lines changed: 57 additions & 57 deletions

File tree

‎composer.json‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
"psr/http-server-handler": "^1.0",
2929
"psr/http-server-middleware": "^1.0",
3030
"psr/log": "^3.0",
31-
"tiny-blocks/http": "^7.1",
31+
"tiny-blocks/http": "^7.2",
3232
"tiny-blocks/http-correlation-id": "^2.1"
3333
},
3434
"require-dev": {
35-
"ergebnis/composer-normalize": "^2.52",
36-
"guzzlehttp/psr7": "^3.0",
37-
"infection/infection": "^0.34",
38-
"phpstan/phpstan": "^2.2",
39-
"phpunit/phpunit": "^13.2",
40-
"sentry/sentry": "^4.0",
35+
"ergebnis/composer-normalize": "^2.54",
36+
"guzzlehttp/psr7": "^3.2",
37+
"infection/infection": "^0.35",
38+
"phpstan/phpstan": "^2.3",
39+
"phpunit/phpunit": "^13.4",
40+
"sentry/sentry": "^4.34",
4141
"slevomat/coding-standard": "^8.31",
4242
"slim/slim": "^4.15",
4343
"squizlabs/php_codesniffer": "^4.0"
@@ -82,7 +82,7 @@
8282
"test-file": "@php ./vendor/bin/phpunit --configuration phpunit.xml --no-coverage --filter",
8383
"tests": [
8484
"@php -d memory_limit=2G ./vendor/bin/phpunit --configuration phpunit.xml tests",
85-
"@php ./vendor/bin/infection --threads=max --logger-html=reports/coverage/mutation-report.html --coverage=reports/coverage"
85+
"@php ./vendor/bin/infection --threads=max --logger-html=reports/coverage/mutation-report.html"
8686
]
8787
}
8888
}

‎tests/Unit/Reporters/SentryReporterTest.php‎

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@ public function testReportWhenClientErrorThenNothingReachesSentry(): void
9696
self::assertNull($sentry->sent);
9797
}
9898

99+
public function testInitializedWithThenTheSdkNeverReadsTheRequestBody(): void
100+
{
101+
/** @Given the deployment values an application resolves from its environment */
102+
$dsn = 'https://examplePublicKey@o0.ingest.sentry.io/1';
103+
104+
/** @When a reporter is built from them */
105+
SentryReporter::initializedWith(dsn: $dsn, release: 'client-gateway@1.0.0', environment: 'development');
106+
107+
/** @Then the SDK is told never to read a body, so a password in one is never gathered */
108+
$options = SentrySdk::getCurrentHub()->getClient()?->getOptions();
109+
self::assertNotNull($options);
110+
self::assertSame('never', $options->getMaxRequestBodySize());
111+
self::assertFalse($options->shouldSendDefaultPii());
112+
}
113+
99114
public function testInitializedWithWhenDsnIsEmptyThenTheSdkStaysDisabled(): void
100115
{
101116
/** @Given an environment with reporting switched off */
@@ -431,55 +446,6 @@ public function testInitializedWithThenTheCurrentHubCarriesTheDeploymentValues()
431446
self::assertSame('1', $options->getDsn()?->getProjectId());
432447
}
433448

434-
public function testInitializedWithThenTheSdkNeverReadsTheRequestBody(): void
435-
{
436-
/** @Given the deployment values an application resolves from its environment */
437-
$dsn = 'https://examplePublicKey@o0.ingest.sentry.io/1';
438-
439-
/** @When a reporter is built from them */
440-
SentryReporter::initializedWith(dsn: $dsn, release: 'client-gateway@1.0.0', environment: 'development');
441-
442-
/** @Then the SDK is told never to read a body, so a password in one is never gathered */
443-
$options = SentrySdk::getCurrentHub()->getClient()?->getOptions();
444-
self::assertNotNull($options);
445-
self::assertSame('never', $options->getMaxRequestBodySize());
446-
self::assertFalse($options->shouldSendDefaultPii());
447-
}
448-
449-
public function testInitializedWithWhenTheSdkGathersTheRequestAndTheUserThenNeitherIsSent(): void
450-
{
451-
/** @Given a reporter built from the deployment values */
452-
SentryReporter::initializedWith(
453-
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/1',
454-
release: 'client-gateway@1.0.0',
455-
environment: 'development'
456-
);
457-
458-
/** @And an event carrying what the SDK gathers on its own while a login fails */
459-
$user = UserDataBag::createFromUserIdentifier(id: '0199a1b2-7c3d-7e4f-8a5b-6c7d8e9f0a1b')
460-
->setEmail(email: 'ana@example.com');
461-
462-
$event = Event::createEvent()
463-
->setUser(user: $user)
464-
->setRequest(request: [
465-
'url' => 'https://api.example.com/v1/sessions?phone=5511999999999',
466-
'data' => ['email' => 'ana@example.com', 'password' => 'correct horse'],
467-
'method' => 'POST',
468-
'headers' => ['Authorization' => ['Bearer token']],
469-
'query_string' => 'phone=5511999999999'
470-
]);
471-
472-
/** @When the SDK runs the hook it calls before sending */
473-
$options = SentrySdk::getCurrentHub()->getClient()?->getOptions();
474-
self::assertNotNull($options);
475-
$sent = ($options->getBeforeSendCallback())($event, null);
476-
477-
/** @Then the event leaves without the request and without the user */
478-
self::assertNotNull($sent);
479-
self::assertNull($sent->getUser());
480-
self::assertSame([], $sent->getRequest());
481-
}
482-
483449
public function testReportWhenTheConsumerReplacesTheRuleThenItsPriorityDecides(): void
484450
{
485451
/** @Given a request */
@@ -716,6 +682,40 @@ public function testReportWhenContextOverridesPriorityThenSeverityFollowsTheOver
716682
self::assertEquals(Severity::info(), $sentry->sent->getLevel());
717683
}
718684

685+
public function testInitializedWithWhenTheSdkGathersTheRequestAndTheUserThenNeitherIsSent(): void
686+
{
687+
/** @Given a reporter built from the deployment values */
688+
SentryReporter::initializedWith(
689+
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/1',
690+
release: 'client-gateway@1.0.0',
691+
environment: 'development'
692+
);
693+
694+
/** @And an event carrying what the SDK gathers on its own while a login fails */
695+
$user = UserDataBag::createFromUserIdentifier(id: '0199a1b2-7c3d-7e4f-8a5b-6c7d8e9f0a1b')
696+
->setEmail(email: 'ana@example.com');
697+
698+
$event = Event::createEvent()
699+
->setUser(user: $user)
700+
->setRequest(request: [
701+
'url' => 'https://api.example.com/v1/sessions?phone=5511999999999',
702+
'data' => ['email' => 'ana@example.com', 'password' => 'correct horse'],
703+
'method' => 'POST',
704+
'headers' => ['Authorization' => ['Bearer token']],
705+
'query_string' => 'phone=5511999999999'
706+
]);
707+
708+
/** @When the SDK runs the hook it calls before sending */
709+
$options = SentrySdk::getCurrentHub()->getClient()?->getOptions();
710+
self::assertNotNull($options);
711+
$sent = ($options->getBeforeSendCallback())($event, null);
712+
713+
/** @Then the event leaves without the request and without the user */
714+
self::assertNotNull($sent);
715+
self::assertNull($sent->getUser());
716+
self::assertSame([], $sent->getRequest());
717+
}
718+
719719
public function testReportWhenBothTheRequestAndTheExceptionTagTheSameNameThenTheExceptionWins(): void
720720
{
721721
/** @Given a request */

0 commit comments

Comments
 (0)