X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2Fpages%2Forga%2FTestOrgaManagement.java;h=3ecc7a21dbb6705525db623b206c21390adba97e;hb=904cc8f11532b1a87c1fb19a69bdcf248ad9be30;hp=c8a6c1394d8627dd1303bf6134b4468dfc32deaa;hpb=280be756fb425fc8148ade698f51528e1e9106c2;p=gigi.git diff --git a/tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java b/tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java index c8a6c139..3ecc7a21 100644 --- a/tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java +++ b/tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java @@ -8,6 +8,7 @@ import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; +import java.sql.SQLException; import java.util.List; import org.cacert.gigi.GigiApiException; @@ -15,8 +16,10 @@ 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.pages.account.MyDetails; import org.cacert.gigi.testUtils.ClientTest; import org.cacert.gigi.testUtils.IOUtils; +import org.junit.After; import org.junit.Test; public class TestOrgaManagement extends ClientTest { @@ -28,8 +31,16 @@ public class TestOrgaManagement extends ClientTest { cookie = login(email, TEST_PASSWORD); } + @After + public void purgeDbAfterTest() throws SQLException, IOException { + purgeDatabase(); + } + @Test public void testAdd() throws IOException { + for (Organisation i : Organisation.getOrganisations(0, 30)) { + i.delete(); + } 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); @@ -53,7 +64,7 @@ public class TestOrgaManagement extends ClientTest { if (affiliation2.getTarget().getId() == u2.getId()) { affiliation2 = allAdmins.get(1); } - assertSame(u.getId(), affiliation2.getTarget().getId()); + assertEquals(u.getId(), affiliation2.getTarget().getId()); assertFalse(affiliation2.isMaster()); executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&email=&do_affiliate=y", 1); @@ -78,13 +89,17 @@ public class TestOrgaManagement extends ClientTest { URLConnection uc = new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH).openConnection(); uc.addRequestProperty("Cookie", session2); + assertEquals(403, ((HttpURLConnection) uc).getResponseCode()); + + uc = new URL("https://" + getServerName() + MyDetails.PATH).openConnection(); + uc.addRequestProperty("Cookie", session2); String content = IOUtils.readURL(uc); assertThat(content, containsString("name21")); assertThat(content, not(containsString("name12"))); uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o1.getId()).openConnection(), session2); - assertEquals(200, ((HttpURLConnection) uc).getResponseCode()); + assertEquals(403, ((HttpURLConnection) uc).getResponseCode()); uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o2.getId()).openConnection(), session2); - assertEquals(404, ((HttpURLConnection) uc).getResponseCode()); + assertEquals(403, ((HttpURLConnection) uc).getResponseCode()); uc = new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH).openConnection(); uc.addRequestProperty("Cookie", cookie);