Updated submodule

Added Test for Hashed data
This commit is contained in:
michael starke
2013-08-09 01:58:43 +02:00
parent bc0af02be4
commit 4b42493376
8 changed files with 58 additions and 26 deletions

View File

@@ -0,0 +1,14 @@
//
// KPKHashedDataTest.h
// MacPass
//
// Created by Michael Starke on 08.08.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
@interface KPKHashedDataTest : SenTestCase
@end

View File

@@ -0,0 +1,23 @@
//
// KPKHashedDataTest.m
// MacPass
//
// Created by Michael Starke on 08.08.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "KPKHashedDataTest.h"
#import "NSData+HashedData.h"
#import "NSData+Random.h"
@implementation KPKHashedDataTest
- (void)testHashedData {
NSData *data = [NSData dataWithRandomBytes:10000];
NSData *hashedData = [data hashedDataWithBlockSize:512];
NSData *unhashedData = [hashedData unhashedData];
STAssertTrue([unhashedData isEqualToData:data], @"Data needs to be the same after hashing and unhashing");
}
@end

View File

@@ -29,7 +29,7 @@
- (void)testWriting {
NSError *error = nil;
KPKTree *tree = [[KPKTree alloc] initWithData:_data password:_password error:&error];
NSData *data = [tree encryptWithPassword:_password forVersion:KPKVersion1 error:&error];
NSData *data = [tree encryptWithPassword:_password forVersion:KPKLegacyVersion error:&error];
}

View File

@@ -35,13 +35,14 @@
}
- (void)testColorRefReading {
uint32_t colorBytes = 0x000000ff;
uint32_t swappedData = colorBytes;//CFSwapInt32(colorBytes);
uint32_t colorBytes = 0x000000FF;
uint32_t swappedData = colorBytes;
NSData *colorData = [NSData dataWithBytesNoCopy:&swappedData length:sizeof(uint32_t) freeWhenDone:NO];
NSColor *color = [NSColor colorWithData:colorData];
STAssertEquals([color redComponent], 1.0, @"Red 100%");
STAssertEquals([color blueComponent], 0.0, @"Blue 0%");
STAssertEquals([color redComponent], 0.0, @"Red 100%");
STAssertEquals([color greenComponent], 0.0, @"Green 0%");
STAssertEquals([color blueComponent], 1.0, @"Blue 100%");
}
@end

View File

@@ -41,7 +41,7 @@
KPKTree *tree = [reader tree:&error];
STAssertNil(tree, @"No Tree form emptry data");
STAssertNotNil(error, @"Error Object should be provided");
STAssertTrue([error code] == KPKErrorXMLRootElementMissing, @"Error Code should be KeePassFile root missing");
STAssertTrue([error code] == KPKErrorXMLMetaElementMissing, @"Error Code should be KeePassFile root missing");
}
@end

View File

@@ -34,18 +34,6 @@
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