]> WPIA git - gigi.git/blobdiff - tests/club/wpia/gigi/pages/orga/TestOrgSwitch.java
add: ensure that for Org Administrator actions certificate login is used
[gigi.git] / tests / club / wpia / gigi / pages / orga / TestOrgSwitch.java
index 94586e3452de2558126cf0113ba42a2b41264338..90362a9a8cac0be7a2e954e6258bc61715507a70 100644 (file)
@@ -5,6 +5,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
 
 import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URLConnection;
 import java.net.URLEncoder;
 import java.sql.SQLException;
 
@@ -35,7 +37,7 @@ public class TestOrgSwitch extends OrgTest {
         assertNull(executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + org2.getId(), "email=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&do_affiliate=y&master=y", 1));
 
         // login with new user u2
-        cookie = login(email, TEST_PASSWORD);
+        cookie = cookieWithCertificateLogin(u2);
     }
 
     @After
@@ -49,7 +51,7 @@ public class TestOrgSwitch extends OrgTest {
         assertNull(executeBasicWebInteraction(cookie, SwitchOrganisation.PATH, "org:" + org1.getId() + "=y", 0));
 
         String res = IOUtils.readURL(get(SwitchOrganisation.PATH));
-        assertThat(res, containsString("Logged in as " + org1.getName() + " (on behalf of " + u2.getPreferredName()));
+        assertThat(res, containsString("Logged in as " + u2.getPreferredName() + ", acting as " + org1.getName()));
 
     }
 
@@ -83,7 +85,7 @@ public class TestOrgSwitch extends OrgTest {
         assertNull(executeBasicWebInteraction(cookie, SwitchOrganisation.PATH, "org:" + org2.getId() + "=y", 0));
 
         String res = IOUtils.readURL(get(SwitchOrganisation.PATH));
-        assertThat(res, containsString("Logged in as " + org2.getName() + " (on behalf of " + u2.getPreferredName()));
+        assertThat(res, containsString("Logged in as " + u2.getPreferredName() + ", acting as " + org2.getName()));
 
     }
 
@@ -94,7 +96,7 @@ public class TestOrgSwitch extends OrgTest {
         assertNull(executeBasicWebInteraction(cookie, SwitchOrganisation.PATH, "org:" + org1.getId() + "=y", 0));
 
         String res = IOUtils.readURL(get(SwitchOrganisation.PATH));
-        assertThat(res, containsString("Logged in as " + org1.getName() + " (on behalf of " + u2.getPreferredName()));
+        assertThat(res, containsString("Logged in as " + u2.getPreferredName() + ", acting as " + org1.getName()));
 
     }
 
@@ -118,4 +120,11 @@ public class TestOrgSwitch extends OrgTest {
 
     }
 
+    @Test
+    public void testSwitchOrgPasswordLogin() throws IOException, GigiApiException {
+        cookie = login(email, TEST_PASSWORD);
+        loginCertificate = null;
+        URLConnection uc = get(cookie, SwitchOrganisation.PATH);
+        assertEquals(403, ((HttpURLConnection) uc).getResponseCode());
+    }
 }