diff --git a/Sources/Packages/Sources/SecretKit/Erasers/AnySecretStore.swift b/Sources/Packages/Sources/SecretKit/Erasers/AnySecretStore.swift index 93d2460..af6e9b3 100644 --- a/Sources/Packages/Sources/SecretKit/Erasers/AnySecretStore.swift +++ b/Sources/Packages/Sources/SecretKit/Erasers/AnySecretStore.swift @@ -4,6 +4,7 @@ import Combine /// Type eraser for SecretStore. public class AnySecretStore: SecretStore, @unchecked Sendable { + let base: Any private let _isAvailable: @Sendable () -> Bool private let _id: @Sendable () -> UUID private let _name: @Sendable () -> String @@ -15,6 +16,7 @@ public class AnySecretStore: SecretStore, @unchecked Sendable { private let _reloadSecrets: @Sendable () async -> Void public init(_ secretStore: SecretStoreType) where SecretStoreType: SecretStore { + base = secretStore _isAvailable = { secretStore.isAvailable } _name = { secretStore.name } _id = { secretStore.id } diff --git a/Sources/Packages/Tests/SecretAgentKitTests/AgentTests.swift b/Sources/Packages/Tests/SecretAgentKitTests/AgentTests.swift index d5ffd37..8753456 100644 --- a/Sources/Packages/Tests/SecretAgentKitTests/AgentTests.swift +++ b/Sources/Packages/Tests/SecretAgentKitTests/AgentTests.swift @@ -35,7 +35,7 @@ class AgentTests: XCTestCase { // XCTAssertEqual(stubWriter.data, Constants.Responses.requestFailure) } - func testSignature() async { + func testSignature() async throws { let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature) let requestReader = OpenSSHReader(data: Constants.Requests.requestSignature[5...]) _ = requestReader.readNextChunk() @@ -63,10 +63,10 @@ class AgentTests: XCTestCase { let signature = try! P256.Signing.ECDSASignature(rawRepresentation: rs) let referenceValid = try! P256.Signing.PublicKey(x963Representation: Constants.Secrets.ecdsa256Secret.publicKey).isValidSignature(signature, for: dataToSign) let store = list.stores.first! - let derVerifies = try! store.verify(signature: signature.derRepresentation, for: dataToSign, with: AnySecret(Constants.Secrets.ecdsa256Secret)) - let invalidRandomSignature = try? store.verify(signature: "invalid".data(using: .utf8)!, for: dataToSign, with: AnySecret(Constants.Secrets.ecdsa256Secret)) - let invalidRandomData = try? store.verify(signature: signature.derRepresentation, for: "invalid".data(using: .utf8)!, with: AnySecret(Constants.Secrets.ecdsa256Secret)) - let invalidWrongKey = try? store.verify(signature: signature.derRepresentation, for: dataToSign, with: AnySecret(Constants.Secrets.ecdsa384Secret)) + let derVerifies = try await store.verify(signature: signature.derRepresentation, for: dataToSign, with: AnySecret(Constants.Secrets.ecdsa256Secret)) + let invalidRandomSignature = try await store.verify(signature: "invalid".data(using: .utf8)!, for: dataToSign, with: AnySecret(Constants.Secrets.ecdsa256Secret)) + let invalidRandomData = try await store.verify(signature: signature.derRepresentation, for: "invalid".data(using: .utf8)!, with: AnySecret(Constants.Secrets.ecdsa256Secret)) + let invalidWrongKey = try await store.verify(signature: signature.derRepresentation, for: dataToSign, with: AnySecret(Constants.Secrets.ecdsa384Secret)) XCTAssertTrue(referenceValid) XCTAssertTrue(derVerifies) XCTAssert(invalidRandomSignature == false) diff --git a/Sources/Packages/Tests/SecretAgentKitTests/StubFileHandleWriter.swift b/Sources/Packages/Tests/SecretAgentKitTests/StubFileHandleWriter.swift index 5b35aef..798a7e2 100644 --- a/Sources/Packages/Tests/SecretAgentKitTests/StubFileHandleWriter.swift +++ b/Sources/Packages/Tests/SecretAgentKitTests/StubFileHandleWriter.swift @@ -1,7 +1,7 @@ import Foundation import SecretAgentKit -class StubFileHandleWriter: FileHandleWriter { +class StubFileHandleWriter: FileHandleWriter, @unchecked Sendable { var data = Data() diff --git a/Sources/Packages/Tests/SecretAgentKitTests/StubStore.swift b/Sources/Packages/Tests/SecretAgentKitTests/StubStore.swift index f990f97..a390e25 100644 --- a/Sources/Packages/Tests/SecretAgentKitTests/StubStore.swift +++ b/Sources/Packages/Tests/SecretAgentKitTests/StubStore.swift @@ -6,7 +6,7 @@ struct Stub {} extension Stub { - public final class Store: SecretStore { + public final class Store: SecretStore, @unchecked Sendable { public let isAvailable = true public let id = UUID()