From 4778c99235d206fe20409a15fffca537c0086e8e Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Sat, 21 Mar 2020 23:29:22 -0700 Subject: [PATCH] Skething out tests --- SecretAgentKit/Agent.swift | 7 ++-- SecretAgentKitTests/AgentTests.swift | 40 +++++++++++++++++++ SecretAgentKitTests/SecretAgentKitTests.swift | 11 ----- Secretive.xcodeproj/project.pbxproj | 30 +++++++------- 4 files changed, 60 insertions(+), 28 deletions(-) create mode 100644 SecretAgentKitTests/AgentTests.swift delete mode 100644 SecretAgentKitTests/SecretAgentKitTests.swift diff --git a/SecretAgentKit/Agent.swift b/SecretAgentKit/Agent.swift index 25185ca..15bb6c5 100644 --- a/SecretAgentKit/Agent.swift +++ b/SecretAgentKit/Agent.swift @@ -38,7 +38,7 @@ extension Agent { switch requestType { case .requestIdentities: response.append(SSHAgent.ResponseType.agentIdentitiesAnswer.data) - response.append(try identities()) + response.append(identities()) os_log(.debug, "Agent returned %@", SSHAgent.ResponseType.agentIdentitiesAnswer.debugDescription) case .signRequest: response.append(SSHAgent.ResponseType.agentSignResponse.data) @@ -58,7 +58,7 @@ extension Agent { extension Agent { - func identities() throws -> Data { + func identities() -> Data { // TODO: RESTORE ONCE XCODE 11.4 IS GM let secrets = storeList.stores.flatMap { $0.secrets } // let secrets = storeList.stores.flatMap(\.secrets) @@ -103,7 +103,7 @@ extension Agent { case (.ellipticCurve, 384): rawRepresentation = try CryptoKit.P384.Signing.ECDSASignature(derRepresentation: derSignature).rawRepresentation default: - fatalError() + throw AgentError.unsupportedKeyType } @@ -154,6 +154,7 @@ extension Agent { enum AgentError: Error { case unhandledType case noMatchingKey + case unsupportedKeyType } } diff --git a/SecretAgentKitTests/AgentTests.swift b/SecretAgentKitTests/AgentTests.swift new file mode 100644 index 0000000..beed7ee --- /dev/null +++ b/SecretAgentKitTests/AgentTests.swift @@ -0,0 +1,40 @@ +import Foundation +import XCTest +import SecretKit +@testable import SecretAgentKit + +class AgentTests: XCTestCase { + + func testEmptyStores() { + let agent = Agent(storeList: SecretStoreList()) + } + + func testRequestTracer() { + // Request tracer should show for Xcode? + } + + func testWitnessObjection() { + + } + + func testWitnessSignature() { + + } + + func testIdentitiesList() { + + } + + func testSignature() { + + } + + func testSignatureException() { + + } + + func testUnhandledAdd() { + + } + +} diff --git a/SecretAgentKitTests/SecretAgentKitTests.swift b/SecretAgentKitTests/SecretAgentKitTests.swift deleted file mode 100644 index 540c1fc..0000000 --- a/SecretAgentKitTests/SecretAgentKitTests.swift +++ /dev/null @@ -1,11 +0,0 @@ -import XCTest -@testable import SecretAgentKit - -class SecretAgentKitTests: XCTestCase { - - func testExample() throws { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. - } - -} diff --git a/Secretive.xcodeproj/project.pbxproj b/Secretive.xcodeproj/project.pbxproj index 1c47f27..7b6986a 100644 --- a/Secretive.xcodeproj/project.pbxproj +++ b/Secretive.xcodeproj/project.pbxproj @@ -56,7 +56,7 @@ 5099A02B23FE352C0062B6F2 /* SmartCardSecret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099A02A23FE352C0062B6F2 /* SmartCardSecret.swift */; }; 5099A02E23FE56E10062B6F2 /* OpenSSHKeyWriter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099A02D23FE56E10062B6F2 /* OpenSSHKeyWriter.swift */; }; 5099A075240242BA0062B6F2 /* SecretAgentKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5099A06C240242BA0062B6F2 /* SecretAgentKit.framework */; }; - 5099A07C240242BA0062B6F2 /* SecretAgentKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099A07B240242BA0062B6F2 /* SecretAgentKitTests.swift */; }; + 5099A07C240242BA0062B6F2 /* AgentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099A07B240242BA0062B6F2 /* AgentTests.swift */; }; 5099A07E240242BA0062B6F2 /* SecretAgentKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 5099A06E240242BA0062B6F2 /* SecretAgentKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5099A08A240242C20062B6F2 /* SSHAgentProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099A089240242C20062B6F2 /* SSHAgentProtocol.swift */; }; 50A3B79124026B7600D209EA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50A3B79024026B7600D209EA /* Assets.xcassets */; }; @@ -252,7 +252,7 @@ 5099A06E240242BA0062B6F2 /* SecretAgentKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SecretAgentKit.h; sourceTree = ""; }; 5099A06F240242BA0062B6F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 5099A074240242BA0062B6F2 /* SecretAgentKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SecretAgentKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5099A07B240242BA0062B6F2 /* SecretAgentKitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretAgentKitTests.swift; sourceTree = ""; }; + 5099A07B240242BA0062B6F2 /* AgentTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgentTests.swift; sourceTree = ""; }; 5099A07D240242BA0062B6F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 5099A089240242C20062B6F2 /* SSHAgentProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHAgentProtocol.swift; sourceTree = ""; }; 50A3B78A24026B7500D209EA /* SecretAgent.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SecretAgent.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -537,7 +537,7 @@ 5099A07A240242BA0062B6F2 /* SecretAgentKitTests */ = { isa = PBXGroup; children = ( - 5099A07B240242BA0062B6F2 /* SecretAgentKitTests.swift */, + 5099A07B240242BA0062B6F2 /* AgentTests.swift */, 5099A07D240242BA0062B6F2 /* Info.plist */, ); path = SecretAgentKitTests; @@ -970,7 +970,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5099A07C240242BA0062B6F2 /* SecretAgentKitTests.swift in Sources */, + 5099A07C240242BA0062B6F2 /* AgentTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1400,11 +1400,11 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Developer ID Application"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = Z72PRUAWF6; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1417,6 +1417,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Brief; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -1430,11 +1431,11 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Developer ID Application"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = Z72PRUAWF6; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1447,6 +1448,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Brief; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -1521,8 +1523,8 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Secretive/Secretive.entitlements; - CODE_SIGN_IDENTITY = "Developer ID Application"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Secretive/Preview Content\""; @@ -1538,7 +1540,7 @@ MARKETING_VERSION = 1; PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = "Secretive - Host"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; name = Test; @@ -1572,8 +1574,8 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = SecretAgent/SecretAgent.entitlements; - CODE_SIGN_IDENTITY = "Developer ID Application"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_ASSET_PATHS = "\"SecretAgent/Preview Content\""; DEVELOPMENT_TEAM = Z72PRUAWF6; @@ -1588,7 +1590,7 @@ MARKETING_VERSION = 1; PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.SecretAgent; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = "Secretive - Secret Agent"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; name = Test;