mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 03:32:40 +00:00
Extended NSUUID extension
Reference Retrieval now can be used with "undashed" ID strings Added NSUUID+KeePassKit Test
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "KPKTree.h"
|
||||
#import "KPKGroup.h"
|
||||
#import "KPKEntry.h"
|
||||
#import "NSString+Commands.h"
|
||||
|
||||
@interface KPKTestReference : XCTestCase
|
||||
@@ -16,8 +20,40 @@
|
||||
@implementation KPKTestReference
|
||||
|
||||
- (void)testCorrectReference {
|
||||
NSString *reference = @"This is some nice stuff {REF:T@U:blubber} and another Reference {REF:U@I:2687345AASTA}";
|
||||
[reference resolveReferencesWithTree:nil];
|
||||
KPKTree *tree = [[KPKTree alloc] init];
|
||||
KPKGroup *group = [[KPKGroup alloc] init];
|
||||
KPKEntry *entry1 = [[KPKEntry alloc] init];
|
||||
KPKEntry *entry2 = [[KPKEntry alloc] init];
|
||||
entry1.title = @"-Entry1Title-";
|
||||
NSString *title2 = [[NSString alloc] initWithFormat:@"Nothing{REF:T@I:%@}Changed", entry1.uuid.UUIDString];
|
||||
entry2.title = title2;
|
||||
entry2.url = @"-Entry2URL-";
|
||||
|
||||
[group addEntry:entry1];
|
||||
[group addEntry:entry2];
|
||||
tree.root = group;
|
||||
|
||||
NSString *result = [entry2.title resolveReferencesWithTree:tree];
|
||||
XCTAssertTrue([result isEqualToString:@"Nothing-Entry1Title-Changed"], @"Replaced Strings should match");
|
||||
}
|
||||
|
||||
- (void)testRecursiveReference{
|
||||
KPKTree *tree = [[KPKTree alloc] init];
|
||||
KPKGroup *group = [[KPKGroup alloc] init];
|
||||
KPKEntry *entry1 = [[KPKEntry alloc] init];
|
||||
KPKEntry *entry2 = [[KPKEntry alloc] init];
|
||||
NSString *title1 = [[NSString alloc] initWithFormat:@"Title1{REF:A@I:%@}", entry2.uuid.UUIDString];
|
||||
entry1.title = title1; // References URL of entry 2
|
||||
NSString *title2 = [[NSString alloc] initWithFormat:@"Nothing{REF:T@I:%@}Changed", entry1.uuid.UUIDString];
|
||||
entry2.title = title2; // Refernces Title of entry 1
|
||||
entry2.url = @"-Entry2URL-";
|
||||
|
||||
[group addEntry:entry1];
|
||||
[group addEntry:entry2];
|
||||
tree.root = group;
|
||||
|
||||
NSString *result = [entry2.title resolveReferencesWithTree:tree];
|
||||
XCTAssertTrue([result isEqualToString:@"NothingTitle1-Entry2URL-Changed"], @"Replaced Strings should match");
|
||||
}
|
||||
|
||||
- (void)testWrongRefernceFormat {
|
||||
|
||||
23
MacPassTests/KPKTestUUIDAdditions.m
Normal file
23
MacPassTests/KPKTestUUIDAdditions.m
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// KPKTestUUIDAdditions.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 16.02.14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import "NSUUID+KeePassKit.h"
|
||||
@interface KPKTestUUIDAdditions : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation KPKTestUUIDAdditions
|
||||
|
||||
- (void)testUndelemitedUUID {
|
||||
NSUUID *uuid1 = [[NSUUID alloc] initWithUUIDString:@"31C1F2E6-BF71-4350-BE58-05216AFC5AFF"];
|
||||
NSUUID *uuid2 = [[NSUUID alloc] initWithUndelemittedUUIDString:@"31C1F2E6BF714350BE5805216AFC5AFF"];
|
||||
XCTAssertTrue([uuid1 isEqual:uuid2], @"UUIDs shoudl match");
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user