@@ -562,7 +562,7 @@ func (suite *NotificationTestSuite) TestSecureTokenParsing() {
562562 mockReceiver := func (ctx context.Context ) (<- chan syncer.Event , error ) {
563563 capturedSDKKey = ctx .Value (SDKKey ).(string )
564564 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
566566 return dataChan , nil
567567 }
568568
@@ -574,6 +574,12 @@ func (suite *NotificationTestSuite) TestSecureTokenParsing() {
574574 if tc .sdkKeyHeader != "" {
575575 req .Header .Set (middleware .OptlySDKHeader , tc .sdkKeyHeader )
576576 }
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+
577583 rec := httptest .NewRecorder ()
578584
579585 // Execute request
@@ -588,11 +594,6 @@ func (suite *NotificationTestSuite) TestSecureTokenParsing() {
588594func (suite * NotificationTestSuite ) TestSecureTokenParsingIntegration () {
589595 // Test that secure token parsing works end-to-end with actual notification flow
590596
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-
596597 // Create a mock receiver that verifies the SDK key context
597598 mockReceiver := func (ctx context.Context ) (<- chan syncer.Event , error ) {
598599 sdkKey := ctx .Value (SDKKey ).(string )
@@ -610,6 +611,11 @@ func (suite *NotificationTestSuite) TestSecureTokenParsingIntegration() {
610611
611612 suite .mux .Get ("/test-secure-notifications" , NotificationEventStreamHandler (mockReceiver ))
612613
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+
613619 // Create cancelable context for SSE
614620 ctx , cancel := context .WithTimeout (req .Context (), 1 * time .Second )
615621 defer cancel ()
0 commit comments