Skip to content
Snippets Groups Projects
Commit e2bf518e authored by Greg DiCristofaro's avatar Greg DiCristofaro
Browse files

Merge branch '8440-develop' into 8440-new_table_load

parents 6664eba0 a0be7000
No related branches found
No related tags found
No related merge requests found
...@@ -11034,7 +11034,8 @@ void setAcquisitionToolDetails(DataSource datasource, String name, String versio ...@@ -11034,7 +11034,8 @@ void setAcquisitionToolDetails(DataSource datasource, String name, String versio
* *
* @throws TskCoreException * @throws TskCoreException
*/ */
void setAcquisitionDetails(long dataSourceId, String details, CaseDbTransaction trans) throws TskCoreException { @Beta
public void setAcquisitionDetails(long dataSourceId, String details, CaseDbTransaction trans) throws TskCoreException {
try { try {
CaseDbConnection connection = trans.getConnection(); CaseDbConnection connection = trans.getConnection();
PreparedStatement statement = connection.getPreparedStatement(PREPARED_STATEMENT.UPDATE_ACQUISITION_DETAILS); PreparedStatement statement = connection.getPreparedStatement(PREPARED_STATEMENT.UPDATE_ACQUISITION_DETAILS);
......
...@@ -396,6 +396,87 @@ public void mergeRealmsTests() throws TskCoreException, OsAccountManager.NotUser ...@@ -396,6 +396,87 @@ public void mergeRealmsTests() throws TskCoreException, OsAccountManager.NotUser
} }
} }
@Test
public void updateRealmAndMergeTests() throws TskCoreException, OsAccountManager.NotUserSIDException {
/**
* Test the scenario where an update of an account triggers an update of
* a realm and subsequent merge of realms and accounts.
*/
Host host = caseDB.getHostManager().newHost("updateRealmAndMergeTestHost");
// Step 1: create a local account with SID and user name
String ownerUid1 = "S-1-5-21-1182664808-117526782-2525957323-13395";
String realmName1 = null;
String loginName1 = "sandip";
OsAccount osAccount1 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerUid1, loginName1, realmName1, host, OsAccountRealm.RealmScope.LOCAL);
OsAccountRealm realm1 = caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount1.getRealmId());
assertEquals(realm1.getRealmAddr().isPresent(), true); // verify the realm has a SID
assertEquals(realm1.getRealmNames().isEmpty(), true); // verify the realm has no name
// Step2: create a local account with domain name and username
String ownerUid2 = null;
String realmName2 = "CORP";
String loginName2 = "sandip";
Optional<OsAccount> oOsAccount2 = caseDB.getOsAccountManager().getWindowsOsAccount(ownerUid2, loginName2, realmName2, host);
// this account should not exists
assertEquals(oOsAccount2.isPresent(), false);
// create a new account - a new realm as there is nothing to tie it to realm1
OsAccount osAccount2 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerUid2, loginName2, realmName2, host, OsAccountRealm.RealmScope.LOCAL);
OsAccountRealm realm2 = caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount2.getRealmId());
assertTrue(osAccount1.getId() != osAccount2.getId());
assertTrue(realm1.getRealmId() != realm2.getRealmId());
// Step 3: now create/update the account with sid/domain/username
// this should return the existing account1, which needs to be updated.
String ownerUid3 = "S-1-5-21-1182664808-117526782-2525957323-13395";
String realmAddr3 = "S-1-5-21-1182664808-117526782-2525957323";
String loginName3 = "sandip";
String realmName3 = "CORP";
Optional<OsAccount> oOsAccount3 = caseDB.getOsAccountManager().getWindowsOsAccount(ownerUid3, loginName3, realmName3, host);
assertTrue(oOsAccount3.isPresent());
// update the account so that its domain gets updated.
OsAccountManager.OsAccountUpdateResult updateResult = caseDB.getOsAccountManager().updateCoreWindowsOsAccountAttributes(oOsAccount3.get(), ownerUid3, loginName3, realmName3, host);
Optional<OsAccount> updatedAccount3 = updateResult.getUpdatedAccount();
assertTrue(updatedAccount3.isPresent());
// this should cause the realm1 to be updated - and then realm2 to be merged into realm1
OsAccountRealm realm3 = caseDB.getOsAccountRealmManager().getRealmByRealmId(updatedAccount3.get().getRealmId());
assertTrue(realm3.getRealmId() == realm1.getRealmId());
assertTrue(realm3.getRealmAddr().isPresent()); // verify the realm gets an addr
assertTrue(realm3.getRealmAddr().get().equalsIgnoreCase(realmAddr3));
assertTrue(realm3.getRealmNames().get(0).equalsIgnoreCase(realmName3)); // verify realm name.
// And now verify that the realm2 has been merged into realm1.
OsAccountRealm realm22 = caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount2.getRealmId());
assertTrue(realm22.getDbStatus() == OsAccountRealm.RealmDbStatus.MERGED);
//and account2 has been merged into account1
OsAccount osAccount22 = caseDB.getOsAccountManager().getOsAccountByObjectId(osAccount2.getId());
assertTrue(osAccount22.getOsAccountDbStatus() == OsAccount.OsAccountDbStatus.MERGED);
}
@Test @Test
public void hostAddressTests() throws TskCoreException { public void hostAddressTests() throws TskCoreException {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment