]> WPIA git - gigi.git/commitdiff
add: test case for user opt-in notification for RA Agents
authorINOPIAE <m.maengel@inopiae.de>
Mon, 22 Aug 2016 08:24:15 +0000 (10:24 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Thu, 8 Sep 2016 04:48:05 +0000 (06:48 +0200)
Change-Id: I896cb3d9f6c6f894001cb8d26f6a84f8b3fc8e6c

tests/org/cacert/gigi/pages/wot/TestAssurance.java

index 3ae4ccd4afa204b61a93a514dc4cdb8f6ad4897c..0af859ccc979ad664a0cc47a682ae9365ce25bba 100644 (file)
@@ -19,10 +19,12 @@ import java.util.regex.Pattern;
 import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.database.GigiPreparedStatement;
 import org.cacert.gigi.dbObjects.Country;
 import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.database.GigiPreparedStatement;
 import org.cacert.gigi.dbObjects.Country;
+import org.cacert.gigi.dbObjects.Group;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.pages.account.MyDetails;
 import org.cacert.gigi.testUtils.IOUtils;
 import org.cacert.gigi.testUtils.ManagedTest;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.pages.account.MyDetails;
 import org.cacert.gigi.testUtils.IOUtils;
 import org.cacert.gigi.testUtils.ManagedTest;
+import org.cacert.gigi.testUtils.TestEmailReceiver.TestMail;
 import org.cacert.gigi.util.DayDate;
 import org.cacert.gigi.util.Notary;
 import org.hamcrest.Matcher;
 import org.cacert.gigi.util.DayDate;
 import org.cacert.gigi.util.Notary;
 import org.hamcrest.Matcher;
@@ -323,4 +325,52 @@ public class TestAssurance extends ManagedTest {
         executeFails("date=" + validVerificationDateString() + "&location=testcase&countryCode=&certify=1&rules=1&assertion=1&points=10");
     }
 
         executeFails("date=" + validVerificationDateString() + "&location=testcase&countryCode=&certify=1&rules=1&assertion=1&points=10");
     }
 
+    @Test
+    public void testRANotificationSet() throws IOException, GigiApiException {
+        getMailReceiver().clearMails();
+
+        User users[] = User.findByEmail(assurerM);
+        assertTrue("user RA Agent not found", users != null && users.length > 0);
+
+        User u = users[0];
+        u.grantGroup(u, Group.VERIFY_NOTIFICATION);
+        clearCaches();
+        cookie = login(assurerM, TEST_PASSWORD);
+
+        String targetMail = u.getEmail();
+
+        // enter verification
+        String uniqueLoc = createUniqueName();
+        executeSuccess("date=" + validVerificationDateString() + "&location=" + uniqueLoc + "&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
+        TestMail tm;
+
+        do {
+            tm = getMailReceiver().receive();
+        } while ( !tm.getTo().equals(targetMail));
+        assertThat(tm.getMessage(), containsString("You entered a verification for the account with email address " + assureeM));
+
+    }
+
+    @Test
+    public void testRANotificationNotSet() throws IOException, GigiApiException {
+        getMailReceiver().clearMails();
+
+        User users[] = User.findByEmail(assurerM);
+        assertTrue("user RA Agent not found", users != null && users.length > 0);
+
+        User u = users[0];
+        u.revokeGroup(u, Group.VERIFY_NOTIFICATION);
+        clearCaches();
+        cookie = login(assurerM, TEST_PASSWORD);
+
+        // enter verification
+        String uniqueLoc = createUniqueName();
+        executeSuccess("date=" + validVerificationDateString() + "&location=" + uniqueLoc + "&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
+
+        TestMail tm;
+
+        tm = getMailReceiver().receive();
+        assertThat(tm.getMessage(), not(containsString("You entered a verification for the account with email address " + assureeM)));
+
+    }
 }
 }