use of com.zimbra.cs.ephemeral.EphemeralInput in project zm-mailbox by Zimbra.
the class MigrateAttributesTest method testErrorDuringMigration.
@Test
public void testErrorDuringMigration() throws Exception {
List<EphemeralInput> results = new LinkedList<EphemeralInput>();
EntrySource source = new DummyEntrySource(acct, acct, acct);
Multimap<String, Object> deletedAttrs = LinkedListMultimap.create();
List<String> attrsToMigrate = Arrays.asList(new String[] { Provisioning.A_zimbraAuthTokens, Provisioning.A_zimbraCsrfTokenData, Provisioning.A_zimbraLastLogonTimestamp });
DummyMigrationCallback callback = new DummyMigrationCallback(results, deletedAttrs);
callback.throwErrorDuringMigration = true;
AttributeMigration migration = new AttributeMigration(attrsToMigrate, source, callback, null);
try {
migration.migrateAllAccounts();
fail("synchronous migration should throw an exception");
} catch (ServiceException e) {
//make sure the root exception got thrown
assertTrue(e.getMessage().contains("Failure during migration"));
}
//make sure nothing got migrated
assertEquals(0, results.size());
migration = new AttributeMigration(attrsToMigrate, source, callback, 3);
try {
migration.migrateAllAccounts();
fail("async migration should throw an exception");
} catch (ServiceException e) {
assertTrue(e.getMessage().contains("Failure during migration"));
}
assertEquals(0, results.size());
}
use of com.zimbra.cs.ephemeral.EphemeralInput in project zm-mailbox by Zimbra.
the class MigrateAttributesTest method testLastLogonTimestampMigrationTask.
/*
* Test MigrationTask for last login timestamp
*/
@Test
public void testLastLogonTimestampMigrationTask() throws ServiceException {
List<EphemeralInput> results = new LinkedList<EphemeralInput>();
Map<String, AttributeConverter> converters = new HashMap<String, AttributeConverter>();
converters.put(Provisioning.A_zimbraLastLogonTimestamp, new StringAttributeConverter());
Multimap<String, Object> deletedAttrs = LinkedListMultimap.create();
MigrationTask task = new MigrationTask(acct, converters, new DummyMigrationCallback(results, deletedAttrs), true);
task.migrateAttributes();
assertEquals(1, results.size());
verifyLastLogonTimestampEphemeralInput(results.get(0), "currentdate");
Collection<Object> deleted = deletedAttrs.asMap().get(Provisioning.A_zimbraLastLogonTimestamp);
assertEquals(1, deleted.size());
assertTrue(deleted.contains("currentdate"));
}
use of com.zimbra.cs.ephemeral.EphemeralInput in project zm-mailbox by Zimbra.
the class AuthTokenConverter method convert.
@Override
public EphemeralInput convert(String attrName, Object ldapValue) {
String ldapValueStr = (String) ldapValue;
String[] parts = ldapValueStr.split("\\|");
if (parts.length != 3) {
ZimbraLog.ephemeral.warn("LDAP auth token %s cannot be parsed", ldapValueStr);
return null;
}
String token = parts[0];
Long expirationMillis;
try {
expirationMillis = Long.parseLong(parts[1]);
} catch (NumberFormatException e) {
ZimbraLog.ephemeral.warn("LDAP auth token %s does not have a valid expiration value", ldapValueStr);
return null;
}
String serverVersion = parts[2];
EphemeralKey key = new EphemeralKey(attrName, token);
EphemeralInput input = new EphemeralInput(key, serverVersion);
Expiration expiration = new AbsoluteExpiration(expirationMillis);
input.setExpiration(expiration);
return input;
}
Aggregations