Skip to content

Commit bb3ee43

Browse files
committed
Update site tests
1 parent 6cc1ad8 commit bb3ee43

File tree

4 files changed

+54
-29
lines changed

4 files changed

+54
-29
lines changed

Modules/Tests/NetworkingTests/Mapper/SiteListMapperTests.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ final class SiteListMapperTests: XCTestCase {
3737
let second = try XCTUnwrap(sites[safe: 1])
3838
XCTAssertFalse(second.hasSSOEnabled)
3939
}
40+
41+
func test_http_urls_are_converted_to_https() throws {
42+
// Given
43+
let sites = mapLoadHTTPSiteListResponse()
44+
45+
// Then
46+
let site = try XCTUnwrap(sites.first)
47+
XCTAssertTrue(site.url.hasPrefix("https://"), "Site URL should be converted to HTTPS")
48+
XCTAssertTrue(site.adminURL.hasPrefix("https://"), "Admin URL should be converted to HTTPS")
49+
XCTAssertTrue(site.loginURL.hasPrefix("https://"), "Login URL should be converted to HTTPS")
50+
51+
XCTAssertEqual(site.url, "https://insecure-site.testing.blog")
52+
XCTAssertEqual(site.adminURL, "https://insecure-site.testing.blog/wp-admin/")
53+
XCTAssertEqual(site.loginURL, "https://insecure-site.testing.blog/wp-login.php")
54+
}
4055
}
4156

4257
private extension SiteListMapperTests {
@@ -55,4 +70,8 @@ private extension SiteListMapperTests {
5570
func mapLoadMalformedSiteListResponse() -> [Site] {
5671
return mapSiteListData(from: "sites-malformed")
5772
}
73+
74+
func mapLoadHTTPSiteListResponse() -> [Site] {
75+
return mapSiteListData(from: "sites-http")
76+
}
5877
}

Modules/Tests/NetworkingTests/Model/SiteTests.swift

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"sites": [
3+
{
4+
"ID": 7777888899990000,
5+
"name": "HTTP Site",
6+
"description": "Testing HTTP to HTTPS conversion",
7+
"URL": "http://insecure-site.testing.blog",
8+
"capabilities": {
9+
"edit_pages": true,
10+
"edit_posts": true,
11+
"manage_options": true,
12+
"own_site": true
13+
},
14+
"jetpack": true,
15+
"jetpack_connection": true,
16+
"was_ecommerce_trial": false,
17+
"plan": {
18+
"product_id": 1008,
19+
"product_slug": "business-bundle"
20+
},
21+
"jetpack_modules": [],
22+
"options": {
23+
"timezone": "",
24+
"gmt_offset": 0,
25+
"blog_public": 1,
26+
"login_url": "http://insecure-site.testing.blog/wp-login.php",
27+
"admin_url": "http://insecure-site.testing.blog/wp-admin/",
28+
"is_wpcom_store": true,
29+
"woocommerce_is_active": true,
30+
"frame_nonce": "abc123def4"
31+
}
32+
}
33+
]
34+
}

WooCommerce/WooCommerce.xcodeproj/xcshareddata/xcschemes/WooCommerce.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
</CommandLineArgument>
149149
<CommandLineArgument
150150
argument = "-simulate-stripe-card-reader"
151-
isEnabled = "NO">
151+
isEnabled = "YES">
152152
</CommandLineArgument>
153153
<CommandLineArgument
154154
argument = "-force-crash-logging 1"

0 commit comments

Comments
 (0)