@@ -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