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.GigiApiException;
10 import org.cacert.gigi.dbObjects.Group;
11 import org.cacert.gigi.pages.admin.support.SupportEnterTicketPage;
12 import org.cacert.gigi.pages.admin.support.SupportUserDetailsPage;
13 import org.cacert.gigi.testUtils.ClientTest;
14 import org.cacert.gigi.testUtils.TestEmailReceiver.TestMail;
15 import org.cacert.gigi.util.ServerConstants;
16 import org.junit.Test;
18 public class TestSEAdminNotificationMail extends ClientTest {
22 public TestSEAdminNotificationMail() throws IOException, GigiApiException {
23 grant(u, Group.SUPPORTER);
24 cookie = login(email, TEST_PASSWORD);
25 assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=a20140808.8&setTicket=action", 0).getResponseCode());
27 String email = createUniqueName() + "@example.com";
28 String fname = "Först";
29 String lname = "Secönd";
30 targetID = createVerifiedUser(fname, lname, email, TEST_PASSWORD);
34 public void testChangeAccountData() throws MalformedURLException, IOException {
36 executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "dobd=1&dobm=2&doby=2000&detailupdate", 0);
38 String message = getMailReceiver().receive().getMessage();
39 assertThat(message, containsString("The account data was changed."));
40 assertThat(message, containsString("supporter " + u.getPreferredName().toString() + " triggered:"));
45 public void testPasswordReset() throws MalformedURLException, IOException {
46 executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "aword=SecretWord&resetPass", 0);
48 String targetMail = ServerConstants.getSupportMailAddress();
50 tm = getMailReceiver().receive();
51 } while ( !tm.getTo().equals(targetMail));
52 assertThat(tm.getMessage(), containsString("A password reset was triggered and an email was sent to user."));
56 public void testGrantUserGroup() throws MalformedURLException, IOException {
57 executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "addGroup&groupToModify=supporter", 0);
59 String message = getMailReceiver().receive().getMessage();
60 assertThat(message, containsString("The group permission supporter was granted."));
64 public void testRemoveUserGroup() throws MalformedURLException, IOException {
65 executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "removeGroup&groupToModify=supporter", 0);
67 String message = getMailReceiver().receive().getMessage();
68 assertThat(message, containsString("The group permission supporter was revoked."));
72 public void testRevokeCertificates() throws MalformedURLException, IOException {
73 executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "revokeall", 1);
75 String message = getMailReceiver().receive().getMessage();
76 assertThat(message, containsString("All certificates in the account have been revoked."));