-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from torusresearch/fix_tests_master
fix: tests
- Loading branch information
Showing
3 changed files
with
34 additions
and
92 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 |
---|---|---|
|
@@ -26,62 +26,40 @@ final class IntegrationTests: XCTestCase { | |
IntegrationTests.sdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-test-ios-public", subVerifierDetails: [sub], network: .legacy(.CYAN)) | ||
} | ||
|
||
func test_getTorusKey() async { | ||
func test_getTorusKey() async throws { | ||
let TORUS_TEST_VERIFIER = "torus-test-health" | ||
// let TORUS_TEST_VERIFIER = "torus-google-dhruv-test" | ||
let exp1 = XCTestExpectation(description: "Should be able to get key") | ||
let email = "[email protected]" | ||
let jwt = try! generateIdToken(email: email) | ||
do { | ||
let data = try await IntegrationTests.sdk?.getTorusKey(verifier: TORUS_TEST_VERIFIER, verifierId: email, idToken: jwt) | ||
let finalKeyDataDict = data!.finalKeyData! | ||
let evmAddress = finalKeyDataDict.evmAddress | ||
XCTAssertEqual(evmAddress, "0x8AA6C8ddCD868873120aA265Fc63E3a2180375BA") | ||
exp1.fulfill() | ||
} catch { | ||
print(error) | ||
XCTFail(error.localizedDescription) | ||
} | ||
wait(for: [exp1], timeout: 15) | ||
let data = try await IntegrationTests.sdk?.getTorusKey(verifier: TORUS_TEST_VERIFIER, verifierId: email, idToken: jwt) | ||
let finalKeyDataDict = data!.finalKeyData! | ||
let evmAddress = finalKeyDataDict.evmAddress | ||
XCTAssertEqual(evmAddress, "0xC615aA03Dd8C9b2dc6F7c43cBDfF2c34bBa47Ec9") | ||
} | ||
|
||
|
||
|
||
let TORUS_TEST_EMAIL = "[email protected]"; | ||
let TORUS_IMPORT_EMAIL = "[email protected]"; | ||
|
||
let TORUS_EXTENDED_VERIFIER_EMAIL = "[email protected]"; | ||
let TORUS_TEST_EMAIL = "[email protected]" | ||
let TORUS_IMPORT_EMAIL = "[email protected]" | ||
|
||
let TORUS_TEST_VERIFIER = "torus-test-health"; | ||
let TORUS_EXTENDED_VERIFIER_EMAIL = "[email protected]" | ||
|
||
let TORUS_TEST_AGGREGATE_VERIFIER = "torus-test-health-aggregate"; | ||
let HashEnabledVerifier = "torus-test-verifierid-hash"; | ||
|
||
func test_Sapphire_getTorusKey() async { | ||
let TORUS_TEST_VERIFIER = "torus-test-health" | ||
|
||
let TORUS_TEST_AGGREGATE_VERIFIER = "torus-test-health-aggregate" | ||
let HashEnabledVerifier = "torus-test-verifierid-hash" | ||
|
||
func test_Sapphire_getTorusKey() async throws { | ||
let sub = SubVerifierDetails(loginType: .web, | ||
loginProvider: .google, | ||
clientId: "221898609709-obfn3p63741l5333093430j3qeiinaa8.apps.googleusercontent.com", | ||
verifier: "google-lrc", | ||
redirectURL: "com.googleusercontent.apps.238941746713-vfap8uumijal4ump28p9jd3lbe6onqt4:/oauthredirect", | ||
browserRedirectURL: "https://scripts.toruswallet.io/redirect.html") | ||
let sdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-test-ios-public", subVerifierDetails: [sub], network: .sapphire(.SAPPHIRE_DEVNET)) | ||
|
||
|
||
let exp1 = XCTestExpectation(description: "Should be able to get key") | ||
let email = "[email protected]" | ||
|
||
let jwt = try! generateIdToken(email: TORUS_TEST_EMAIL) | ||
do { | ||
let data = try await sdk.getTorusKey(verifier: TORUS_TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: jwt) | ||
let finalKeyDataDict = data.finalKeyData! | ||
let evmAddress = finalKeyDataDict.evmAddress | ||
XCTAssertEqual(evmAddress, "0x4924F91F5d6701dDd41042D94832bB17B76F316F") | ||
exp1.fulfill() | ||
} catch { | ||
print(error) | ||
XCTFail(error.localizedDescription) | ||
} | ||
wait(for: [exp1], timeout: 15) | ||
let data = try await sdk.getTorusKey(verifier: TORUS_TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: jwt) | ||
let finalKeyDataDict = data.finalKeyData! | ||
let evmAddress = finalKeyDataDict.evmAddress | ||
XCTAssertEqual(evmAddress, "0x81001206C06AD09b3611b593aEEd3A607d79871E") | ||
} | ||
} | ||
|
||
|
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,10 +1,3 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Michael Lee on 31/10/2021. | ||
// | ||
|
||
import CustomAuth | ||
import FetchNodeDetails | ||
import Foundation | ||
|
@@ -13,24 +6,7 @@ import TorusUtils | |
import XCTest | ||
import CommonSources | ||
|
||
final class StubURLProtocolTests: XCTestCase { | ||
// func testStubURLProtocol() { | ||
// let expectation = XCTestExpectation(description: "getTorusKey using stubbed URLSession should work") | ||
// let sessionConfiguration =c URLSessionConfiguration.ephemeral | ||
// sessionConfiguration.protocolClasses = [StubURLProtocol.self] | ||
// let urlSession = URLSession(configuration: sessionConfiguration) | ||
// let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "torus-direct-mock-ios", subVerifierDetails: [], factory: StubMockCASDKFactory(), network: .ROPSTEN, loglevel: .debug, urlSession: urlSession) | ||
// tdsdk.getTorusKey(verifier: "torus-direct-mock-ios", verifierId: "[email protected]", idToken: "eyJhbGciOiJSUzI1NiIsImtpZCI6ImFkZDhjMGVlNjIzOTU0NGFmNTNmOTM3MTJhNTdiMmUyNmY5NDMzNTIiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhen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0x22f2Ce611cE0d0ff4DA661d3a4C4B7A60B2b13F8") | ||
// XCTAssertEqual(data["privateKey"] as! String, "495b9a126c0c703caeaa5c561692d6778952c455789b0a2ba04312cfdc2e1bb9") | ||
// expectation.fulfill() | ||
// }.catch { err in | ||
// XCTFail(err.localizedDescription) | ||
// } | ||
// | ||
// wait(for: [expectation], timeout: 12000) | ||
// } | ||
} | ||
final class StubURLProtocolTests: XCTestCase {} | ||
|
||
public class StubMockTorusUtils: TorusUtils { | ||
override open func getTimestamp() -> TimeInterval { | ||
|
@@ -39,10 +15,7 @@ public class StubMockTorusUtils: TorusUtils { | |
return ret | ||
} | ||
|
||
override open func generatePrivateKeyData() -> Data? { | ||
// empty bytes | ||
// let ret = Data(count: 32) | ||
|
||
open func generatePrivateKeyData() -> Data? { | ||
let ret = Data(base64Encoded: "FBz7bssmbsV6jBWoOJpkVOu14+6/Xgyt1pxTycODG08=") | ||
|
||
print("[StubMockTorusUtils] generatePrivateKeyData(): ", ret!.bytes.toBase64()) | ||
|
@@ -51,11 +24,6 @@ public class StubMockTorusUtils: TorusUtils { | |
} | ||
|
||
public class StubMockCASDKFactory: CASDKFactoryProtocol { | ||
// public func createFetchNodeDetails(network: TorusNetwork, urlSession: URLSession, networkUrl: String? = nil) -> FetchNodeDetails { | ||
// let net = network == .MAINNET ? "0xf20336e16B5182637f09821c27BDe29b0AFcfe80" : "0x6258c9d6c12ed3edda59a1a6527e469517744aa7" | ||
// return FetchNodeDetails(proxyAddress: net, network: network, urlSession: urlSession) | ||
// } | ||
|
||
public func createTorusUtils(loglevel: OSLogType, urlSession: URLSession, enableOneKey: Bool, network: TorusNetwork) -> AbstractTorusUtils { | ||
let allowHost = network.signerMap.appending("/api/allow") | ||
let signerHost = network.signerMap.appending("/api/sign") | ||
|