Skip to content

Commit f624c72

Browse files
authored
Merge pull request #8052 from woocommerce/issue/8046-add-frame-nonce
Products Onboarding: Add support for using `frame_nonce` in product previews
2 parents 7b905f4 + 78be945 commit f624c72

File tree

15 files changed

+897
-6
lines changed

15 files changed

+897
-6
lines changed

Fakes/Fakes/Networking.generated.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,7 @@ extension Networking.Site {
15101510
url: .fake(),
15111511
adminURL: .fake(),
15121512
loginURL: .fake(),
1513+
frameNonce: .fake(),
15131514
plan: .fake(),
15141515
isJetpackThePluginInstalled: .fake(),
15151516
isJetpackConnected: .fake(),

Networking/Networking/Model/Copiable/Models+Copiable.generated.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,7 @@ extension Networking.Site {
17851785
url: CopiableProp<String> = .copy,
17861786
adminURL: CopiableProp<String> = .copy,
17871787
loginURL: CopiableProp<String> = .copy,
1788+
frameNonce: CopiableProp<String> = .copy,
17881789
plan: CopiableProp<String> = .copy,
17891790
isJetpackThePluginInstalled: CopiableProp<Bool> = .copy,
17901791
isJetpackConnected: CopiableProp<Bool> = .copy,
@@ -1800,6 +1801,7 @@ extension Networking.Site {
18001801
let url = url ?? self.url
18011802
let adminURL = adminURL ?? self.adminURL
18021803
let loginURL = loginURL ?? self.loginURL
1804+
let frameNonce = frameNonce ?? self.frameNonce
18031805
let plan = plan ?? self.plan
18041806
let isJetpackThePluginInstalled = isJetpackThePluginInstalled ?? self.isJetpackThePluginInstalled
18051807
let isJetpackConnected = isJetpackConnected ?? self.isJetpackConnected
@@ -1816,6 +1818,7 @@ extension Networking.Site {
18161818
url: url,
18171819
adminURL: adminURL,
18181820
loginURL: loginURL,
1821+
frameNonce: frameNonce,
18191822
plan: plan,
18201823
isJetpackThePluginInstalled: isJetpackThePluginInstalled,
18211824
isJetpackConnected: isJetpackConnected,

Networking/Networking/Model/Site.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
2929
///
3030
public let loginURL: String
3131

32+
public let frameNonce: String
33+
3234
/// Short name for site's plan.
3335
///
3436
public let plan: String
@@ -82,13 +84,15 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
8284
let gmtOffset = try optionsContainer.decode(Double.self, forKey: .gmtOffset)
8385
let adminURL = try optionsContainer.decode(String.self, forKey: .adminURL)
8486
let loginURL = try optionsContainer.decode(String.self, forKey: .loginURL)
87+
let frameNonce = try optionsContainer.decode(String.self, forKey: .frameNonce)
8588

8689
self.init(siteID: siteID,
8790
name: name,
8891
description: description,
8992
url: url,
9093
adminURL: adminURL,
9194
loginURL: loginURL,
95+
frameNonce: frameNonce,
9296
plan: String(), // Not created on init. Added in supplementary API request.
9397
isJetpackThePluginInstalled: isJetpackThePluginInstalled,
9498
isJetpackConnected: isJetpackConnected,
@@ -107,6 +111,7 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
107111
url: String,
108112
adminURL: String,
109113
loginURL: String,
114+
frameNonce: String,
110115
plan: String,
111116
isJetpackThePluginInstalled: Bool,
112117
isJetpackConnected: Bool,
@@ -121,6 +126,7 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
121126
self.url = url
122127
self.adminURL = adminURL
123128
self.loginURL = loginURL
129+
self.frameNonce = frameNonce
124130
self.plan = plan
125131
self.isJetpackThePluginInstalled = isJetpackThePluginInstalled
126132
self.isJetpackConnected = isJetpackConnected
@@ -163,6 +169,7 @@ private extension Site {
163169
case jetpackConnectionActivePlugins = "jetpack_connection_active_plugins"
164170
case adminURL = "admin_url"
165171
case loginURL = "login_url"
172+
case frameNonce = "frame_nonce"
166173
}
167174

168175
enum PlanKeys: String, CodingKey {

Networking/Networking/Remote/AccountRemote.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class AccountRemote: Remote, AccountRemoteProtocol {
8585
let path = "me/sites"
8686
let parameters = [
8787
"fields": "ID,name,description,URL,options,jetpack,jetpack_connection",
88-
"options": "timezone,is_wpcom_store,woocommerce_is_active,gmt_offset,jetpack_connection_active_plugins,admin_url,login_url"
88+
"options": "timezone,is_wpcom_store,woocommerce_is_active,gmt_offset,jetpack_connection_active_plugins,admin_url,login_url,frame_nonce"
8989
]
9090

9191
let request = DotcomRequest(wordpressApiVersion: .mark1_1, method: .get, path: path, parameters: parameters)

Networking/NetworkingTests/Mapper/AccountMapperTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ final class AccountMapperTests: XCTestCase {
3535
XCTAssertEqual(first.url, "https://some-testing-url.testing.blog")
3636
XCTAssertEqual(first.adminURL, "https://some-testing-url.here/wp-admin/")
3737
XCTAssertEqual(first.loginURL, "https://some-testing-url.here/wp-login.php")
38+
XCTAssertEqual(first.frameNonce, "73ae7163d8")
3839
XCTAssertFalse(first.isJetpackCPConnected)
3940
XCTAssertTrue(first.isJetpackConnected)
4041
XCTAssertTrue(first.isJetpackThePluginInstalled)
@@ -52,6 +53,7 @@ final class AccountMapperTests: XCTestCase {
5253
XCTAssertEqual(second.url, "https://thoughts.testing.blog")
5354
XCTAssertEqual(second.adminURL, "https://thoughts.testing.blog/wp-admin/")
5455
XCTAssertEqual(second.loginURL, "https://thoughts.testing.blog/wp-login.php")
56+
XCTAssertEqual(second.frameNonce, "e7bfd785f0")
5557
XCTAssertTrue(second.isJetpackCPConnected)
5658
XCTAssertTrue(second.isJetpackConnected)
5759
XCTAssertFalse(second.isJetpackThePluginInstalled)

Storage/Storage.xcodeproj/project.pbxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@
392392
9302E3AB220E1CE900DA5018 /* CoreDataIterativeMigratorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataIterativeMigratorTests.swift; sourceTree = "<group>"; };
393393
933A272F2222344D00C2143A /* Logging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logging.swift; sourceTree = "<group>"; };
394394
A3821B262583F14863740A37 /* Pods-Storage.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Storage.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-Storage/Pods-Storage.debug.xcconfig"; sourceTree = "<group>"; };
395+
AE7DF9FA2919023100C4D1ED /* Model 77.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 77.xcdatamodel"; sourceTree = "<group>"; };
395396
AE93BE8F272C0E9F001B55EA /* GeneralStoreSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralStoreSettings.swift; sourceTree = "<group>"; };
396397
AEC4481B290853C300BAA299 /* Model 76.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 76.xcdatamodel"; sourceTree = "<group>"; };
397398
B505255320EE6914008090F5 /* StorageType+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StorageType+Extensions.swift"; sourceTree = "<group>"; };
@@ -1814,6 +1815,7 @@
18141815
DEC51AA4275B41BE009F3DF4 /* WooCommerce.xcdatamodeld */ = {
18151816
isa = XCVersionGroup;
18161817
children = (
1818+
AE7DF9FA2919023100C4D1ED /* Model 77.xcdatamodel */,
18171819
AEC4481B290853C300BAA299 /* Model 76.xcdatamodel */,
18181820
688908A328F8EB360081A07E /* Model 75.xcdatamodel */,
18191821
6889088D28F668330081A07E /* Model 74.xcdatamodel */,
@@ -1891,7 +1893,7 @@
18911893
DEC51ADE275B41BE009F3DF4 /* Model 47.xcdatamodel */,
18921894
DEC51ADF275B41BE009F3DF4 /* Model 19.xcdatamodel */,
18931895
);
1894-
currentVersion = AEC4481B290853C300BAA299 /* Model 76.xcdatamodel */;
1896+
currentVersion = AE7DF9FA2919023100C4D1ED /* Model 77.xcdatamodel */;
18951897
path = WooCommerce.xcdatamodeld;
18961898
sourceTree = "<group>";
18971899
versionGroupType = wrapper.xcdatamodel;

Storage/Storage/Model/MIGRATIONS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This file documents changes in the WCiOS Storage data model. Please explain any changes to the data model as well as any custom migrations.
44

5+
## Model 77 (Release 11.2.0.0)
6+
- @ealeksandrov 2022-11-07
7+
- Added `frameNonce` attribute to `Site` entity.
8+
59
## Model 76 (Release 11.0.0.0)
610
- @ealeksandrov 2022-10-26
711
- Added `loginURL` attribute to `Site` entity.

Storage/Storage/Model/Site+CoreDataProperties.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ extension Site {
1313
@NSManaged public var url: String?
1414
@NSManaged public var adminURL: String?
1515
@NSManaged public var loginURL: String?
16+
@NSManaged public var frameNonce: String?
1617
@NSManaged public var plan: String?
1718
@NSManaged public var isWooCommerceActive: NSNumber?
1819
@NSManaged public var isWordPressStore: NSNumber?

Storage/Storage/Model/WooCommerce.xcdatamodeld/.xccurrentversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<plist version="1.0">
44
<dict>
55
<key>_XCCurrentVersionName</key>
6-
<string>Model 76.xcdatamodel</string>
6+
<string>Model 77.xcdatamodel</string>
77
</dict>
88
</plist>

0 commit comments

Comments
 (0)