Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed PrebidMobile/Version from User Agent #933

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion PrebidMobile/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
import UIKit

public let PrebidLocalCacheIdKey = "hb_cache_id_local"
public let PREBID_VERSION = "2.1.5"

@objc public class Constants: NSObject {
@objc public static let PREBID_VERSION = "2.1.5"
}

extension String {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@implementation PBMFunctions

+ (nonnull NSString *)sdkVersion {
NSString *version = [PBMFunctions infoPlistValueFor:@"CFBundleShortVersionString"];
NSString *version = Constants.PREBID_VERSION;
return version ? version : @"";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ - (instancetype)init {
#pragma mark - Public Methods

- (nonnull NSString *)getFullUserAgent {
return [NSString stringWithFormat:@"%@ PrebidMobile/%@", self.userAgent, self.sdkVersion];
return [NSString stringWithFormat:@"%@", self.userAgent];
}

#pragma mark - Private Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ class PBMUserAgentServiceTest: XCTestCase {

XCTAssert(userAgentString.PBMdoesMatch("AppleWebKit"))

//Should end with the SDK version
XCTAssert(userAgentString.PBMdoesMatch(" PrebidMobile/\(self.sdkVersion)$"))

self.expectationUserAgentExecuted?.fulfill()
}

Expand All @@ -54,13 +51,10 @@ class PBMUserAgentServiceTest: XCTestCase {
func testInjectedSDKVersion() {
let injectedSDKVersion = "x.y.z"
PBMUserAgentService.shared.sdkVersion = injectedSDKVersion
let userAgentString = PBMUserAgentService.shared.getFullUserAgent()

let didFindInjectedSDKVersion = userAgentString.PBMdoesMatch("PrebidMobile/\(injectedSDKVersion)")
XCTAssert(didFindInjectedSDKVersion)
let userAgentSDKVersion = PBMUserAgentService.shared.sdkVersion

let didFindDefaultSDKVersion = userAgentString.PBMdoesMatch("PrebidMobile/\(sdkVersion)")
XCTAssertFalse(didFindDefaultSDKVersion)
let didFindInjectedSDKVersion = userAgentSDKVersion?.PBMdoesMatch(injectedSDKVersion)
XCTAssert((didFindInjectedSDKVersion != nil))

PBMUserAgentService.shared.sdkVersion = PBMFunctions.sdkVersion()
}
Expand All @@ -72,18 +66,14 @@ class PBMUserAgentServiceTest: XCTestCase {
}

func testSharedSDKVersion() {
let userAgentString = PBMUserAgentService.shared.getFullUserAgent()
let didFindDefaultSDKVersion = userAgentString.PBMdoesMatch("PrebidMobile/\(sdkVersion)")
XCTAssert(didFindDefaultSDKVersion)
XCTAssert(sdkVersion == PBMUserAgentService.shared.sdkVersion)
}

func testFromBackgroundThread() {
let expectationCheckThread = self.expectation(description: "Check thread expectation")

DispatchQueue.global(qos: .background).async {
let userAgentString = PBMUserAgentService.shared.getFullUserAgent()
let didFindDefaultSDKVersion = userAgentString.PBMdoesMatch("PrebidMobile/\(self.sdkVersion)")
XCTAssert(didFindDefaultSDKVersion)
XCTAssert(self.sdkVersion == PBMUserAgentService.shared.sdkVersion)

expectationCheckThread.fulfill()
}
Expand Down