@@ -562,7 +562,7 @@ func (suite *NotificationTestSuite) TestSecureTokenParsing() {
562
562
mockReceiver := func (ctx context.Context ) (<- chan syncer.Event , error ) {
563
563
capturedSDKKey = ctx .Value (SDKKey ).(string )
564
564
dataChan := make (chan syncer.Event )
565
- close ( dataChan ) // Close immediately as we don't need events
565
+ // Don't close the channel - let the test timeout handle cleanup
566
566
return dataChan , nil
567
567
}
568
568
@@ -574,6 +574,12 @@ func (suite *NotificationTestSuite) TestSecureTokenParsing() {
574
574
if tc .sdkKeyHeader != "" {
575
575
req .Header .Set (middleware .OptlySDKHeader , tc .sdkKeyHeader )
576
576
}
577
+
578
+ // Create a context with a short timeout to prevent hanging
579
+ ctx , cancel := context .WithTimeout (req .Context (), 100 * time .Millisecond )
580
+ defer cancel ()
581
+ req = req .WithContext (ctx )
582
+
577
583
rec := httptest .NewRecorder ()
578
584
579
585
// Execute request
@@ -588,11 +594,6 @@ func (suite *NotificationTestSuite) TestSecureTokenParsing() {
588
594
func (suite * NotificationTestSuite ) TestSecureTokenParsingIntegration () {
589
595
// Test that secure token parsing works end-to-end with actual notification flow
590
596
591
- // Test with secure token format
592
- req := httptest .NewRequest ("GET" , "/notifications/event-stream" , nil )
593
- req .Header .Set (middleware .OptlySDKHeader , "test_sdk_key:test_api_key" )
594
- rec := httptest .NewRecorder ()
595
-
596
597
// Create a mock receiver that verifies the SDK key context
597
598
mockReceiver := func (ctx context.Context ) (<- chan syncer.Event , error ) {
598
599
sdkKey := ctx .Value (SDKKey ).(string )
@@ -610,6 +611,11 @@ func (suite *NotificationTestSuite) TestSecureTokenParsingIntegration() {
610
611
611
612
suite .mux .Get ("/test-secure-notifications" , NotificationEventStreamHandler (mockReceiver ))
612
613
614
+ // Test with secure token format
615
+ req := httptest .NewRequest ("GET" , "/test-secure-notifications" , nil )
616
+ req .Header .Set (middleware .OptlySDKHeader , "test_sdk_key:test_api_key" )
617
+ rec := httptest .NewRecorder ()
618
+
613
619
// Create cancelable context for SSE
614
620
ctx , cancel := context .WithTimeout (req .Context (), 1 * time .Second )
615
621
defer cancel ()
0 commit comments