Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed Sep 17, 2024
1 parent e3ec925 commit 9d1ff3f
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 32 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ let singleFactoreAuth = SingleFactorAuth(params: SFAParams)
Use the `getKey` function to login the user and get the privateKey and public address for the given user.

```swift
let idToken = try generateIdToken(email: TOURUS_TEST_EMAIL)
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(
verifier: TEST_VERIFIER,
verifierId: TOURUS_TEST_EMAIL,
verifierId: TORUS_TEST_EMAIL,
idToken: idToken
)

Expand Down
19 changes: 9 additions & 10 deletions Tests/SingleFactorAuthTests/AquaTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import BigInt
import JWTKit
import XCTest
import FetchNodeDetails

@testable import SingleFactorAuth
import SingleFactorAuth

final class AquaTest: XCTestCase {
var singleFactoreAuth: SingleFactorAuth!
var singleFactorAuthArgs: SFAParams!

let TOURUS_TEST_EMAIL = "[email protected]"
let TORUS_TEST_EMAIL = "[email protected]"
let TEST_VERIFIER = "torus-test-health"
let TEST_AGGREGRATE_VERIFIER = "torus-test-health-aggregate"

Expand All @@ -19,8 +18,8 @@ final class AquaTest: XCTestCase {
}

func testConnect() async throws {
let idToken = try generateIdToken(email: TOURUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TOURUS_TEST_EMAIL, idToken: idToken)
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken)
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)

let requiredPrivateKey = "d8204e9f8c270647294c54acd8d49ee208789f981a7503158e122527d38626d8"
Expand All @@ -29,18 +28,18 @@ final class AquaTest: XCTestCase {
}

func testInitialise() async throws {
let idToken = try generateIdToken(email: TOURUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TOURUS_TEST_EMAIL, idToken: idToken)
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken)
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)
let savedKey = try await singleFactoreAuth.initialize()
let requiredPrivateKey = "d8204e9f8c270647294c54acd8d49ee208789f981a7503158e122527d38626d8"
XCTAssertEqual(requiredPrivateKey, savedKey.getPrivateKey())
XCTAssertEqual(torusKey.publicAddress, savedKey.getPublicAddress())
XCTAssertEqual(torusKey.getPublicAddress(), savedKey.getPublicAddress())
}

func testAggregrateGetTorusKey() async throws {
let idToken = try generateIdToken(email: TOURUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_AGGREGRATE_VERIFIER, verifierId: TOURUS_TEST_EMAIL, idToken: idToken, subVerifierInfoArray: [TorusSubVerifierInfo(verifier: TEST_VERIFIER, idToken: idToken)])
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_AGGREGRATE_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken, subVerifierInfoArray: [TorusSubVerifierInfo(verifier: TEST_VERIFIER, idToken: idToken)])
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)

let requiredPrivateKey = "6f8b884f19975fb0d138ed21b22a6a7e1b79e37f611d0a29f1442b34efc6bacd"
Expand Down
19 changes: 9 additions & 10 deletions Tests/SingleFactorAuthTests/CyanTest.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import BigInt
import JWTKit
import XCTest

@testable import SingleFactorAuth
import SingleFactorAuth

final class CyanTest: XCTestCase {
var singleFactoreAuth: SingleFactorAuth!
var singleFactorAuthArgs: SFAParams!

let TOURUS_TEST_EMAIL = "[email protected]"
let TORUS_TEST_EMAIL = "[email protected]"
let TEST_VERIFIER = "torus-test-health"
let TEST_AGGREGRATE_VERIFIER = "torus-test-health-aggregate"

Expand All @@ -18,8 +17,8 @@ final class CyanTest: XCTestCase {
}

func testConnect() async throws {
let idToken = try generateIdToken(email: TOURUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TOURUS_TEST_EMAIL, idToken: idToken)
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken)
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)

let requiredPrivateKey = "223d982054fa1ad27d1497560521e4cce5b8c6438c38533c7bad27ff21ce0546"
Expand All @@ -28,18 +27,18 @@ final class CyanTest: XCTestCase {
}

func testInitialise() async throws {
let idToken = try generateIdToken(email: TOURUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TOURUS_TEST_EMAIL, idToken: idToken)
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken)
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)
let requiredPrivateKey = "223d982054fa1ad27d1497560521e4cce5b8c6438c38533c7bad27ff21ce0546"
let savedKey = try await singleFactoreAuth.initialize()
XCTAssertEqual(requiredPrivateKey, savedKey.getPrivateKey())
XCTAssertEqual(torusKey.publicAddress, savedKey.getPublicAddress())
XCTAssertEqual(torusKey.getPublicAddress(), savedKey.getPublicAddress())
}

func testAggregrateGetTorusKey() async throws {
let idToken = try generateIdToken(email: TOURUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_AGGREGRATE_VERIFIER, verifierId: TOURUS_TEST_EMAIL, idToken: idToken, subVerifierInfoArray: [TorusSubVerifierInfo(verifier: TEST_VERIFIER, idToken: idToken)])
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_AGGREGRATE_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken, subVerifierInfoArray: [TorusSubVerifierInfo(verifier: TEST_VERIFIER, idToken: idToken)])
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)

let requiredPrivateKey = "66af498ea82c95d52fdb8c8dedd44cf2f758424a0eecab7ac3dd8721527ea2d4"
Expand Down
49 changes: 49 additions & 0 deletions Tests/SingleFactorAuthTests/SapphireDevnetTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import BigInt
import JWTKit
import XCTest
import FetchNodeDetails
import SingleFactorAuth

final class SapphireDevnetTests: XCTestCase {
var singleFactoreAuth: SingleFactorAuth!
var singleFactorAuthArgs: SFAParams!

let TORUS_TEST_EMAIL = "[email protected]"
let TEST_VERIFIER = "torus-test-health"
let TEST_AGGREGRATE_VERIFIER = "torus-test-health-aggregate"

override func setUp() {
singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .sapphire(.SAPPHIRE_DEVNET))
singleFactoreAuth = try! SingleFactorAuth(params: singleFactorAuthArgs)
}

func testConnect() async throws {
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken)
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)

let requiredPrivateKey = "230dad9f42039569e891e6b066ff5258b14e9764ef5176d74aeb594d1a744203"
XCTAssertEqual(requiredPrivateKey, torusKey.getPrivateKey())
XCTAssertEqual("0x462A8BF111A55C9354425F875F89B22678c0Bc44", torusKey.getPublicAddress())
}

func testInitialise() async throws {
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken)
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)
let savedKey = try await singleFactoreAuth.initialize()
let requiredPrivateKey = "230dad9f42039569e891e6b066ff5258b14e9764ef5176d74aeb594d1a744203"
XCTAssertEqual(requiredPrivateKey, savedKey.getPrivateKey())
XCTAssertEqual(torusKey.getPublicAddress(), savedKey.getPublicAddress())
}

func testAggregrateGetTorusKey() async throws {
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_AGGREGRATE_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken, subVerifierInfoArray: [TorusSubVerifierInfo(verifier: TEST_VERIFIER, idToken: idToken)])
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)

let requiredPrivateKey = "edef171853fdf23ed3cfc702d32cf46f181b475a449d2f7b636924cabecd81d4"
XCTAssertEqual(requiredPrivateKey, torusKey.getPrivateKey())
XCTAssertEqual("0xfC58EB0475F1E3fa05877eE2e1350f6A619E2d78", torusKey.getPublicAddress())
}
}
49 changes: 49 additions & 0 deletions Tests/SingleFactorAuthTests/SapphireMainnetTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import BigInt
import JWTKit
import XCTest
import FetchNodeDetails
import SingleFactorAuth

final class SapphireMainnetTests: XCTestCase {
var singleFactoreAuth: SingleFactorAuth!
var singleFactorAuthArgs: SFAParams!

let TORUS_TEST_EMAIL = "[email protected]"
let TEST_VERIFIER = "torus-test-health"
let TEST_AGGREGRATE_VERIFIER = "torus-aggregate-sapphire-mainnet"

override func setUp() {
singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .sapphire(.SAPPHIRE_MAINNET))
singleFactoreAuth = try! SingleFactorAuth(params: singleFactorAuthArgs)
}

func testConnect() async throws {
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken)
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)

let requiredPrivateKey = "2c4b346a91ecd11fe8a02d111d00bd921bf9b543f0a1e811face91b5f28947d6"
XCTAssertEqual(requiredPrivateKey, torusKey.getPrivateKey())
XCTAssertEqual("0x0934d844a0a6db37CF75aF0269436ae1b2Ae5D36", torusKey.getPublicAddress())
}

func testInitialise() async throws {
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken)
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)
let savedKey = try await singleFactoreAuth.initialize()
let requiredPrivateKey = "2c4b346a91ecd11fe8a02d111d00bd921bf9b543f0a1e811face91b5f28947d6"
XCTAssertEqual(requiredPrivateKey, savedKey.getPrivateKey())
XCTAssertEqual(torusKey.getPublicAddress(), savedKey.getPublicAddress())
}

func testAggregrateGetTorusKey() async throws {
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_AGGREGRATE_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken, subVerifierInfoArray: [TorusSubVerifierInfo(verifier: TEST_VERIFIER, idToken: idToken)])
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)

let requiredPrivateKey = "0c724bb285560dc41e585b91aa2ded94fdd703c2e7133dcc64b1361b0d1fd105"
XCTAssertEqual(requiredPrivateKey, torusKey.getPrivateKey())
XCTAssertEqual("0xA92E2C756B5b2abABc127907b02D4707dc085612", torusKey.getPublicAddress())
}
}
19 changes: 9 additions & 10 deletions Tests/SingleFactorAuthTests/SingleFactorAuthTests.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import BigInt
import JWTKit
import XCTest

@testable import SingleFactorAuth
import SingleFactorAuth

final class SingleFactorAuthTests: XCTestCase {
var singleFactoreAuth: SingleFactorAuth!
var singleFactorAuthArgs: SFAParams!

let TOURUS_TEST_EMAIL = "[email protected]"
let TORUS_TEST_EMAIL = "[email protected]"
let TEST_VERIFIER = "torus-test-health"
let TEST_AGGREGRATE_VERIFIER = "torus-test-health-aggregate"

Expand All @@ -18,27 +17,27 @@ final class SingleFactorAuthTests: XCTestCase {
}

func testConnect() async throws {
let idToken = try generateIdToken(email: TOURUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TOURUS_TEST_EMAIL, idToken: idToken)
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken)
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)
let requiredPrivateKey = "296045a5599afefda7afbdd1bf236358baff580a0fe2db62ae5c1bbe817fbae4"
XCTAssertEqual(requiredPrivateKey, torusKey.getPrivateKey())
XCTAssertEqual("0x53010055542cCc0f2b6715a5c53838eC4aC96EF7", torusKey.getPublicAddress())
}

func testInitialise() async throws {
let idToken = try generateIdToken(email: TOURUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TOURUS_TEST_EMAIL, idToken: idToken)
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken)
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)
let savedKey = try await singleFactoreAuth.initialize()
let requiredPrivateKey = "296045a5599afefda7afbdd1bf236358baff580a0fe2db62ae5c1bbe817fbae4"
XCTAssertEqual(requiredPrivateKey, savedKey.getPrivateKey())
XCTAssertEqual(torusKey.publicAddress, savedKey.getPublicAddress())
XCTAssertEqual(torusKey.getPublicAddress(), savedKey.getPublicAddress())
}

func testAggregrateGetTorusKey() async throws {
let idToken = try generateIdToken(email: TOURUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_AGGREGRATE_VERIFIER, verifierId: TOURUS_TEST_EMAIL, idToken: idToken, subVerifierInfoArray: [TorusSubVerifierInfo(verifier: TEST_VERIFIER, idToken: idToken)])
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let loginParams = LoginParams(verifier: TEST_AGGREGRATE_VERIFIER, verifierId: TORUS_TEST_EMAIL, idToken: idToken, subVerifierInfoArray: [TorusSubVerifierInfo(verifier: TEST_VERIFIER, idToken: idToken)])
let torusKey = try await singleFactoreAuth.connect(loginParams: loginParams)

let requiredPrivateKey = "ad47959db4cb2e63e641bac285df1b944f54d1a1cecdaeea40042b60d53c35d2"
Expand Down

0 comments on commit 9d1ff3f

Please sign in to comment.