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

Add tests for legacy uspstring #564

Merged
merged 3 commits into from
Apr 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ extension SPUSNatConsent {

public extension SPUSNatConsent {
struct Statuses: CustomStringConvertible, Equatable {
let rejectedAny, consentedToAll, consentedToAny,
public let rejectedAny, consentedToAll, consentedToAny,
hasConsentData, sellStatus, shareStatus,
sensitiveDataStatus, gpcStatus: Bool?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import WebKit
/// * you should append query param `_sp_pass_consent=true` to your page (so the our web script knows it should wait for consent data)
/// * you need to call `preloadConsent` only _after_ the url been loaded into the webview (ie. after `.load(URLRequest)`)
func preloadConsent(from consents: SPUserData) {
guard
guard
let consentsData = try? JSONEncoder().encode(
PreloadConsentsPayload(consent: consents.webConsents)
),
Expand Down
2 changes: 2 additions & 0 deletions Example/AuthExample/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ class HomeViewController: UIViewController {
var accountId, propertyId, propertyName: String!

override func viewDidLoad() {
#if compiler(>=5.8) && DEBUG
if #available(iOS 16.4, *) {
webview.isInspectable = true
}
#endif
webview.cleanCache()
webview.navigationDelegate = self
webview.load(URLRequest(url: webviewUrl))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,18 +498,65 @@ class SPClientCoordinatorSpec: QuickSpec {
coordinator = coordinatorFor(campaigns: SPCampaigns(usnat: SPCampaign()))
}

it("can support legacy uspstring") {
coordinator = coordinatorFor(
campaigns: SPCampaigns(
usnat: SPCampaign(supportLegacyUSPString: true)
describe("with the supportLegacyUSPString flag") {
it("receives the IABUSPrivacy_String on GPPData") {
coordinator = coordinatorFor(
campaigns: SPCampaigns(
usnat: SPCampaign(supportLegacyUSPString: true)
)
)
)
waitUntil { done in
coordinator.loadMessages(forAuthId: nil, pubData: nil) { _ in
expect(
coordinator.userData.usnat?.consents?.GPPData?["IABUSPrivacy_String"]?.stringValue
).notTo(beEmpty())
done()
waitUntil { done in
coordinator.loadMessages(forAuthId: nil, pubData: nil) { _ in
let optedOutUspString = "1YYN"
let optedInUspString = "1YNN"
let newUserUspString = coordinator.userData.usnat?.consents?.GPPData?["IABUSPrivacy_String"]?.stringValue
expect(newUserUspString).to(equal(optedOutUspString))

let saveAndExitAcceptAction = SPAction(
type: .SaveAndExit,
campaignType: .usnat,
pmPayload: try! SPJson([
"shownCategories": [
"65a6a785cc78fac48ab34e65",
"65a6a785cc78fac48ab34e6a",
"65a6a785cc78fac48ab34e6f",
"65a6a785cc78fac48ab34e74",
"65a6a785cc78fac48ab34e79",
"65a6a785cc78fac48ab34e7e",
"65a6a785cc78fac48ab34e83",
"65a6a785cc78fac48ab34e88",
"65a6a785cc78fac48ab34e8d",
"65a6a785cc78fac48ab34e92",
"65a6a785cc78fac48ab34e97",
"65a6a785cc78fac48ab34e9c"
],
"privacyManagerId": "995256",
"lan": "EN",
"vendors": [],
"categories": [
"65a6a785cc78fac48ab34e65",
"65a6a785cc78fac48ab34e6a",
"65a6a785cc78fac48ab34e6f",
"65a6a785cc78fac48ab34e74",
"65a6a785cc78fac48ab34e79",
"65a6a785cc78fac48ab34e7e",
"65a6a785cc78fac48ab34e83",
"65a6a785cc78fac48ab34e88",
"65a6a785cc78fac48ab34e8d",
"65a6a785cc78fac48ab34e92",
"65a6a785cc78fac48ab34e97",
"65a6a785cc78fac48ab34e9c",
"648c9c48e17a3c7a82360c54"
]
])
)
coordinator.reportAction(saveAndExitAcceptAction) { result in
let actionUserData = try? result.get()
let actionUspString = actionUserData?.usnat?.consents?.GPPData?["IABUSPrivacy_String"]?.stringValue
expect(actionUspString).to(equal(optedInUspString))
done()
}
}
}
}
}
Expand Down
Loading