import org.cacert.gigi.GigiApiException;
import org.cacert.gigi.dbObjects.Domain;
-import org.cacert.gigi.dbObjects.Group;
import org.cacert.gigi.dbObjects.Organisation;
-import org.cacert.gigi.testUtils.ClientTest;
+import org.cacert.gigi.testUtils.OrgTest;
import org.junit.Test;
-public class TestOrgDomain extends ClientTest {
+public class TestOrgDomain extends OrgTest {
public TestOrgDomain() throws IOException {
- makeAssurer(u.getId());
- u.grantGroup(u, Group.ORGASSURER);
- clearCaches();
- cookie = login(email, TEST_PASSWORD);
+
}
@Test
assertEquals(0, u.getDomains().length);
}
- private Organisation createUniqueOrg() throws GigiApiException {
- Organisation o1 = new Organisation(createUniqueName(), "st", "pr", "city", "test@example.com", "", "", u);
- return o1;
- }
-
@Test
public void testBusinessAddInvalid() throws IOException, GigiApiException {
Organisation o1 = createUniqueOrg();
import java.util.List;
import org.cacert.gigi.GigiApiException;
-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.cacert.gigi.testUtils.OrgTest;
import org.junit.After;
import org.junit.Test;
-public class TestOrgaManagement extends ClientTest {
+public class TestOrgManagement extends OrgTest {
+
+ public TestOrgManagement() throws IOException {
- public TestOrgaManagement() throws IOException {
- u.grantGroup(u, Group.ORGASSURER);
- makeAssurer(u.getId());
- clearCaches();
- cookie = login(email, TEST_PASSWORD);
}
@After
@Test
public void testNonAssurerSeeOnlyOwn() throws IOException, GigiApiException {
User u2 = User.getById(createAssuranceUser("testworker", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD));
- Organisation o1 = new Organisation("name21", "DE", "sder", "Rostov", "email", "", "", u);
- Organisation o2 = new Organisation("name12", "DE", "sder", "Rostov", "email", "", "", u);
+ Organisation o1 = createUniqueOrg();
+ Organisation o2 = createUniqueOrg();
o1.addAdmin(u2, u, false);
String session2 = login(u2.getEmail(), TEST_PASSWORD);
uc = get(session2, MyDetails.PATH);
String content = IOUtils.readURL(uc);
- assertThat(content, containsString("name21"));
- assertThat(content, not(containsString("name12")));
+ assertThat(content, containsString(o1.getName()));
+ assertThat(content, not(containsString(o2.getName())));
uc = get(session2, ViewOrgPage.DEFAULT_PATH + "/" + o1.getId());
assertEquals(403, ((HttpURLConnection) uc).getResponseCode());
uc = get(session2, ViewOrgPage.DEFAULT_PATH + "/" + o2.getId());
uc = get(ViewOrgPage.DEFAULT_PATH);
content = IOUtils.readURL(uc);
- assertThat(content, containsString("name21"));
- assertThat(content, containsString("name12"));
+ assertThat(content, containsString(o1.getName()));
+ assertThat(content, containsString(o2.getName()));
uc = get(ViewOrgPage.DEFAULT_PATH + "/" + o1.getId());
assertEquals(200, ((HttpURLConnection) uc).getResponseCode());
uc = get(ViewOrgPage.DEFAULT_PATH + "/" + o2.getId());
User u2 = User.getById(createAssuranceUser("testworker", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD));
User u3 = User.getById(createAssuranceUser("testmaster", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD));
User u4_dummy = User.getById(createVerifiedUser("testmaster", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD));
- Organisation o1 = new Organisation("name21", "DE", "sder", "Rostov", "email", "", "", u);
+ Organisation o1 = createUniqueOrg();
o1.addAdmin(u3, u, true);
try {
// must fail because u4 is no assurer
--- /dev/null
+package org.cacert.gigi.testUtils;
+
+import java.io.IOException;
+
+import org.cacert.gigi.GigiApiException;
+import org.cacert.gigi.dbObjects.Group;
+import org.cacert.gigi.dbObjects.Organisation;
+
+public class OrgTest extends ClientTest {
+
+ public OrgTest() throws IOException {
+ makeAssurer(u.getId());
+ u.grantGroup(u, Group.ORGASSURER);
+ clearCaches();
+ cookie = login(email, TEST_PASSWORD);
+ }
+
+ public Organisation createUniqueOrg() throws GigiApiException {
+ Organisation o1 = new Organisation(createUniqueName(), "st", "pr", "city", "test@example.com", "", "", u);
+ return o1;
+ }
+}