Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7ece35421 | |||
| 8dd3200ae3 | |||
| 48f008a26e | |||
| 0dda3a7208 | |||
| c218c1fbea | |||
| 68515bdc2c | |||
| f38046bb9e | |||
| e804dd0452 | |||
| 04c6084a8f | |||
| fbc549973b | |||
| 4ad7ca14e6 | |||
| 582f74e305 | |||
| 1758691bc2 | |||
| 2a21d9d0d1 |
@@ -7,11 +7,12 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
BFFB19D61A4870A300CCFFC3 /* Locksmith.h in Headers */ = {isa = PBXBuildFile; fileRef = BFFB19D51A4870A300CCFFC3 /* Locksmith.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
9D60D8141B10927B00BE14A9 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9D60D8131B10927B00BE14A9 /* Info.plist */; };
|
||||
9DF0A2C01B0E394F0049F83A /* Locksmith.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DF0A2BE1B0E394F0049F83A /* Locksmith.swift */; };
|
||||
9DF0A2C11B0E394F0049F83A /* LocksmithRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DF0A2BF1B0E394F0049F83A /* LocksmithRequest.swift */; };
|
||||
9DF0A2C81B0E3D370049F83A /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9DF0A2C71B0E3D370049F83A /* Info.plist */; };
|
||||
BFFB19DC1A4870A300CCFFC3 /* Locksmith.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BFFB19D01A4870A300CCFFC3 /* Locksmith.framework */; };
|
||||
BFFB19E31A4870A300CCFFC3 /* LocksmithTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFFB19E21A4870A300CCFFC3 /* LocksmithTests.swift */; };
|
||||
BFFB19EE1A4870E400CCFFC3 /* LocksmithRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFFB19EC1A4870E400CCFFC3 /* LocksmithRequest.swift */; };
|
||||
BFFB19EF1A4870E400CCFFC3 /* Locksmith.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFFB19ED1A4870E400CCFFC3 /* Locksmith.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -25,14 +26,13 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
9D60D8131B10927B00BE14A9 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Pod/Info.plist; sourceTree = SOURCE_ROOT; };
|
||||
9DF0A2BE1B0E394F0049F83A /* Locksmith.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Locksmith.swift; path = Pod/Classes/Locksmith.swift; sourceTree = SOURCE_ROOT; };
|
||||
9DF0A2BF1B0E394F0049F83A /* LocksmithRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LocksmithRequest.swift; path = Pod/Classes/LocksmithRequest.swift; sourceTree = SOURCE_ROOT; };
|
||||
9DF0A2C71B0E3D370049F83A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
BFFB19D01A4870A300CCFFC3 /* Locksmith.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Locksmith.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BFFB19D41A4870A300CCFFC3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
BFFB19D51A4870A300CCFFC3 /* Locksmith.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Locksmith.h; sourceTree = "<group>"; };
|
||||
BFFB19DB1A4870A300CCFFC3 /* LocksmithTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LocksmithTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BFFB19E11A4870A300CCFFC3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
BFFB19E21A4870A300CCFFC3 /* LocksmithTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocksmithTests.swift; sourceTree = "<group>"; };
|
||||
BFFB19EC1A4870E400CCFFC3 /* LocksmithRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocksmithRequest.swift; sourceTree = "<group>"; };
|
||||
BFFB19ED1A4870E400CCFFC3 /* Locksmith.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Locksmith.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -75,9 +75,8 @@
|
||||
BFFB19D21A4870A300CCFFC3 /* Locksmith */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BFFB19EC1A4870E400CCFFC3 /* LocksmithRequest.swift */,
|
||||
BFFB19ED1A4870E400CCFFC3 /* Locksmith.swift */,
|
||||
BFFB19D51A4870A300CCFFC3 /* Locksmith.h */,
|
||||
9DF0A2BE1B0E394F0049F83A /* Locksmith.swift */,
|
||||
9DF0A2BF1B0E394F0049F83A /* LocksmithRequest.swift */,
|
||||
BFFB19D31A4870A300CCFFC3 /* Supporting Files */,
|
||||
);
|
||||
path = Locksmith;
|
||||
@@ -86,7 +85,7 @@
|
||||
BFFB19D31A4870A300CCFFC3 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BFFB19D41A4870A300CCFFC3 /* Info.plist */,
|
||||
9D60D8131B10927B00BE14A9 /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
@@ -103,7 +102,7 @@
|
||||
BFFB19E01A4870A300CCFFC3 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BFFB19E11A4870A300CCFFC3 /* Info.plist */,
|
||||
9DF0A2C71B0E3D370049F83A /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
@@ -115,7 +114,6 @@
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
BFFB19D61A4870A300CCFFC3 /* Locksmith.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -198,6 +196,7 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9D60D8141B10927B00BE14A9 /* Info.plist in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -205,6 +204,7 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9DF0A2C81B0E3D370049F83A /* Info.plist in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -215,8 +215,8 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
BFFB19EF1A4870E400CCFFC3 /* Locksmith.swift in Sources */,
|
||||
BFFB19EE1A4870E400CCFFC3 /* LocksmithRequest.swift in Sources */,
|
||||
9DF0A2C11B0E394F0049F83A /* LocksmithRequest.swift in Sources */,
|
||||
9DF0A2C01B0E394F0049F83A /* Locksmith.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -274,7 +274,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
@@ -314,7 +314,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
@@ -327,11 +327,12 @@
|
||||
BFFB19E71A4870A300CCFFC3 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = Locksmith/Info.plist;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/Pod/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -343,11 +344,12 @@
|
||||
BFFB19E81A4870A300CCFFC3 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = Locksmith/Info.plist;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/Pod/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -367,7 +369,7 @@
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = LocksmithTests/Info.plist;
|
||||
INFOPLIST_FILE = LockSmithTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
@@ -380,7 +382,7 @@
|
||||
"$(SDKROOT)/Developer/Library/Frameworks",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = LocksmithTests/Info.plist;
|
||||
INFOPLIST_FILE = LockSmithTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0630"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BFFB19CF1A4870A300CCFFC3"
|
||||
BuildableName = "Locksmith.framework"
|
||||
BlueprintName = "Locksmith"
|
||||
ReferencedContainer = "container:Locksmith.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BFFB19DA1A4870A300CCFFC3"
|
||||
BuildableName = "LocksmithTests.xctest"
|
||||
BlueprintName = "LocksmithTests"
|
||||
ReferencedContainer = "container:Locksmith.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BFFB19DA1A4870A300CCFFC3"
|
||||
BuildableName = "LocksmithTests.xctest"
|
||||
BlueprintName = "LocksmithTests"
|
||||
ReferencedContainer = "container:Locksmith.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BFFB19CF1A4870A300CCFFC3"
|
||||
BuildableName = "Locksmith.framework"
|
||||
BlueprintName = "Locksmith"
|
||||
ReferencedContainer = "container:Locksmith.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BFFB19CF1A4870A300CCFFC3"
|
||||
BuildableName = "Locksmith.framework"
|
||||
BlueprintName = "Locksmith"
|
||||
ReferencedContainer = "container:Locksmith.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BFFB19CF1A4870A300CCFFC3"
|
||||
BuildableName = "Locksmith.framework"
|
||||
BlueprintName = "Locksmith"
|
||||
ReferencedContainer = "container:Locksmith.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -22,68 +22,69 @@ class LocksmithTests: XCTestCase {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
|
||||
// public class func saveData(data: Dictionary<String, String>, inService service: String, forUserAccount userAccount: String) -> NSError?
|
||||
func testSaveData_Once() {
|
||||
var error = Locksmith.saveData(["key": "value"], inService: "myService", forUserAccount: "myUserAccount")
|
||||
var error = Locksmith.saveData(["key": "value"], forUserAccount: "myUserAccount", inService: "myService")
|
||||
XCTAssert(error == nil, "❌: saving data")
|
||||
}
|
||||
|
||||
func testSaveData_Multiple() {
|
||||
var errors: [NSError?] = []
|
||||
for i in 0...10 {
|
||||
errors.append(Locksmith.saveData(["key": "value \(i)"], inService: "myService", forUserAccount: "myAccount\(i)"))
|
||||
errors.append(Locksmith.saveData(["key": "value \(i)"], forUserAccount: "myAccount\(i)", inService: "myService"))
|
||||
}
|
||||
XCTAssert(errors.filter({ $0 != nil }).isEmpty, "❌: saving multiple items")
|
||||
}
|
||||
|
||||
func testSaveData_Duplicate() {
|
||||
// Should be successful
|
||||
let error1 = Locksmith.saveData(["key": "value"], inService: "myService", forUserAccount: "user")
|
||||
let error1 = Locksmith.saveData(["key": "value"], forUserAccount: "user", inService: "myService")
|
||||
|
||||
// Should fail
|
||||
let error2 = Locksmith.saveData(["key": "value"], inService: "myService", forUserAccount: "user")
|
||||
let error2 = Locksmith.saveData(["key": "value"], forUserAccount: "user", inService: "myService")
|
||||
|
||||
XCTAssert(error1 == nil && error2 != nil, "❌: saving duplicate data")
|
||||
}
|
||||
|
||||
|
||||
// Setup the keychain for requests that use pre-existing values on the keychain (update, read, delete)
|
||||
func setupLoads() {
|
||||
Locksmith.saveData(["key": "value"], inService: "myService", forUserAccount: "user1")
|
||||
Locksmith.saveData(["anotherkey": "anothervalue"], inService: "myService", forUserAccount: "user2")
|
||||
Locksmith.saveData(["word": "definition"], inService: "myService", forUserAccount: "user3")
|
||||
Locksmith.saveData(["key": "value"], forUserAccount: "user1", inService: "myService")
|
||||
Locksmith.saveData(["anotherkey": "anothervalue"], forUserAccount: "user2", inService: "myService")
|
||||
Locksmith.saveData(["word": "definition"], forUserAccount: "user3", inService: "myService")
|
||||
}
|
||||
|
||||
// public class func loadDataInService(service: String, forUserAccount userAccount: String) -> (NSDictionary?, NSError?)
|
||||
func testLoadData_Once() {
|
||||
setupLoads()
|
||||
|
||||
let (dictionary, error) = Locksmith.loadDataInService("myService", forUserAccount: "user1")
|
||||
XCTAssert(dictionary!.valueForKey("key")! as NSString == "value" && error == nil, "❌: loading one item")
|
||||
let (dictionary, error) = Locksmith.loadDataForUserAccount("user1", inService: "myService")
|
||||
XCTAssert(dictionary!.valueForKey("key") as! NSString == "value" && error == nil, "❌: loading one item")
|
||||
}
|
||||
|
||||
func testLoadData_Multiple() {
|
||||
setupLoads()
|
||||
|
||||
let (dictionary, error) = Locksmith.loadDataInService("myService", forUserAccount: "user1")
|
||||
let (dictionary2, error2) = Locksmith.loadDataInService("myService", forUserAccount: "user2")
|
||||
let (dictionary3, error3) = Locksmith.loadDataInService("myService", forUserAccount: "user3")
|
||||
let (dictionary, error) = Locksmith.loadDataForUserAccount("user1", inService: "myService")
|
||||
let (dictionary2, error2) = Locksmith.loadDataForUserAccount("user2", inService: "myService")
|
||||
let (dictionary3, error3) = Locksmith.loadDataForUserAccount("user3", inService: "myService")
|
||||
|
||||
XCTAssert(dictionary!.valueForKey("key")! as NSString == "value" && error == nil, "❌: loading multiple items")
|
||||
XCTAssert(dictionary2!.valueForKey("anotherkey")! as NSString == "anothervalue" && error == nil, "❌: loading multiple items")
|
||||
XCTAssert(dictionary3!.valueForKey("word")! as NSString == "definition" && error == nil, "❌: loading multiple items")
|
||||
XCTAssert(dictionary!.valueForKey("key") as! NSString == "value" && error == nil, "❌: loading multiple items")
|
||||
XCTAssert(dictionary2!.valueForKey("anotherkey") as! NSString == "anothervalue" && error == nil, "❌: loading multiple items")
|
||||
XCTAssert(dictionary3!.valueForKey("word") as! NSString == "definition" && error == nil, "❌: loading multiple items")
|
||||
}
|
||||
|
||||
// public class func updateData(data: Dictionary<String, String>, inService service: String, forUserAccount userAccount: String) -> NSError?
|
||||
func testUpdateData() {
|
||||
setupLoads()
|
||||
|
||||
let error = Locksmith.updateData(["key": "newvalue"], inService: "myService", forUserAccount: "user1")
|
||||
let (dictionary, err) = Locksmith.loadDataInService("myService", forUserAccount: "user1")
|
||||
XCTAssert(dictionary!.valueForKey("key")! as NSString == "newvalue" && error == nil, "❌: updating item")
|
||||
let error = Locksmith.updateData(["key": "newvalue"], forUserAccount: "user1", inService: "myService")
|
||||
let (dictionary, err) = Locksmith.loadDataForUserAccount("user1", inService: "myService")
|
||||
|
||||
XCTAssert(dictionary!.valueForKey("key") as! NSString == "newvalue" && error == nil, "❌: updating item")
|
||||
|
||||
// Updating an item that doesn't exist should create that item (i.e. performs a regular create request)
|
||||
let error2 = Locksmith.updateData(["key": "anothervalue"], inService: "myService", forUserAccount: "user1")
|
||||
let error2 = Locksmith.updateData(["key": "anothervalue"], forUserAccount: "user1", inService: "myService")
|
||||
XCTAssert(error2 == nil, "❌: updating item that doesn't exist")
|
||||
}
|
||||
|
||||
@@ -91,10 +92,10 @@ class LocksmithTests: XCTestCase {
|
||||
func testDeleteData() {
|
||||
setupLoads()
|
||||
|
||||
let error = Locksmith.deleteDataInService("myService", forUserAccount: "user1")
|
||||
let error = Locksmith.deleteDataForUserAccount("user1", inService: "myService")
|
||||
XCTAssert(error == nil, "❌: deleting existing item")
|
||||
|
||||
let error2 = Locksmith.deleteDataInService("myService", forUserAccount: "user1")
|
||||
let error2 = Locksmith.deleteDataForUserAccount("user1", inService: "myService")
|
||||
XCTAssert(error2 != nil, "❌: deleting non existent item")
|
||||
}
|
||||
|
||||
@@ -105,4 +106,4 @@ class LocksmithTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import UIKit
|
||||
import Security
|
||||
|
||||
public let LocksmithErrorDomain = "com.locksmith.error"
|
||||
public let LocksmithDefaultService = NSBundle.mainBundle().infoDictionary![kCFBundleIdentifierKey] as! String
|
||||
public let LocksmithDefaultService = NSBundle.mainBundle().infoDictionary![kCFBundleIdentifierKey] as? String ?? "com.locksmith.defaultService"
|
||||
|
||||
|
||||
public class Locksmith: NSObject {
|
||||
|
||||
@@ -28,7 +28,7 @@ public enum Accessible: Int {
|
||||
public class LocksmithRequest: NSObject, DebugPrintable {
|
||||
// Keychain Options
|
||||
// Required
|
||||
public var service: String = NSBundle.mainBundle().infoDictionary![kCFBundleIdentifierKey] as! String // Default to Bundle Identifier
|
||||
public var service: String = LocksmithDefaultService
|
||||
public var userAccount: String
|
||||
public var type: RequestType = .Read // Default to non-destructive
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.matthewpalmer.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.1.2</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,12 +1,16 @@
|
||||
> This is Locksmith’s compatibility branch for Swift 1.2
|
||||
|
||||
# Locksmith
|
||||
|
||||
A sane way to work with the iOS Keychain in Swift.
|
||||
|
||||
<!--[](https://travis-ci.org/matthewpalmer/Locksmith)-->
|
||||
[](http://cocoadocs.org/docsets/Locksmith)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
[](http://cocoadocs.org/docsets/Locksmith)
|
||||
[](http://cocoadocs.org/docsets/Locksmith)
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
### CocoaPods
|
||||
@@ -14,8 +18,7 @@ A sane way to work with the iOS Keychain in Swift.
|
||||
Locksmith is available through [CocoaPods](http://cocoapods.org). To install
|
||||
it, simply add the following line to your Podfile:
|
||||
|
||||
pod "Locksmith"
|
||||
|
||||
pod "Locksmith", :git => 'https://github.com/matthewpalmer/Locksmith.git', :branch => '1.2.2'
|
||||
|
||||
### Manual
|
||||
|
||||
@@ -27,6 +30,8 @@ In the following examples, you can choose not to provide a value for the `inServ
|
||||
|
||||
**Save data**
|
||||
|
||||
- writes the data to the keychain if it does not exist already
|
||||
|
||||
```swift
|
||||
let error = Locksmith.saveData(["some key": "some value"], forUserAccount: "myUserAccount")
|
||||
```
|
||||
@@ -51,6 +56,8 @@ let (dictionary, error) = Locksmith.loadDataForUserAccount("myUserAccount", inSe
|
||||
|
||||
**Update data**
|
||||
|
||||
- overwrites whatever is stored on the keychain under this user account (if nothing is stored, we save as normal)
|
||||
|
||||
```swift
|
||||
let error = Locksmith.updateData(["some key": "another value"], forUserAccount: "myUserAccount")
|
||||
```
|
||||
@@ -117,6 +124,9 @@ var securityClass: SecurityClass // Defaults to .GenericPassword
|
||||
var synchronizable: Bool // Defaults to false
|
||||
```
|
||||
|
||||
## Testing
|
||||
I can't work out why, but opening `Example/Locksmith.xcworkspace` and trying to run the tests from there won't work. (Pull requests greatly appreciated on this!) Instead, you can run the tests by opening `Locksmith.xcodeproj` in the root directory, and doing Product -> Test.
|
||||
|
||||
## Author
|
||||
|
||||
[Matthew Palmer](http://matthewpalmer.net), matt@matthewpalmer.net
|
||||
|
||||
Reference in New Issue
Block a user