From 6a1674d74d2d056ceea8088fdc6fa79da1f9e8ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Fri, 27 Jun 2014 18:15:44 +0200 Subject: [PATCH] Add the race condition test case. --- .../cacert/gigi/pages/wot/TestAssurance.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/org/cacert/gigi/pages/wot/TestAssurance.java b/tests/org/cacert/gigi/pages/wot/TestAssurance.java index b072ad60..b81a4333 100644 --- a/tests/org/cacert/gigi/pages/wot/TestAssurance.java +++ b/tests/org/cacert/gigi/pages/wot/TestAssurance.java @@ -6,10 +6,13 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; +import java.sql.PreparedStatement; +import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.Date; import org.cacert.gigi.IOUtils; +import org.cacert.gigi.database.DatabaseConnection; import org.cacert.gigi.testUtils.ManagedTest; import org.junit.Before; import org.junit.Test; @@ -73,6 +76,21 @@ public class TestAssurance extends ManagedTest { String error = getError("date=2000-01-01&location=testcase&certify=1&rules=1&CCAAgreed=1&assertion=1&points=10"); assertTrue(error, error.startsWith("")); } + + @Test + public void testAssureFormRace() throws IOException, SQLException { + URLConnection uc = buildupAssureFormConnection(); + PreparedStatement ps = DatabaseConnection.getInstance().prepare( + "UPDATE `users` SET email='changed' WHERE id=?"); + ps.setInt(1, assuree); + ps.execute(); + uc.getOutputStream() + .write(("date=2000-01-01&location=testcase&certify=1&rules=1&CCAAgreed=1&assertion=1&points=10") + .getBytes()); + uc.getOutputStream().flush(); + String error = fetchStartErrorMessage(IOUtils.readURL(uc)); + assertTrue(error, !error.startsWith("")); + } @Test public void testAssureFormFuture() throws IOException { SimpleDateFormat sdf = new SimpleDateFormat("YYYY"); -- 2.39.2