Fixed Tests

Fixed error that lead to trying to create and array with nil object
This commit is contained in:
michael starke
2013-07-13 00:00:51 +02:00
parent 860d6bb21c
commit a31e287ec8
12 changed files with 182 additions and 39 deletions

View File

@@ -17,8 +17,8 @@
STAssertTrue(document.version == MPDatabaseVersion3, @"Database should be Version1");
STAssertNotNil(document.treeV3, @"Database Tree needs to be Kdb3Tree");
STAssertNil(document.treeV4, @"Database Tree cannot be Kdb4Tree");
STAssertTrue(document.isDecrypted, @"Document has to be decrypted new database is created");
STAssertFalse(document.isSecured, @"Document has no Password/Keyfile and thus is not secured");
STAssertTrue(document.decrypted, @"Document has to be decrypted new database is created");
STAssertFalse(document.hasPasswordOrKey, @"Document has no Password/Keyfile and thus is not secured");
}
- (void)testCreateDatabaseVersion2 {
@@ -27,8 +27,8 @@
STAssertTrue(document.version == MPDatabaseVersion4, @"Database should be Version2");
STAssertNotNil(document.treeV4, @"Database Tree needs to be Kdb4Tree");
STAssertNil(document.treeV3, @"Database Tree cannot be Kdb3Tree");
STAssertTrue(document.isDecrypted, @"Document has to be decrypted new database is created");
STAssertFalse(document.isSecured, @"Document has no Password/Keyfile and thus is not secured");
STAssertTrue(document.decrypted, @"Document has to be decrypted new database is created");
STAssertFalse(document.hasPasswordOrKey, @"Document has no Password/Keyfile and thus is not secured");
}
@end

View File

@@ -20,9 +20,9 @@
MPDocument *document = [[MPDocument alloc] initWithContentsOfURL:url ofType:@"kdb" error:&error];
STAssertNil(error, @"No Error should occur on loading");
STAssertNotNil(document, @"Document cannot be nil");
STAssertFalse(document.isDecrypted, @"Document is not decrypted after inital load");
STAssertTrue([document decryptWithPassword:@"1234" keyFileURL:nil], @"Should decrypt with password");
STAssertTrue(document.isDecrypted, @"Document is decrypted if decryptiong succeeds");
STAssertFalse(document.decrypted, @"Document is not decrypted after inital load");
STAssertTrue([document unlockWithPassword:@"1234" keyFileURL:nil], @"Should decrypt with password");
STAssertTrue(document.decrypted, @"Document is decrypted if decryptiong succeeds");
STAssertNotNil(document.treeV3, @"Tree shoudl be version1");
STAssertNil(document.treeV4, @"Tree should not be version2");
STAssertTrue(document.version == MPDatabaseVersion3, @"Internal databse version should be correct");
@@ -35,9 +35,9 @@
MPDocument *document = [[MPDocument alloc] initWithContentsOfURL:url ofType:@"kdb" error:&error];
STAssertNil(error, @"No Error should occur on loading");
STAssertNotNil(document, @"Document should not be nil");
STAssertFalse(document.isDecrypted, @"Document is not decrypted after inital load");
STAssertFalse([document decryptWithPassword:@"123" keyFileURL:nil], @"Decryption should fail");
STAssertFalse(document.isDecrypted, @"Document is not decrypted with wrong password supplied");
STAssertFalse(document.decrypted, @"Document is not decrypted after inital load");
STAssertFalse([document unlockWithPassword:@"123" keyFileURL:nil], @"Decryption should fail");
STAssertFalse(document.decrypted, @"Document is not decrypted with wrong password supplied");
}
- (void)testLoadDatabaseVerions2 {
@@ -47,9 +47,9 @@
MPDocument *document = [[MPDocument alloc] initWithContentsOfURL:url ofType:@"kdbx" error:&error];
STAssertNil(error, @"No Error should occur on loading");
STAssertNotNil(document, @"Document cannot be nil");
STAssertFalse(document.isDecrypted, @"Document is not decrypted after inital load");
STAssertTrue([document decryptWithPassword:@"1234" keyFileURL:nil], @"Should decrypt with password");
STAssertTrue(document.isDecrypted, @"Document is decrypted if decryptiong succeeds");
STAssertFalse(document.decrypted, @"Document is not decrypted after inital load");
STAssertTrue([document unlockWithPassword:@"1234" keyFileURL:nil], @"Should decrypt with password");
STAssertTrue(document.decrypted, @"Document is decrypted if decryptiong succeeds");
STAssertNil(document.treeV3, @"Tree should not be version1");
STAssertNotNil(document.treeV4, @"Tree shoud be version2");
STAssertTrue(document.version == MPDatabaseVersion4, @"Internal database version should be correct");

View File

@@ -25,22 +25,22 @@
- (void)testSetPassword {
STAssertTrue([_databaseV3.password length] == 0, @"Password should not be set");
STAssertNil(_databaseV3.key, @"Keyfile should not be set");
STAssertFalse(_databaseV3.isSecured, @"Database without password is not secure");
STAssertFalse(_databaseV3.hasPasswordOrKey, @"Database without password is not secure");
_databaseV3.password = @"test";
STAssertTrue([_databaseV3.password isEqualToString:@"test"], @"Password should be set");
STAssertTrue(_databaseV3.isSecured, @"Database with password is secured");
STAssertTrue(_databaseV3.hasPasswordOrKey, @"Database with password is secured");
_databaseV3.password = nil;
STAssertFalse(_databaseV3.isSecured, @"Database with removed password is not secure anymore");
STAssertFalse(_databaseV3.hasPasswordOrKey, @"Database with removed password is not secure anymore");
}
- (void)testSetKeyfile {
STAssertTrue([_databaseV3.password length] == 0, @"Password should not be set");
STAssertNil(_databaseV3.key, @"Keyfile should not be set");
STAssertFalse(_databaseV3.isSecured, @"Database without keyfile is not secure");
STAssertFalse(_databaseV3.hasPasswordOrKey, @"Database without keyfile is not secure");
_databaseV3.key = [NSURL URLWithString:@"noKeyFile"];
STAssertTrue(_databaseV3.isSecured, @"Database with keyfile is secured");
STAssertTrue(_databaseV3.hasPasswordOrKey, @"Database with keyfile is secured");
_databaseV3.key = nil;
STAssertFalse(_databaseV3.isSecured, @"Database with removed keyfile is not secure anymore");
STAssertFalse(_databaseV3.hasPasswordOrKey, @"Database with removed keyfile is not secure anymore");
}