-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b86214
commit 954b706
Showing
3 changed files
with
24 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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×tamp=1337178173")! | ||
|
||
let hmac = url.generateHMAC(key: "hush") | ||
XCTAssertEqual(hmac, "700e2dadb827fcc8609e9d5ce208b2e9cdaab9df07390d2cbca10d7c328fc4bf") | ||
#expect(hmac == "700e2dadb827fcc8609e9d5ce208b2e9cdaab9df07390d2cbca10d7c328fc4bf") | ||
} | ||
} |