1 package org.cacert.gigi.pages.admin;
3 import static org.hamcrest.CoreMatchers.*;
4 import static org.junit.Assert.*;
6 import java.io.IOException;
7 import java.net.MalformedURLException;
9 import org.cacert.gigi.dbObjects.Group;
10 import org.cacert.gigi.pages.admin.support.SupportEnterTicketPage;
11 import org.cacert.gigi.pages.admin.support.SupportUserDetailsPage;
12 import org.cacert.gigi.testUtils.ClientTest;
13 import org.cacert.gigi.testUtils.TestEmailReceiver.TestMail;
14 import org.cacert.gigi.util.ServerConstants;
15 import org.junit.Test;
17 public class TestSEAdminNotificationMail extends ClientTest {
21 public TestSEAdminNotificationMail() throws IOException {
22 grant(email, Group.SUPPORTER);
23 assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=a20140808.8&setTicket=action", 0).getResponseCode());
25 String email = createUniqueName() + "@example.com";
26 String fname = "Först";
27 String lname = "Secönd";
28 targetID = createVerifiedUser(fname, lname, email, TEST_PASSWORD);
32 public void testChangeAccountData() throws MalformedURLException, IOException {
34 executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "dobd=1&dobm=2&doby=2000&detailupdate", 0);
36 String message = getMailReceiver().receive().getMessage();
37 assertThat(message, containsString("The account data was changed."));
38 assertThat(message, containsString("supporter " + u.getPreferredName().toString() + " triggered:"));
43 public void testPasswordReset() throws MalformedURLException, IOException {
44 executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "aword=SecretWord&resetPass", 0);
46 String targetMail = ServerConstants.getSupportMailAddress();
48 tm = getMailReceiver().receive();
49 } while ( !tm.getTo().equals(targetMail));
50 assertThat(tm.getMessage(), containsString("A password reset was triggered and an email was sent to user."));
54 public void testGrantUserGroup() throws MalformedURLException, IOException {
55 executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "grant&groupToModify=supporter", 0);
57 String message = getMailReceiver().receive().getMessage();
58 assertThat(message, containsString("The group permission supporter was granted."));
62 public void testRemoveUserGroup() throws MalformedURLException, IOException {
63 executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "deny&groupToModify=supporter", 0);
65 String message = getMailReceiver().receive().getMessage();
66 assertThat(message, containsString("The group permission supporter was revoked."));
70 public void testRevokeCertificates() throws MalformedURLException, IOException {
71 executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "revokeall", 1);
73 String message = getMailReceiver().receive().getMessage();
74 assertThat(message, containsString("All certificates in the account have been revoked."));