Skip to content

Commit

Permalink
add tests for adding custom headers into request
Browse files Browse the repository at this point in the history
  • Loading branch information
ondra-kormanik committed Jan 17, 2022
1 parent 49d7e07 commit 87bbd76
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 34 deletions.
73 changes: 40 additions & 33 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,56 +1,63 @@
PODS:
- Alamofire (4.9.1)
- Eureka (5.2.1)
- Google-Mobile-Ads-SDK (8.5.0):
- Google-Mobile-Ads-SDK (8.13.0):
- GoogleAppMeasurement (< 9.0, >= 7.0)
- GoogleUserMessagingPlatform (>= 1.1)
- GoogleAds-IMA-iOS-SDK (3.14.3)
- GoogleAppMeasurement (8.1.0):
- GoogleAppMeasurement/AdIdSupport (= 8.1.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.4)
- GoogleUtilities/MethodSwizzler (~> 7.4)
- GoogleUtilities/Network (~> 7.4)
- "GoogleUtilities/NSData+zlib (~> 7.4)"
- GoogleAppMeasurement (8.10.0):
- GoogleAppMeasurement/AdIdSupport (= 8.10.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.6)
- GoogleUtilities/MethodSwizzler (~> 7.6)
- GoogleUtilities/Network (~> 7.6)
- "GoogleUtilities/NSData+zlib (~> 7.6)"
- nanopb (~> 2.30908.0)
- GoogleAppMeasurement/AdIdSupport (8.1.0):
- GoogleUtilities/AppDelegateSwizzler (~> 7.4)
- GoogleUtilities/MethodSwizzler (~> 7.4)
- GoogleUtilities/Network (~> 7.4)
- "GoogleUtilities/NSData+zlib (~> 7.4)"
- GoogleAppMeasurement/AdIdSupport (8.10.0):
- GoogleAppMeasurement/WithoutAdIdSupport (= 8.10.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.6)
- GoogleUtilities/MethodSwizzler (~> 7.6)
- GoogleUtilities/Network (~> 7.6)
- "GoogleUtilities/NSData+zlib (~> 7.6)"
- nanopb (~> 2.30908.0)
- GoogleAppMeasurement/WithoutAdIdSupport (8.10.0):
- GoogleUtilities/AppDelegateSwizzler (~> 7.6)
- GoogleUtilities/MethodSwizzler (~> 7.6)
- GoogleUtilities/Network (~> 7.6)
- "GoogleUtilities/NSData+zlib (~> 7.6)"
- nanopb (~> 2.30908.0)
- GoogleUserMessagingPlatform (2.0.0)
- GoogleUtilities/AppDelegateSwizzler (7.4.1):
- GoogleUtilities/AppDelegateSwizzler (7.7.0):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (7.4.1):
- PromisesObjC (~> 1.2)
- GoogleUtilities/Logger (7.4.1):
- GoogleUtilities/Environment (7.7.0):
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.7.0):
- GoogleUtilities/Environment
- GoogleUtilities/MethodSwizzler (7.4.1):
- GoogleUtilities/MethodSwizzler (7.7.0):
- GoogleUtilities/Logger
- GoogleUtilities/Network (7.4.1):
- GoogleUtilities/Network (7.7.0):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.4.1)"
- GoogleUtilities/Reachability (7.4.1):
- "GoogleUtilities/NSData+zlib (7.7.0)"
- GoogleUtilities/Reachability (7.7.0):
- GoogleUtilities/Logger
- mopub-ios-sdk (5.17.0):
- mopub-ios-sdk/MoPubSDK (= 5.17.0)
- mopub-ios-sdk/Core (5.17.0)
- mopub-ios-sdk/MoPubSDK (5.17.0):
- mopub-ios-sdk (5.18.2):
- mopub-ios-sdk/MoPubSDK (= 5.18.2)
- mopub-ios-sdk/Core (5.18.2)
- mopub-ios-sdk/MoPubSDK (5.18.2):
- mopub-ios-sdk/Core
- mopub-ios-sdk/NativeAds
- mopub-ios-sdk/NativeAds (5.17.0):
- mopub-ios-sdk/NativeAds (5.18.2):
- mopub-ios-sdk/Core
- nanopb (2.30908.0):
- nanopb/decode (= 2.30908.0)
- nanopb/encode (= 2.30908.0)
- nanopb/decode (2.30908.0)
- nanopb/encode (2.30908.0)
- PromisesObjC (1.2.12)
- RxSwift (6.2.0)
- PromisesObjC (2.0.0)
- RxSwift (6.5.0)
- SVProgressHUD (2.2.5)

DEPENDENCIES:
Expand Down Expand Up @@ -89,15 +96,15 @@ CHECKOUT OPTIONS:
SPEC CHECKSUMS:
Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18
Eureka: c883105488e05bc65539f583246ecf9657cabbfe
Google-Mobile-Ads-SDK: 6f5c41bf73db1656e5b203ba9c31e3d0899a128d
Google-Mobile-Ads-SDK: 05e5d68bb42a61b2e5bef336a52789785605aa22
GoogleAds-IMA-iOS-SDK: 2a9b7b14bda4993306f05287f952dce41b5be4ad
GoogleAppMeasurement: 9ff7b9e23cced93a5a41736c09bdeb5b5b7fb111
GoogleAppMeasurement: a3311dbcf3ea651e5a070fe8559b57c174ada081
GoogleUserMessagingPlatform: ab890ce5f6620f293a21b6bdd82e416a2c73aeca
GoogleUtilities: f8a43108b38a68eebe8b3540e1f4f2d28843ce20
mopub-ios-sdk: 36d322902674b79b0560a1cb8d15af0548d364ea
GoogleUtilities: e0913149f6b0625b553d70dae12b49fc62914fd1
mopub-ios-sdk: 39dd404dc791e543979b91aa8e3b27197af91377
nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96
PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97
RxSwift: d356ab7bee873611322f134c5f9ef379fa183d8f
PromisesObjC: 68159ce6952d93e17b2dfe273b8c40907db5ba58
RxSwift: 5710a9e6b17f3c3d6e40d6e559b9fa1e813b2ef8
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6

PODFILE CHECKSUM: 70d3af733d91701648c67c4c4d29032fc0594841
Expand Down
2 changes: 1 addition & 1 deletion PrebidMobile/RequestBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class RequestBuilder: NSObject {
func setCustomHeaders(request: inout URLRequest) {
if !Prebid.shared.customHeaders.isEmpty {
for(headerName, headerValue) in Prebid.shared.customHeaders {
request.addValue(headerName, forHTTPHeaderField: headerValue)
request.addValue(headerValue, forHTTPHeaderField: headerName)
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions PrebidMobileTests/FetchingLogictests/RequestBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,21 @@ class RequestBuilderTests: XCTestCase, CLLocationManagerDelegate {
//then
XCTAssertEqual("appdomain.com", domain)
}

func testPostDataWithCustomHeaders() throws {
let headerField = "X-JamboJambo"
let headerValue = "value-of-the-header-field"

//given
Prebid.shared.clearCustomHeaders()
Prebid.shared.addCustomHeader(name: headerField, value: headerValue)

//when
let urlRequest = try getPostDataHelper(adUnit: adUnit).urlRequest

//then
XCTAssertEqual(headerValue, urlRequest.value(forHTTPHeaderField: headerField))
}

func testPostDataWithRubiconHost() throws {

Expand Down

0 comments on commit 87bbd76

Please sign in to comment.