X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2Fpages%2Forga%2FTestOrgaManagement.java;h=6fe4f1828d57d79b771d3ac2d6b414e0feff00ab;hb=bc51ef4b743b32a7cd3f917a65a2884155b589bb;hp=a21eff56d25f95c63b8ef86842f28f33a5673a51;hpb=1f61ecd4dcc1a9595f41ea8aae52442be9bd2353;p=gigi.git diff --git a/tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java b/tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java index a21eff56..6fe4f182 100644 --- a/tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java +++ b/tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java @@ -5,9 +5,9 @@ import static org.junit.Assert.*; import java.io.IOException; 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; @@ -18,6 +18,7 @@ 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 { @@ -29,6 +30,11 @@ 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)) { @@ -80,28 +86,25 @@ public class TestOrgaManagement extends ClientTest { o1.addAdmin(u2, u, false); String session2 = login(u2.getEmail(), TEST_PASSWORD); - URLConnection uc = new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH).openConnection(); - uc.addRequestProperty("Cookie", session2); + URLConnection uc = get(session2, ViewOrgPage.DEFAULT_PATH); assertEquals(403, ((HttpURLConnection) uc).getResponseCode()); - uc = new URL("https://" + getServerName() + MyDetails.PATH).openConnection(); - uc.addRequestProperty("Cookie", session2); + uc = get(session2, MyDetails.PATH); 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); + uc = get(session2, ViewOrgPage.DEFAULT_PATH + "/" + o1.getId()); assertEquals(403, ((HttpURLConnection) uc).getResponseCode()); - uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o2.getId()).openConnection(), session2); + uc = get(session2, ViewOrgPage.DEFAULT_PATH + "/" + o2.getId()); assertEquals(403, ((HttpURLConnection) uc).getResponseCode()); - uc = new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH).openConnection(); - uc.addRequestProperty("Cookie", cookie); + uc = get(ViewOrgPage.DEFAULT_PATH); content = IOUtils.readURL(uc); assertThat(content, containsString("name21")); assertThat(content, containsString("name12")); - uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o1.getId()).openConnection(), cookie); + uc = get(ViewOrgPage.DEFAULT_PATH + "/" + o1.getId()); assertEquals(200, ((HttpURLConnection) uc).getResponseCode()); - uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o2.getId()).openConnection(), cookie); + uc = get(ViewOrgPage.DEFAULT_PATH + "/" + o2.getId()); assertEquals(200, ((HttpURLConnection) uc).getResponseCode()); o1.delete(); o2.delete();