X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2Fpages%2Forga%2FTestOrgaManagement.java;h=f0a07a801d39e24ff8c2d912834c36061385000e;hp=45406b56a9fa74aba3ca23beccb7ef924988e379;hb=8af6231b22da4fef795bcb54913faad6592b1a02;hpb=346185795ad8dd3dbfeb417d2dccb69a39af64be diff --git a/tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java b/tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java index 45406b56..f0a07a80 100644 --- a/tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java +++ b/tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java @@ -14,40 +14,37 @@ import org.cacert.gigi.dbObjects.Group; import org.cacert.gigi.dbObjects.Organisation; import org.cacert.gigi.dbObjects.Organisation.Affiliation; import org.cacert.gigi.dbObjects.User; +import org.cacert.gigi.testUtils.ClientTest; import org.cacert.gigi.testUtils.IOUtils; -import org.cacert.gigi.testUtils.ManagedTest; import org.junit.Test; -public class TestOrgaManagement extends ManagedTest { - - public User u = User.getById(createVerifiedUser("testuser", "testname", uniq + "@testdom.com", TEST_PASSWORD)); - - public String session; +public class TestOrgaManagement extends ClientTest { public TestOrgaManagement() throws IOException { u.grantGroup(u, Group.getByString("orgassurer")); clearCaches(); - session = login(uniq + "@testdom.com", TEST_PASSWORD); + cookie = login(email, TEST_PASSWORD); } @Test public void testAdd() throws IOException { - executeBasicWebInteraction(session, CreateOrgPage.DEFAULT_PATH, "O=name&contact=&L=K%C3%B6ln&ST=%C3%9C%C3%96%C3%84%C3%9F&C=DE&comments=jkl%C3%B6loiuzfdfgjlh%C3%B6", 0); + executeBasicWebInteraction(cookie, CreateOrgPage.DEFAULT_PATH, "O=name&contact=mail&L=K%C3%B6ln&ST=%C3%9C%C3%96%C3%84%C3%9F&C=DE&comments=jkl%C3%B6loiuzfdfgjlh%C3%B6", 0); Organisation[] orgs = Organisation.getOrganisations(0, 30); assertEquals(1, orgs.length); + assertEquals("mail", orgs[0].getContactEmail()); assertEquals("name", orgs[0].getName()); assertEquals("Köln", orgs[0].getCity()); assertEquals("ÜÖÄß", orgs[0].getProvince()); User u2 = User.getById(createVerifiedUser("testworker", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD)); - executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&affiliate=y&master=y", 1); + executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&do_affiliate=y&master=y", 1); List allAdmins = orgs[0].getAllAdmins(); assertEquals(1, allAdmins.size()); Affiliation affiliation = allAdmins.get(0); assertSame(u2, affiliation.getTarget()); assertTrue(affiliation.isMaster()); - executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&affiliate=y", 1); + executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&do_affiliate=y", 1); allAdmins = orgs[0].getAllAdmins(); assertEquals(2, allAdmins.size()); Affiliation affiliation2 = allAdmins.get(0); @@ -57,13 +54,13 @@ public class TestOrgaManagement extends ManagedTest { assertSame(u.getId(), affiliation2.getTarget().getId()); assertFalse(affiliation2.isMaster()); - executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&email=&affiliate=y", 1); + executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&email=&do_affiliate=y", 1); assertEquals(1, orgs[0].getAllAdmins().size()); - executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&email=&affiliate=y", 1); + executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&email=&do_affiliate=y", 1); assertEquals(0, orgs[0].getAllAdmins().size()); - executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "O=name1&contact=&L=K%C3%B6ln&ST=%C3%9C%C3%96%C3%84%C3%9F&C=DE&comments=jkl%C3%B6loiuzfdfgjlh%C3%B6", 0); + executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "O=name1&contact=&L=K%C3%B6ln&ST=%C3%9C%C3%96%C3%84%C3%9F&C=DE&comments=jkl%C3%B6loiuzfdfgjlh%C3%B6", 0); clearCaches(); orgs = Organisation.getOrganisations(0, 30); assertEquals("name1", orgs[0].getName()); @@ -88,13 +85,13 @@ public class TestOrgaManagement extends ManagedTest { assertEquals(404, ((HttpURLConnection) uc).getResponseCode()); uc = new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH).openConnection(); - uc.addRequestProperty("Cookie", session); + uc.addRequestProperty("Cookie", cookie); content = IOUtils.readURL(uc); assertThat(content, containsString("name21")); assertThat(content, containsString("name12")); - uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o1.getId()).openConnection(), session); + uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o1.getId()).openConnection(), cookie); assertEquals(200, ((HttpURLConnection) uc).getResponseCode()); - uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o2.getId()).openConnection(), session); + uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o2.getId()).openConnection(), cookie); assertEquals(200, ((HttpURLConnection) uc).getResponseCode()); o1.delete(); o2.delete();