mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 17:32:17 +00:00
Fixed #71 Added A simple entropy calculation for purely random generated passwords Added separate Views for Group and Entry Inspector Added "no Selection" view for Inpsector
53 lines
1.6 KiB
Objective-C
53 lines
1.6 KiB
Objective-C
//
|
|
// KPKXmlLoadingTest.m
|
|
// MacPass
|
|
//
|
|
// Created by Michael Starke on 23.07.13.
|
|
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
|
//
|
|
|
|
#import "KPKXmlLoadingTest.h"
|
|
#import "KPKTreeCryptor.h"
|
|
#import "KPKPassword.h"
|
|
|
|
#import "KPKTree.h"
|
|
#import "KPKEntry.h"
|
|
#import "KPKGroup.h"
|
|
|
|
@implementation KPKXmlLoadingTest
|
|
|
|
- (void)setUp {
|
|
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
|
|
NSURL *url = [myBundle URLForResource:@"Test_Password_1234" withExtension:@"kdbx"];
|
|
_data = [NSData dataWithContentsOfURL:url];
|
|
_password = [[KPKPassword alloc] initWithPassword:@"1234" key:nil];
|
|
}
|
|
|
|
- (void)tearDown {
|
|
_data = nil;
|
|
_password = nil;
|
|
}
|
|
|
|
- (void)testLoading {
|
|
KPKTreeCryptor *cryptor = [KPKTreeCryptor treeCryptorWithData:_data password:_password];
|
|
KPKTree *tree = [cryptor decryptTree:NULL];
|
|
//STAssertNotNil(tree, @"Loading should result in a tree object");
|
|
|
|
//STAssertTrue([tree.root.groups count] == 0, @"Tree contains just root group");
|
|
//STAssertTrue([tree.root.entries count] == 1, @"Tree has only one entry");
|
|
|
|
KPKEntry *entry = [tree.root.entries lastObject];
|
|
NSMutableData *data = [[NSMutableData alloc] init];
|
|
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
|
|
[entry encodeWithCoder:archiver];
|
|
[archiver finishEncoding];
|
|
|
|
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
|
|
KPKEntry *newEntry = [[KPKEntry alloc] initWithCoder:unarchiver];
|
|
[unarchiver finishDecoding];
|
|
|
|
STAssertTrue([entry.title isEqualToString:newEntry.title], @"Entries must have same attributes");
|
|
}
|
|
|
|
@end
|