mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-01-07 20:17:09 +00:00
Base
This commit is contained in:
parent
c09ad3ecc1
commit
e332b7cb9d
@ -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<SecretStoreType>(_ secretStore: SecretStoreType) where SecretStoreType: SecretStore {
|
||||
base = secretStore
|
||||
_isAvailable = { secretStore.isAvailable }
|
||||
_name = { secretStore.name }
|
||||
_id = { secretStore.id }
|
||||
|
@ -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)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Foundation
|
||||
import SecretAgentKit
|
||||
|
||||
class StubFileHandleWriter: FileHandleWriter {
|
||||
class StubFileHandleWriter: FileHandleWriter, @unchecked Sendable {
|
||||
|
||||
var data = Data()
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user