import org.cacert.gigi.GigiApiException;
import org.cacert.gigi.database.GigiPreparedStatement;
+import org.cacert.gigi.dbObjects.Assurance.AssuranceType;
+import org.cacert.gigi.dbObjects.ObjectCache;
import org.cacert.gigi.dbObjects.User;
import org.cacert.gigi.output.DateSelector;
-import org.cacert.gigi.testUtils.ManagedTest;
+import org.cacert.gigi.testUtils.BusinessTest;
import org.junit.Test;
-public class TestNotary extends ManagedTest {
+public class TestNotary extends BusinessTest {
+ // These tests create a lot of users and therefore require resetting of the
+ // registering-rate-limit.
@Test
public void testNormalAssurance() throws SQLException, GigiApiException {
User[] users = new User[30];
};
try {
- Notary.assure(assurer, users[0], users[0].getName(), users[0].getDoB(), -1, "test-notary", "2014-01-01");
+ Notary.assure(assurer, users[0], users[0].getPreferredName(), users[0].getDoB(), -1, "test-notary", "2014-01-01", AssuranceType.FACE_TO_FACE);
fail("This shouldn't have passed");
} catch (GigiApiException e) {
// expected
assertEquals(result[i], assurer.getMaxAssurePoints());
assuranceFail(assurer, users[i], result[i] + 1, "test-notary", "2014-01-01");
- Notary.assure(assurer, users[i], users[i].getName(), users[i].getDoB(), result[i], "test-notary", "2014-01-01");
+ Notary.assure(assurer, users[i], users[i].getPreferredName(), users[i].getDoB(), result[i], "test-notary", "2014-01-01", AssuranceType.FACE_TO_FACE);
assuranceFail(assurer, users[i], result[i], "test-notary", "2014-01-01");
}
private void assuranceFail(User assurer, User user, int i, String location, String date) throws SQLException {
try {
- Notary.assure(assurer, user, user.getName(), user.getDoB(), i, location, date);
+ Notary.assure(assurer, user, user.getPreferredName(), user.getDoB(), i, location, date, AssuranceType.FACE_TO_FACE);
fail("This shouldn't have passed");
} catch (GigiApiException e) {
// expected
ps.setInt(1, id);
ps.execute();
}
+ ObjectCache.clearAllCaches(); // reload values from db
User assurer = User.getById(id);
for (int i = 0; i < users.length; i++) {
assuranceFail(assurer, users[i], -1, "test-notary", "2014-01-01");
assuranceFail(assurer, users[i], 11, "test-notary", "2014-01-01");
- Notary.assure(assurer, users[i], users[i].getName(), users[i].getDoB(), 10, "test-notary", "2014-01-01");
+ if (User.POJAM_ENABLED) {
+ Notary.assure(assurer, users[i], users[i].getPreferredName(), users[i].getDoB(), 10, "test-notary", "2014-01-01", AssuranceType.FACE_TO_FACE);
+ }
assuranceFail(assurer, users[i], 10, "test-notary", "2014-01-01");
}
}
assuranceFail(assuree, assuranceUser, 10, "notary-junit-test", "2014-01-01");
// valid
- Notary.assure(assuranceUser, assuree, assuree.getName(), assuree.getDoB(), 10, "notary-junit-test", "2014-01-01");
+ Notary.assure(assuranceUser, assuree, assuree.getPreferredName(), assuree.getDoB(), 10, "notary-junit-test", "2014-01-01", AssuranceType.FACE_TO_FACE);
// assure double
assuranceFail(assuranceUser, assuree, 10, "notary-junit-test", "2014-01-01");