@@ -854,6 +854,53 @@ class RequestHandlerTests: XCTestCase {
854854 NetworkHelper . isNetworkLoggingEnabled = false
855855 }
856856
857+ func testNetworkLoggingGetRequest( ) throws {
858+ // 1. Setup Mock Log Delegate
859+ class MockLogDelegate : NSObject , IterableLogDelegate {
860+ var loggedMessages : [ String ] = [ ]
861+ func log( level: LogLevel , message: String ) {
862+ loggedMessages. append ( message)
863+ }
864+ }
865+ let mockLogDelegate = MockLogDelegate ( )
866+ IterableLogUtil . sharedInstance = IterableLogUtil ( dateProvider: SystemDateProvider ( ) , logDelegate: mockLogDelegate)
867+
868+ // 2. Enable Network Logging
869+ NetworkHelper . isNetworkLoggingEnabled = true
870+
871+ // 3. Perform GET Request
872+ let expectation1 = expectation ( description: " GET Request success " )
873+ let networkSession = MockNetworkSession ( statusCode: 200 , data: " {} " . data ( using: . utf8) !)
874+
875+ networkSession. requestCallback = { request in
876+ expectation1. fulfill ( )
877+ }
878+
879+ let requestHandler = createRequestHandler ( networkSession: networkSession, notificationCenter: MockNotificationCenter ( ) , selectOffline: false )
880+
881+ let _ = requestHandler. getRemoteConfiguration ( )
882+
883+ wait ( for: [ expectation1] , timeout: testExpectationTimeout)
884+
885+ // Wait a little for async logging dispatch
886+ let loggingExpectation = expectation ( description: " Logging wait " )
887+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.5 ) {
888+ loggingExpectation. fulfill ( )
889+ }
890+ wait ( for: [ loggingExpectation] , timeout: 1.0 )
891+
892+ // 4. Verify Logs
893+ // Should see "sending request" but NOT "request body"
894+ let requestLogs = mockLogDelegate. loggedMessages. filter { $0. contains ( " sending request " ) }
895+ let bodyLogs = mockLogDelegate. loggedMessages. filter { $0. contains ( " request body " ) }
896+
897+ XCTAssertTrue ( requestLogs. count > 0 , " Should have logged request sending " )
898+ XCTAssertTrue ( bodyLogs. count == 0 , " Should NOT have logged body for GET request " )
899+
900+ // Cleanup
901+ NetworkHelper . isNetworkLoggingEnabled = false
902+ }
903+
857904 func testCreatedAtSentAtForOffline( ) throws {
858905 let expectation1 = expectation ( description: #function)
859906 let date = Date ( ) . addingTimeInterval ( - 5000 )
0 commit comments