From 1a0e4ba058af23a1e23f2a3fcb96657520caaff6 Mon Sep 17 00:00:00 2001 From: Valeriu Popa Date: Mon, 13 Nov 2023 10:09:15 +0200 Subject: [PATCH] tests update --- .../Tests/UnitTests/CR_CdbBidTests.m | 13 ++++++----- .../UnitTests/CR_SKAdNetworkImpressionTests.m | 3 --- .../CR_SKAdNetworkParametersTests.m | 22 +++++-------------- .../Tests/UnitTests/SampleBid.json | 11 +++++++--- .../Tests/UnitTests/Util/CR_URLOpenerTests.m | 22 +++++++++++-------- .../Utility/Checkers/CR_CreativeViewChecker.m | 3 --- 6 files changed, 35 insertions(+), 39 deletions(-) diff --git a/CriteoPublisherSdk/Tests/UnitTests/CR_CdbBidTests.m b/CriteoPublisherSdk/Tests/UnitTests/CR_CdbBidTests.m index 5908f6a61..880a3a42b 100644 --- a/CriteoPublisherSdk/Tests/UnitTests/CR_CdbBidTests.m +++ b/CriteoPublisherSdk/Tests/UnitTests/CR_CdbBidTests.m @@ -25,6 +25,7 @@ #import "CR_CdbResponse.h" #import "NSDictionary+Criteo.h" #import "NSString+CriteoUrl.h" +#import "CR_SKAdNetworkFidelityParameter.h" @interface CR_CdbBidTests : XCTestCase @@ -190,12 +191,14 @@ - (void)testInitialization { XCTAssertEqualObjects(nativeBid.skAdNetworkParameters.networkId, @"network"); XCTAssertEqualObjects(nativeBid.skAdNetworkParameters.campaignId, @1); XCTAssertEqualObjects(nativeBid.skAdNetworkParameters.iTunesItemId, @2); - XCTAssertEqualObjects( - nativeBid.skAdNetworkParameters.nonce, - [[NSUUID alloc] initWithUUIDString:@"ef50fece-faf4-4a5c-91b4-37e90b71a829"]); XCTAssertEqualObjects(nativeBid.skAdNetworkParameters.sourceAppId, @3); - XCTAssertEqualObjects(nativeBid.skAdNetworkParameters.timestamp, @4); - XCTAssertEqualObjects(nativeBid.skAdNetworkParameters.signature, @"signature"); + + CR_SKAdNetworkFidelityParameter *fidelity = + nativeBid.skAdNetworkParameters.fidelities.firstObject; + XCTAssertEqualObjects(fidelity.timestamp, @4); + XCTAssertEqualObjects(fidelity.signature, @"signature"); + XCTAssertEqualObjects( + fidelity.nonce, [[NSUUID alloc] initWithUUIDString:@"ef50fece-faf4-4a5c-91b4-37e90b71a829"]); } - (void)testEmptyInitialization { diff --git a/CriteoPublisherSdk/Tests/UnitTests/CR_SKAdNetworkImpressionTests.m b/CriteoPublisherSdk/Tests/UnitTests/CR_SKAdNetworkImpressionTests.m index 5c091e71c..1c5ee8834 100644 --- a/CriteoPublisherSdk/Tests/UnitTests/CR_SKAdNetworkImpressionTests.m +++ b/CriteoPublisherSdk/Tests/UnitTests/CR_SKAdNetworkImpressionTests.m @@ -57,10 +57,7 @@ - (void)testImpression { version:version campaignId:campaignId iTunesItemId:iTunesItemId - nonce:nonce - timestamp:timestamp sourceAppId:sourceAppId - signature:signature fidelities:[NSArray arrayWithObject:fidelity]]; CR_SKAdNetworkHandler *handler = [[CR_SKAdNetworkHandler alloc] initWithParameters:skAdNetworkParameters]; diff --git a/CriteoPublisherSdk/Tests/UnitTests/SKAdNetwork/CR_SKAdNetworkParametersTests.m b/CriteoPublisherSdk/Tests/UnitTests/SKAdNetwork/CR_SKAdNetworkParametersTests.m index e47062fd2..158abc864 100644 --- a/CriteoPublisherSdk/Tests/UnitTests/SKAdNetwork/CR_SKAdNetworkParametersTests.m +++ b/CriteoPublisherSdk/Tests/UnitTests/SKAdNetwork/CR_SKAdNetworkParametersTests.m @@ -62,10 +62,7 @@ - (void)testInitWithDict_GivenExpectedTypes_ReturnParameters { XCTAssertEqualObjects(parameters.networkId, networkId); XCTAssertEqualObjects(parameters.campaignId, campaignId); XCTAssertEqualObjects(parameters.iTunesItemId, iTunesItemId); - XCTAssertEqualObjects(parameters.nonce, nonce); XCTAssertEqualObjects(parameters.sourceAppId, sourceAppId); - XCTAssertEqualObjects(parameters.timestamp, timestamp); - XCTAssertEqualObjects(parameters.signature, signature); XCTAssertTrue(parameters.fidelities.count == 0); } @@ -93,10 +90,7 @@ - (void)testInitWithDict_GivenAlternateValidTypes_ReturnParameters { XCTAssertEqualObjects(parameters.networkId, networkId); XCTAssertEqualObjects(parameters.campaignId, campaignId); XCTAssertEqualObjects(parameters.iTunesItemId, iTunesItemId); - XCTAssertEqualObjects(parameters.nonce, nonce); XCTAssertEqualObjects(parameters.sourceAppId, sourceAppId); - XCTAssertEqualObjects(parameters.timestamp, timestamp); - XCTAssertEqualObjects(parameters.signature, signature); } - (void)testInitWithDict_GivenNil_ReturnNil { @@ -128,16 +122,18 @@ - (void)testToLoadProductParameters API_AVAILABLE(ios(14.0)) { NSNumber *timestamp = @(123457890); NSNumber *sourceAppId = @(87654321); NSString *signature = @"signature"; + CR_SKAdNetworkFidelityParameter *fidelityParam = + [[CR_SKAdNetworkFidelityParameter alloc] initWithFidelity:@1 + timestamp:timestamp + nonce:nonce + signature:signature]; CR_SKAdNetworkParameters *skAdNetworkParameters = [[CR_SKAdNetworkParameters alloc] initWithNetworkId:networkId version:version campaignId:campaignId iTunesItemId:iTunesItemId - nonce:nonce - timestamp:timestamp sourceAppId:sourceAppId - signature:signature - fidelities:[NSArray new]]; + fidelities:[NSArray arrayWithObject:fidelityParam]]; NSDictionary *loadProductParameters = skAdNetworkParameters.toLoadProductParameters; NSDictionary *expected = @{ SKStoreProductParameterAdNetworkVersion : version, @@ -155,21 +151,15 @@ - (void)testToLoadProductParameters API_AVAILABLE(ios(14.0)) { - (void)testInitWithDict_GivenEmptyFidelities { NSString *networkId = @"networkId"; NSString *version = @"2.0"; - NSUUID *nonce = [NSUUID UUID]; NSNumber *campaignId = @(42); NSNumber *iTunesItemId = @(12345678); - NSNumber *timestamp = @(123457890); NSNumber *sourceAppId = @(87654321); - NSString *signature = @"signature"; CR_SKAdNetworkParameters *skAdNetworkParameters = [[CR_SKAdNetworkParameters alloc] initWithNetworkId:networkId version:version campaignId:campaignId iTunesItemId:iTunesItemId - nonce:nonce - timestamp:timestamp sourceAppId:sourceAppId - signature:signature fidelities:[NSArray new]]; XCTAssertTrue(skAdNetworkParameters.fidelities.count == 0); } diff --git a/CriteoPublisherSdk/Tests/UnitTests/SampleBid.json b/CriteoPublisherSdk/Tests/UnitTests/SampleBid.json index 5bc493e53..e7fae30e1 100644 --- a/CriteoPublisherSdk/Tests/UnitTests/SampleBid.json +++ b/CriteoPublisherSdk/Tests/UnitTests/SampleBid.json @@ -59,10 +59,15 @@ "network" : "network", "campaign" : "1", "itunesItem" : "2", - "nonce" : "ef50fece-faf4-4a5c-91b4-37e90b71a829", "sourceApp" : "3", - "timestamp" : "4", - "signature" : "signature" + "fidelities": [ + { + "fidelity": "1", + "timestamp" : "4", + "signature" : "signature", + "nonce" : "ef50fece-faf4-4a5c-91b4-37e90b71a829" + } + ] } }, { diff --git a/CriteoPublisherSdk/Tests/UnitTests/Util/CR_URLOpenerTests.m b/CriteoPublisherSdk/Tests/UnitTests/Util/CR_URLOpenerTests.m index 721a8058c..62dccd512 100644 --- a/CriteoPublisherSdk/Tests/UnitTests/Util/CR_URLOpenerTests.m +++ b/CriteoPublisherSdk/Tests/UnitTests/Util/CR_URLOpenerTests.m @@ -22,6 +22,7 @@ #import "CR_URLOpener.h" #import "CR_SKAdNetworkParameters.h" +#import "CR_SKAdNetworkFidelityParameter.h" @interface CR_URLOpenerTests : XCTestCase @end @@ -65,15 +66,18 @@ - (void)testOpenAppStoreURLWithoutSKAdNetworkParameters { } - (CR_SKAdNetworkParameters *)buildParameters { - return [[CR_SKAdNetworkParameters alloc] initWithNetworkId:@"networkId" - version:@"2.0" - campaignId:@1 - iTunesItemId:@12345 - nonce:[NSUUID UUID] - timestamp:@123567890 - sourceAppId:@67890 - signature:@"tlkjlkj" - fidelities:[NSArray new]]; + CR_SKAdNetworkFidelityParameter *fidelityParam = + [[CR_SKAdNetworkFidelityParameter alloc] initWithFidelity:@1 + timestamp:@123567890 + nonce:[NSUUID UUID] + signature:@"tlkjlkj"]; + return + [[CR_SKAdNetworkParameters alloc] initWithNetworkId:@"networkId" + version:@"2.0" + campaignId:@1 + iTunesItemId:@12345 + sourceAppId:@67890 + fidelities:[NSArray arrayWithObject:fidelityParam]]; } @end diff --git a/CriteoPublisherSdk/Tests/Utility/Checkers/CR_CreativeViewChecker.m b/CriteoPublisherSdk/Tests/Utility/Checkers/CR_CreativeViewChecker.m index 1c04e54af..a462039b4 100644 --- a/CriteoPublisherSdk/Tests/Utility/Checkers/CR_CreativeViewChecker.m +++ b/CriteoPublisherSdk/Tests/Utility/Checkers/CR_CreativeViewChecker.m @@ -88,10 +88,7 @@ - (void)injectBidWithExpectedCreativeUrl:(NSString *)creativeUrl version:@"2.0" campaignId:@1 iTunesItemId:@2 - nonce:[NSUUID UUID] - timestamp:@3 sourceAppId:@4 - signature:@"signature" fidelities:[NSArray new]]); } CR_CdbBid *bid = bidBuilder.build;