From ea71c367d9b34410a5b8f4ea855f0c4ebb1aba2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Herculano?= Date: Fri, 5 Apr 2024 19:43:07 +0200 Subject: [PATCH 1/3] make statuses properties public --- ConsentViewController/Classes/Consents/SPUSNatConsent.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ConsentViewController/Classes/Consents/SPUSNatConsent.swift b/ConsentViewController/Classes/Consents/SPUSNatConsent.swift index ef0402263..11d3af3e4 100644 --- a/ConsentViewController/Classes/Consents/SPUSNatConsent.swift +++ b/ConsentViewController/Classes/Consents/SPUSNatConsent.swift @@ -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? From 681dbfbd85dc0011b65cd1763ed5becc862f10b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Herculano?= Date: Fri, 5 Apr 2024 19:43:16 +0200 Subject: [PATCH 2/3] fix linting warning --- .../Classes/Views/iOS/SPWebViewExtensions.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ConsentViewController/Classes/Views/iOS/SPWebViewExtensions.swift b/ConsentViewController/Classes/Views/iOS/SPWebViewExtensions.swift index 1f7b46321..571308d96 100644 --- a/ConsentViewController/Classes/Views/iOS/SPWebViewExtensions.swift +++ b/ConsentViewController/Classes/Views/iOS/SPWebViewExtensions.swift @@ -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) ), From cfd58fbfd154c8036e7761fb93f3e6d5b8e8eef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Herculano?= Date: Fri, 5 Apr 2024 19:43:24 +0200 Subject: [PATCH 3/3] fix AuthExample app not build on gh actions --- Example/AuthExample/HomeViewController.swift | 2 + .../SPClientCoordinatorSpec.swift | 69 ++++++++++++++++--- 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/Example/AuthExample/HomeViewController.swift b/Example/AuthExample/HomeViewController.swift index 0852f6aad..386f3ab11 100644 --- a/Example/AuthExample/HomeViewController.swift +++ b/Example/AuthExample/HomeViewController.swift @@ -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)) diff --git a/Example/ConsentViewController_ExampleTests/SPClientCoordinator/SPClientCoordinatorSpec.swift b/Example/ConsentViewController_ExampleTests/SPClientCoordinator/SPClientCoordinatorSpec.swift index fe3167d72..ccb8f4efd 100644 --- a/Example/ConsentViewController_ExampleTests/SPClientCoordinator/SPClientCoordinatorSpec.swift +++ b/Example/ConsentViewController_ExampleTests/SPClientCoordinator/SPClientCoordinatorSpec.swift @@ -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() + } + } } } }