Skip to content

Commit

Permalink
Update to Swift 6
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino committed Nov 10, 2024
1 parent 7b86214 commit 954b706
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
11 changes: 4 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.10
// swift-tools-version:6.0
import PackageDescription

let package = Package(
Expand Down Expand Up @@ -56,16 +56,13 @@ let package = Package(
.target(name: "ImperialMicrosoft", dependencies: ["ImperialCore"], swiftSettings: swiftSettings),
.target(name: "ImperialShopify", dependencies: ["ImperialCore"], swiftSettings: swiftSettings),
.testTarget(name: "ImperialTests", dependencies: ["ImperialCore", "ImperialShopify"], swiftSettings: swiftSettings),
]
],
swiftLanguageModes: [.v5]
)

var swiftSettings: [SwiftSetting] {
[
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableUpcomingFeature("StrictConcurrency"),
.enableExperimentalFeature("StrictConcurrency=complete"),
.enableUpcomingFeature("FullTypedThrows"),
]
}
7 changes: 4 additions & 3 deletions Tests/ImperialTests/ImperialTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import XCTest
import Testing

@testable import ImperialCore

class ImperialTests: XCTestCase {
func testExists() {}
struct ImperialTests {
@Test func empty() {}
}
32 changes: 16 additions & 16 deletions Tests/ImperialTests/ShopifyTests.swift
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import Foundation
import Testing

@testable import ImperialShopify
import XCTest

final class ShopifyTests: XCTestCase {

func testDomainCheck() throws {

@Suite("Shopify Tests")
struct ShopifyTests {
@Test("Valid Shopify Domain") func domainCheck() throws {
let domain = "davidmuzi.myshopify.com"
XCTAssertTrue(URL(string: domain)!.isValidShopifyDomain())
#expect(URL(string: domain)!.isValidShopifyDomain())

let domain2 = "d4m3.myshopify.com"
XCTAssertTrue(URL(string: domain2)!.isValidShopifyDomain())
#expect(URL(string: domain2)!.isValidShopifyDomain())

let domain3 = "david-muzi.myshopify.com"
XCTAssertTrue(URL(string: domain3)!.isValidShopifyDomain())
#expect(URL(string: domain3)!.isValidShopifyDomain())

let domain4 = "david.muzi.myshopify.com"
XCTAssertTrue(URL(string: domain4)!.isValidShopifyDomain())
#expect(URL(string: domain4)!.isValidShopifyDomain())

let domain5 = "david#muzi.myshopify.com"
XCTAssertFalse(URL(string: domain5)!.isValidShopifyDomain())
#expect(!URL(string: domain5)!.isValidShopifyDomain())

let domain6 = "davidmuzi.myshopify.com.ca"
XCTAssertFalse(URL(string: domain6)!.isValidShopifyDomain())
#expect(!URL(string: domain6)!.isValidShopifyDomain())

let domain7 = "davidmuzi.square.com"
XCTAssertFalse(URL(string: domain7)!.isValidShopifyDomain())
#expect(!URL(string: domain7)!.isValidShopifyDomain())

let domain8 = "david*muzi.shopify.ca"
XCTAssertFalse(URL(string: domain8)!.isValidShopifyDomain())
#expect(!URL(string: domain8)!.isValidShopifyDomain())
}

func testHMACValidation() throws {

@Test("HMAC Validation") func hmacValidation() throws {
let url = URL(string: "https://domain.com/?code=0907a61c0c8d55e99db179b68161bc00&hmac=700e2dadb827fcc8609e9d5ce208b2e9cdaab9df07390d2cbca10d7c328fc4bf&shop=some-shop.myshopify.com&state=0.6784241404160823&timestamp=1337178173")!

let hmac = url.generateHMAC(key: "hush")
XCTAssertEqual(hmac, "700e2dadb827fcc8609e9d5ce208b2e9cdaab9df07390d2cbca10d7c328fc4bf")
#expect(hmac == "700e2dadb827fcc8609e9d5ce208b2e9cdaab9df07390d2cbca10d7c328fc4bf")
}
}

0 comments on commit 954b706

Please sign in to comment.