diff --git a/HNHUi b/HNHUi index f274bfbe..7bf39a4b 160000 --- a/HNHUi +++ b/HNHUi @@ -1 +1 @@ -Subproject commit f274bfbec9d964affe2f11f42c72f429cc990b69 +Subproject commit 7bf39a4be92cef2a9d4076ccd1612c92a8a0c01b diff --git a/KeePassKit b/KeePassKit index e1edcc11..105bd0ad 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit e1edcc115b261eb0b157675e748b00182b468aad +Subproject commit 105bd0adbd9aafa4dcc1c8048775be44a10f0f12 diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index f4b3eac0..38560c33 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -187,6 +187,9 @@ 4C77E37A15B84A240093A587 /* MPAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C77E37915B84A240093A587 /* MPAppDelegate.m */; }; 4C77E37D15B84A240093A587 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C77E37B15B84A240093A587 /* MainMenu.xib */; }; 4C79DF2A176685870083708F /* HNHRoundedTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C79DF29176685870083708F /* HNHRoundedTextField.m */; }; + 4C79E80317A9187400AC6CD2 /* KPKXmlHeaderWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C79E80217A9187400AC6CD2 /* KPKXmlHeaderWriter.m */; }; + 4C79E80617A9400500AC6CD2 /* KPKTestNSCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C79E80517A9400500AC6CD2 /* KPKTestNSCoding.m */; }; + 4C79E80917A9485600AC6CD2 /* KPKTestNSCopying.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C79E80817A9485600AC6CD2 /* KPKTestNSCopying.m */; }; 4C7F35681779DFFB00C57890 /* Errors.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4C7F356A1779DFFB00C57890 /* Errors.strings */; }; 4C801AFC179310E2002821E3 /* NSString+Hexdata.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C801AFB179310E2002821E3 /* NSString+Hexdata.m */; }; 4C80BB6F176DE06F00E5E248 /* HNHScrollDocumentViewAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C80BB6E176DE06F00E5E248 /* HNHScrollDocumentViewAdapter.m */; }; @@ -199,7 +202,6 @@ 4C888C9716EB754B003D34A1 /* MPActionHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C888C9616EB754B003D34A1 /* MPActionHelper.m */; }; 4C8A173D1790AA41008B5C17 /* NSData+Keyfile.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8A173C1790AA41008B5C17 /* NSData+Keyfile.m */; }; 4C8B36AB17A6ED4B005E1FF1 /* MPOutlineContextMenuDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8B36AA17A6ED4B005E1FF1 /* MPOutlineContextMenuDelegate.m */; }; - 4C8B36AE17A734A1005E1FF1 /* HNHContextButtonSegmentedCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8B36AD17A734A1005E1FF1 /* HNHContextButtonSegmentedCell.m */; }; 4C8FECC816D57E3200BF26CF /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C8FECC716D57E3200BF26CF /* QuartzCore.framework */; }; 4C96D15417A12E4F00D931FA /* 99_CreatedTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C96D15317A12E4F00D931FA /* 99_CreatedTemplate.pdf */; }; 4C9D6AA917615199001C660C /* HNHRoundedSecureTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C9D6AA817615199001C660C /* HNHRoundedSecureTextFieldCell.m */; }; @@ -614,6 +616,12 @@ 4C77E37915B84A240093A587 /* MPAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPAppDelegate.m; sourceTree = ""; }; 4C79DF28176685870083708F /* HNHRoundedTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHRoundedTextField.h; sourceTree = ""; }; 4C79DF29176685870083708F /* HNHRoundedTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHRoundedTextField.m; sourceTree = ""; }; + 4C79E80117A9187400AC6CD2 /* KPKXmlHeaderWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKXmlHeaderWriter.h; sourceTree = ""; }; + 4C79E80217A9187400AC6CD2 /* KPKXmlHeaderWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKXmlHeaderWriter.m; sourceTree = ""; }; + 4C79E80417A9400500AC6CD2 /* KPKTestNSCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKTestNSCoding.h; sourceTree = ""; }; + 4C79E80517A9400500AC6CD2 /* KPKTestNSCoding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKTestNSCoding.m; sourceTree = ""; }; + 4C79E80717A9485600AC6CD2 /* KPKTestNSCopying.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKTestNSCopying.h; sourceTree = ""; }; + 4C79E80817A9485600AC6CD2 /* KPKTestNSCopying.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKTestNSCopying.m; sourceTree = ""; }; 4C7F35691779DFFB00C57890 /* en */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Errors.strings; sourceTree = ""; }; 4C7F356B1779DFFF00C57890 /* de */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Errors.strings; sourceTree = ""; }; 4C801AFA179310E2002821E3 /* NSString+Hexdata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Hexdata.h"; sourceTree = ""; }; @@ -637,8 +645,6 @@ 4C8A173C1790AA41008B5C17 /* NSData+Keyfile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Keyfile.m"; sourceTree = ""; }; 4C8B36A917A6ED4B005E1FF1 /* MPOutlineContextMenuDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineContextMenuDelegate.h; sourceTree = ""; }; 4C8B36AA17A6ED4B005E1FF1 /* MPOutlineContextMenuDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOutlineContextMenuDelegate.m; sourceTree = ""; }; - 4C8B36AC17A734A1005E1FF1 /* HNHContextButtonSegmentedCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHContextButtonSegmentedCell.h; sourceTree = ""; }; - 4C8B36AD17A734A1005E1FF1 /* HNHContextButtonSegmentedCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHContextButtonSegmentedCell.m; sourceTree = ""; }; 4C8FECC716D57E3200BF26CF /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 4C96D15317A12E4F00D931FA /* 99_CreatedTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 99_CreatedTemplate.pdf; sourceTree = ""; }; 4C9D6AA717615199001C660C /* HNHRoundedSecureTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHRoundedSecureTextFieldCell.h; sourceTree = ""; }; @@ -1173,6 +1179,10 @@ 4C1842B7179B348600E2F5BC /* KPKLegacyLoadingTest.m */, 4CFC8741179DFD3E000DFC03 /* KPKXmlLoadingTest.h */, 4CFC8742179DFD3E000DFC03 /* KPKXmlLoadingTest.m */, + 4C79E80417A9400500AC6CD2 /* KPKTestNSCoding.h */, + 4C79E80517A9400500AC6CD2 /* KPKTestNSCoding.m */, + 4C79E80717A9485600AC6CD2 /* KPKTestNSCopying.h */, + 4C79E80817A9485600AC6CD2 /* KPKTestNSCopying.m */, ); path = MacPassTests; sourceTree = ""; @@ -1525,8 +1535,6 @@ 4CF78059176E6D5F0032EE71 /* HNHTableRowView.m */, 4C52A242177D7B9F0000D88F /* HNHScrollView.h */, 4C52A243177D7B9F0000D88F /* HNHScrollView.m */, - 4C8B36AC17A734A1005E1FF1 /* HNHContextButtonSegmentedCell.h */, - 4C8B36AD17A734A1005E1FF1 /* HNHContextButtonSegmentedCell.m */, 4C2671AB17A7D8FC00F3A645 /* HNHColorWell.h */, 4C2671AC17A7D8FC00F3A645 /* HNHColorWell.m */, ); @@ -1603,6 +1611,8 @@ 4C1842C9179C616700E2F5BC /* KPKTreeCryptor.m */, 4C1842BA179B434C00E2F5BC /* KPKXmlHeaderReader.h */, 4C1842BB179B434C00E2F5BC /* KPKXmlHeaderReader.m */, + 4C79E80117A9187400AC6CD2 /* KPKXmlHeaderWriter.h */, + 4C79E80217A9187400AC6CD2 /* KPKXmlHeaderWriter.m */, 4C1842D1179C64EF00E2F5BC /* KPKXmlTreeCryptor.h */, 4C1842D2179C64EF00E2F5BC /* KPKXmlTreeCryptor.m */, 4C5AA58F179549A1008ECAD7 /* KPKXmlTreeWriter.h */, @@ -1862,6 +1872,8 @@ 4C305F3C179A19F90082334F /* KPKIconLoading.m in Sources */, 4C1842B8179B348600E2F5BC /* KPKLegacyLoadingTest.m in Sources */, 4CFC8743179DFD3E000DFC03 /* KPKXmlLoadingTest.m in Sources */, + 4C79E80617A9400500AC6CD2 /* KPKTestNSCoding.m in Sources */, + 4C79E80917A9485600AC6CD2 /* KPKTestNSCopying.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2061,11 +2073,11 @@ 4C4B7EF817A4B335000234C7 /* MPUniqueCharactersFormatter.m in Sources */, 4C5FA86D17A5F26800C781C9 /* KPKDataStreamWriter.m in Sources */, 4C8B36AB17A6ED4B005E1FF1 /* MPOutlineContextMenuDelegate.m in Sources */, - 4C8B36AE17A734A1005E1FF1 /* HNHContextButtonSegmentedCell.m in Sources */, 4CD7223B17A7CB0700F5A1E1 /* MPWorkflowSettingsController.m in Sources */, 4C2671AD17A7D8FC00F3A645 /* HNHColorWell.m in Sources */, 4CA08DA017A831B200A6544B /* MPAddEntryContextMenuDelegate.m in Sources */, 4C6BEA3117A88E6C00CF69A8 /* MPStripLineBreaksTransformer.m in Sources */, + 4C79E80317A9187400AC6CD2 /* KPKXmlHeaderWriter.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/Base.lproj/InspectorView.xib b/MacPass/Base.lproj/InspectorView.xib index a924845d..f47764af 100644 --- a/MacPass/Base.lproj/InspectorView.xib +++ b/MacPass/Base.lproj/InspectorView.xib @@ -12,6 +12,8 @@ IBNSLayoutConstraint + NSButton + NSButtonCell NSCustomObject NSCustomView NSImageCell @@ -121,11 +123,41 @@ 268 - + + + + -2147483380 + {{20, 2}, {59, 25}} + + + + _NS:22 + YES + + -2080374784 + 134217728 + Edit + + _NS:22 + + 918306816 + 163 + + NSImage + 07_NotepadTemplate + + + + 400 + 75 + + NO + + {278, 30} - + _NS:9 HNHGradientView @@ -135,15 +167,17 @@ {{0, 30}, {278, 369}} - + _NS:9 2 - + 256 {278, 369} + + _NS:28 @@ -158,7 +192,6 @@ 256 {278, 369} - _NS:11 Group @@ -167,7 +200,7 @@ - + 256 @@ -175,8 +208,7 @@ 268 {{77, 173}, {125, 24}} - - + _NS:1535 YES @@ -205,8 +237,6 @@ {278, 369} - - NoSelection @@ -214,13 +244,13 @@ - + 6 YES YES - + @@ -571,6 +601,38 @@ 2930 + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 5 + 22 + 2 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + 8 @@ -587,6 +649,7 @@ 40 1 + @@ -784,6 +847,29 @@ + + 3109 + + + + + + + + 3110 + + + + + 3111 + + + + + 3112 + + + @@ -821,8 +907,10 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - + + + com.apple.InterfaceBuilder.CocoaPlugin @@ -861,12 +949,17 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - 3095 + 3114 @@ -966,10 +1059,10 @@ IBCocoaFramework YES 3 - - NSActionTemplate - {15, 15} - + + {128, 128} + {15, 15} + YES diff --git a/MacPass/EntryInspectorView.xib b/MacPass/EntryInspectorView.xib index 9b720d43..33f60a7d 100644 --- a/MacPass/EntryInspectorView.xib +++ b/MacPass/EntryInspectorView.xib @@ -4989,6 +4989,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + HNHRoundedTextField com.apple.InterfaceBuilder.CocoaPlugin @@ -4996,6 +4997,7 @@ HNHRoundedTextField com.apple.InterfaceBuilder.CocoaPlugin + HNHRoundedTextField com.apple.InterfaceBuilder.CocoaPlugin @@ -5016,14 +5018,11 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - HNHRoundedTextFieldCell com.apple.InterfaceBuilder.CocoaPlugin - HNHRoundedTextFieldCell com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - HNHRoundedTextFieldCell com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin diff --git a/MacPass/EntryView.xib b/MacPass/EntryView.xib index 165c0c8f..e8763ff9 100644 --- a/MacPass/EntryView.xib +++ b/MacPass/EntryView.xib @@ -59,6 +59,7 @@ {{7, 5}, {32, 19}} + _NS:9 YES @@ -108,7 +109,7 @@ {694, 548} - + _NS:13 YES NO @@ -380,7 +381,7 @@ {{0, 30}, {694, 565}} - + _NS:9 133680 @@ -1572,7 +1573,7 @@ - 843 + 878 @@ -1732,13 +1733,13 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - 867 + 878 diff --git a/MacPass/GroupInspectorView.xib b/MacPass/GroupInspectorView.xib index ae313834..a6573f45 100644 --- a/MacPass/GroupInspectorView.xib +++ b/MacPass/GroupInspectorView.xib @@ -54,7 +54,6 @@ {{18, 99}, {222, 26}} - _NS:9 {249, 750} YES @@ -336,7 +335,7 @@ {215, 257} - + _NS:13 @@ -462,7 +461,7 @@ {{20, 190}, {217, 259}} - + _NS:9 {750, 750} 133138 @@ -549,7 +548,7 @@ {255, 421} - + _NS:13 @@ -593,7 +592,7 @@ {255, 421} - + _NS:9 133152 @@ -1361,6 +1360,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + HNHRoundedTextField com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1383,7 +1383,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - HNHRoundedTextFieldCell com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1449,11 +1448,11 @@ - HNHRoundedTextFieldCell - NSTextFieldCell + HNHRoundedTextField + NSTextField IBProjectSource - ./Classes/HNHRoundedTextFieldCell.h + ./Classes/HNHRoundedTextField.h @@ -1478,7 +1477,7 @@ NSView NSTextView - NSTextField + HNHRoundedTextField @@ -1491,7 +1490,7 @@ titleTextField - NSTextField + HNHRoundedTextField diff --git a/MacPass/MPContextToolbarButton.m b/MacPass/MPContextToolbarButton.m index 840cfd2d..b2bf828a 100644 --- a/MacPass/MPContextToolbarButton.m +++ b/MacPass/MPContextToolbarButton.m @@ -8,8 +8,6 @@ #import "MPContextToolbarButton.h" -#import "HNHContextButtonSegmentedCell.h" - @implementation MPContextToolbarButton - (id)initWithFrame:(NSRect)frame { diff --git a/MacPass/MPGroupInspectorViewController.h b/MacPass/MPGroupInspectorViewController.h index 91cf2293..c6bb356d 100644 --- a/MacPass/MPGroupInspectorViewController.h +++ b/MacPass/MPGroupInspectorViewController.h @@ -8,11 +8,12 @@ #import "MPViewController.h" @class MPDocument; +@class HNHRoundedTextField; @interface MPGroupInspectorViewController : MPViewController @property (strong) IBOutlet NSView *contentView; -@property (weak) IBOutlet NSTextField *titleTextField; +@property (weak) IBOutlet HNHRoundedTextField *titleTextField; @property (unsafe_unretained) IBOutlet NSTextView *notesTextView; - (void)setupBindings:(MPDocument *)document; diff --git a/MacPass/MPGroupInspectorViewController.m b/MacPass/MPGroupInspectorViewController.m index ceb71053..309e5a88 100644 --- a/MacPass/MPGroupInspectorViewController.m +++ b/MacPass/MPGroupInspectorViewController.m @@ -8,11 +8,13 @@ #import "MPGroupInspectorViewController.h" #import "MPDocument.h" +#import "MPPasteBoardController.h" #import "Kdb.h" #import "Kdb4Node.h" #import "HNHScrollView.h" +#import "HNHRoundedTextField.h" @interface MPGroupInspectorViewController () @@ -51,6 +53,12 @@ metrics:nil views:views]]; [[self view] layoutSubtreeIfNeeded]; + + copyAction copyBlock = ^void(NSTextField *textField) { + [[MPPasteBoardController defaultController] copyObjects:@[ textField.stringValue ]]; + }; + + self.titleTextField.copyActionBlock = copyBlock; } - (void)setupBindings:(MPDocument *)document { diff --git a/MacPassTests/KPKTestNSCoding.h b/MacPassTests/KPKTestNSCoding.h new file mode 100644 index 00000000..037e550d --- /dev/null +++ b/MacPassTests/KPKTestNSCoding.h @@ -0,0 +1,13 @@ +// +// KPKTestNSCopying.h +// MacPass +// +// Created by Michael Starke on 31.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +@interface KPKTestNSCoding : SenTestCase + +@end diff --git a/MacPassTests/KPKTestNSCoding.m b/MacPassTests/KPKTestNSCoding.m new file mode 100644 index 00000000..c3c25757 --- /dev/null +++ b/MacPassTests/KPKTestNSCoding.m @@ -0,0 +1,86 @@ +// +// KPKTestNSCopying.m +// MacPass +// +// Created by Michael Starke on 31.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "KPKTestNSCoding.h" +#import "KPKEntry.h" +#import "KPKBinary.h" +#import "KPKAttribute.h" + +@implementation KPKTestNSCoding + +- (void)testAttributeCoding { + KPKAttribute *attribute = [[KPKAttribute alloc] initWithKey:@"Key" value:@"Value" isProtected:YES]; + NSData *data = [self encode:attribute]; + KPKAttribute *copy = [self decode:data ofClass:[KPKAttribute class]]; + + STAssertTrue([copy.value isEqualToString:attribute.value], @"Values should be preseved"); + STAssertTrue([copy.key isEqualToString:attribute.key], @"Keys should be preserved"); + STAssertTrue(copy.isProtected == attribute.isProtected, @"Protected status should be the same"); +} + +- (void)testBinaryCoding { + +} + +- (void)testEntryCoding { + /* + 1. Deep Copy + 2. Copy without History + */ + KPKEntry *entry = [[KPKEntry alloc] init]; + + entry.title = @"Title"; + entry.url = @"URL"; + entry.username = @"Username"; + entry.password = @"Password"; + + uint8 bytes[] = { 0xFF, 0x00, 0xFF, 0x00, 0xFF }; + NSData *data = [[NSData alloc] initWithBytes:bytes length:5]; + + KPKBinary *binary = [[KPKBinary alloc] init]; + binary.data = data; + binary.name = @"Binary"; + + [entry addBinary:binary]; + [entry addCustomAttribute:[[KPKAttribute alloc] initWithKey:@"Custom" value:@"Value" isProtected:NO]]; + + NSData *encodedData = [self encode:entry]; + KPKEntry *copyEntry = [self decode:encodedData ofClass:[KPKEntry class]]; + + STAssertNotNil(copyEntry, @"Copied Entry cannot be nil"); + STAssertTrue([copyEntry.title isEqualToString:entry.title], @"Titles should match"); + STAssertTrue([copyEntry.url isEqualToString:entry.url], @"URLS should match"); + STAssertTrue([copyEntry.binaries count] == 1, @"Binareis should be copied"); + + KPKBinary *copiedBinary = [copyEntry.binaries lastObject]; + STAssertTrue([copiedBinary.data isEqualToData:binary.data], @"Binary data should match"); + STAssertTrue([copiedBinary.name isEqualToString:binary.name], @"Binary names should macht"); +} + + +- (void)testGroupCoding { + +} + + +- (NSData *)encode:(id)object { + NSMutableData *data = [[NSMutableData alloc] initWithCapacity:500]; + NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; + [object encodeWithCoder:archiver]; + [archiver finishEncoding]; + return data; +} + +- (id)decode:(NSData *)data ofClass:(Class)class { + NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; + id object = [[class alloc] initWithCoder:unarchiver]; + [unarchiver finishDecoding]; + return object; +} + +@end diff --git a/MacPassTests/KPKTestNSCopying.h b/MacPassTests/KPKTestNSCopying.h new file mode 100644 index 00000000..0bf80199 --- /dev/null +++ b/MacPassTests/KPKTestNSCopying.h @@ -0,0 +1,13 @@ +// +// KPKTestNSCopying.h +// MacPass +// +// Created by Michael Starke on 31.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +@interface KPKTestNSCopying : SenTestCase + +@end diff --git a/MacPassTests/KPKTestNSCopying.m b/MacPassTests/KPKTestNSCopying.m new file mode 100644 index 00000000..b589f62c --- /dev/null +++ b/MacPassTests/KPKTestNSCopying.m @@ -0,0 +1,13 @@ +// +// KPKTestNSCopying.m +// MacPass +// +// Created by Michael Starke on 31.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "KPKTestNSCopying.h" + +@implementation KPKTestNSCopying + +@end