]> WPIA git - gigi.git/commitdiff
upd: url for support details (so relative URLs are better)
authorFelix Dörre <felix@dogcraft.de>
Thu, 4 Aug 2016 10:10:39 +0000 (12:10 +0200)
committerFelix Dörre <felix@dogcraft.de>
Sat, 6 Aug 2016 10:04:07 +0000 (12:04 +0200)
Change-Id: I5d1dd30d7cb15bc8430dbae2f981f952a4705ec7

src/org/cacert/gigi/output/AssurancesDisplay.templ
src/org/cacert/gigi/pages/admin/support/FindUserByDomainPage.java
src/org/cacert/gigi/pages/admin/support/FindUserByEmailForm.templ
src/org/cacert/gigi/pages/admin/support/FindUserByEmailPage.java
src/org/cacert/gigi/pages/admin/support/SupportUserDetailsForm.java
src/org/cacert/gigi/pages/admin/support/SupportUserDetailsForm.templ
src/org/cacert/gigi/pages/admin/support/SupportUserDetailsPage.java
tests/org/cacert/gigi/pages/admin/TestSEAdminNotificationMail.java
tests/org/cacert/gigi/pages/admin/TestSEAdminPageDetails.java
tests/org/cacert/gigi/pages/admin/TestSEAdminPageUserDomainSearch.java
tests/org/cacert/gigi/pages/admin/TestSEAdminPageUserMailSearch.java

index a36e3583f1e748f53d599cc83810db07ef190a97..b7c0e4fce9f16db73b042e452a190834076511fb 100644 (file)
@@ -14,7 +14,7 @@
 <? foreach($assurances) {?>
 <tr>
 <? if($support) { ?>
-<td><a href="/support/user/<?=$linkId?>"><?=$id?></a></td>
+<td><a href="/support/user/<?=$linkId?>/"><?=$id?></a></td>
 <? } else { ?>
 <td><?=$id?></td>
 <? } ?>
index ee5192b0225051f32bdd18d900953b7f13f334c1..3572d3e626460699d2d2ca4ef28189c81977cb1f 100644 (file)
@@ -19,7 +19,7 @@ public class FindUserByDomainPage extends OneFormPage {
     public String getSuccessPath(Form f) {
         CertificateOwner res = ((FindUserByDomainForm) f).getRes();
         if (res instanceof User) {
-            return SupportUserDetailsPage.PATH + res.getId();
+            return SupportUserDetailsPage.PATH + res.getId() + "/";
         } else if (res instanceof Organisation) {
             return "/support/domain/" + res.getId();
         } else {
index 0461bc39dad56d6556fca30cd5fc563457dd615f..a6b4549c63d9901f0ea86dfe09249949fbb14bc5 100644 (file)
@@ -4,7 +4,7 @@
 <tr>
 <th>Id</th><th>E-Mail</th></tr>
 <? foreach($usertable) {?>
-       <tr><td><a href="/support/user/<?=$usrid?>"><?=$usrid?></a></td><td><a href="/support/user/<?=$usrid?>"><?=$usermail?></a></td></tr>
+       <tr><td><a href="/support/user/<?=$usrid?>/"><?=$usrid?></a></td><td><a href="/support/user/<?=$usrid?>/"><?=$usermail?></a></td></tr>
 <? } ?>
 </table>
 <? } ?>
index 42d9e8d00ec6826df87a610885fe388f03003d2b..85e69a33fb6fa87697114c27d1dcb71e7428ab88 100644 (file)
@@ -37,7 +37,7 @@ public class FindUserByEmailPage extends Page {
             form.submit(resp.getWriter(), req);
             final EmailAddress[] emails = form.getEmails();
             if (emails.length == 1) {
-                resp.sendRedirect(SupportUserDetailsPage.PATH + emails[0].getOwner().getId());
+                resp.sendRedirect(SupportUserDetailsPage.PATH + emails[0].getOwner().getId() + "/");
             } else {
                 HashMap<String, Object> vars = new HashMap<String, Object>();
                 vars.put("first", false);
index f97b2c44e0601d9eccecb6356899ff282400379e..8b37e903c8b3950f8870c13bc591e5e43e97730c 100644 (file)
@@ -106,7 +106,6 @@ public class SupportUserDetailsForm extends Form {
         vars.put("dob", dobSelector);
         vars.put("assurancepoints", user.getAssurancePoints());
         vars.put("exppoints", user.getExperiencePoints());
-        vars.put("id", user.getId());
         final Set<Group> gr = user.getGroups();
         vars.put("groups", new IterableDataset() {
 
index b73cc6daa180f4e1fd77f92d6b24e8a213816a38..2e4759652f0f823481ee19f540682a09016284ba 100644 (file)
@@ -20,7 +20,7 @@
         </tr>
         <tr>
             <td><?=_Trainings?>:</td>
-            <td><a href="./<?=$id?>/trainings"><?=_Show?></a></td>
+            <td><a href="trainings"><?=_Show?></a></td>
         </tr>
         <tr>
             <td><?=_Is RA Agent?>:</td>
@@ -34,7 +34,7 @@
         </tr>
         <tr>
             <td><?=_Verification Points?>:</td>
-            <td><?=$assurancepoints?> (<a href="./<?=$id?>/points"><?=_Show?></a>)</td>
+            <td><?=$assurancepoints?> (<a href="./points"><?=_Show?></a>)</td>
         </tr>
         <tr>
             <td><?=_Experience Points?>:</td>
@@ -59,7 +59,7 @@
             <td><?=_Show Lost Password Details?></td>
         </tr>
             <tr>
-            <td colspan="2"><a href="./<?=$id?>/history"><?=_Show account history?></a></td>
+            <td colspan="2"><a href="history"><?=_Show account history?></a></td>
         </tr>
         <tr><td colspan="2"><input name="detailupdate" type="submit" value="<?=_Update?>"/></td></tr>
     </tbody>
index fad39e90c4007cc2b69b7f2eb90e0d78280d325f..5f626b4ef5d24e3c78a8c7afea46843e664b91f3 100644 (file)
@@ -30,6 +30,9 @@ public class SupportUserDetailsPage extends Page {
     @Override
     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
         int id = -1;
+        if ( !req.getPathInfo().endsWith("/")) {
+            resp.sendError(404);
+        }
         String[] idP = req.getPathInfo().split("/");
         try {
             id = Integer.parseInt(idP[idP.length - 1]);
index 033f69a6a8445b43b637d7f99e788e318631a59c..45e0ca3805f75b702c515fcadd1df0aa8fe90ab2 100644 (file)
@@ -31,7 +31,7 @@ public class TestSEAdminNotificationMail extends ClientTest {
     @Test
     public void testChangeAccountData() throws MalformedURLException, IOException {
 
-        executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID, "dobd=1&dobm=2&doby=2000&detailupdate", 0);
+        executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "dobd=1&dobm=2&doby=2000&detailupdate", 0);
 
         String message = getMailReceiver().receive().getMessage();
         assertThat(message, containsString("The account data was changed."));
@@ -41,7 +41,7 @@ public class TestSEAdminNotificationMail extends ClientTest {
 
     @Test
     public void testPasswordReset() throws MalformedURLException, IOException {
-        executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID, "aword=SecretWord&resetPass", 0);
+        executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "aword=SecretWord&resetPass", 0);
         TestMail tm;
         String targetMail = ServerConstants.getSupportMailAddress();
         do {
@@ -52,7 +52,7 @@ public class TestSEAdminNotificationMail extends ClientTest {
 
     @Test
     public void testGrantUserGroup() throws MalformedURLException, IOException {
-        executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID, "grant&groupToModify=supporter", 0);
+        executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "grant&groupToModify=supporter", 0);
 
         String message = getMailReceiver().receive().getMessage();
         assertThat(message, containsString("The group permission supporter was granted."));
@@ -60,7 +60,7 @@ public class TestSEAdminNotificationMail extends ClientTest {
 
     @Test
     public void testRemoveUserGroup() throws MalformedURLException, IOException {
-        executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID, "deny&groupToModify=supporter", 0);
+        executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "deny&groupToModify=supporter", 0);
 
         String message = getMailReceiver().receive().getMessage();
         assertThat(message, containsString("The group permission supporter was revoked."));
@@ -68,7 +68,7 @@ public class TestSEAdminNotificationMail extends ClientTest {
 
     @Test
     public void testRevokeCertificates() throws MalformedURLException, IOException {
-        executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID, "revokeall", 1);
+        executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID + "/", "revokeall", 1);
 
         String message = getMailReceiver().receive().getMessage();
         assertThat(message, containsString("All certificates in the account have been revoked."));
index 44c23535a9bfe5d8c422a754268fe85cbfb63ef3..3e1bb64cc805264a7d761b1f0deb47d7290dac08 100644 (file)
@@ -39,7 +39,7 @@ public class TestSEAdminPageDetails extends ClientTest {
         String fname = "Först";
         String lname = "Secönd";
         int id = createVerifiedUser(fname, lname, email, TEST_PASSWORD);
-        URLConnection uc = get(SupportUserDetailsPage.PATH + id);
+        URLConnection uc = get(SupportUserDetailsPage.PATH + id + "/");
         uc.setDoOutput(true);
         String res = IOUtils.readURL(uc);
         assertThat(res, containsString(fname));
@@ -61,13 +61,13 @@ public class TestSEAdminPageDetails extends ClientTest {
         ea = EmailAddress.getById(ea.getId());
         assertTrue(ea.isVerified());
 
-        String res = IOUtils.readURL(get(SupportUserDetailsPage.PATH + id));
+        String res = IOUtils.readURL(get(SupportUserDetailsPage.PATH + id + "/"));
         assertEquals(2, countRegex(res, Pattern.quote(email)));
         assertEquals(1, countRegex(res, Pattern.quote(email2)));
 
         User.getById(id).updateDefaultEmail(ea);
         clearCaches();
-        res = IOUtils.readURL(get(SupportUserDetailsPage.PATH + id));
+        res = IOUtils.readURL(get(SupportUserDetailsPage.PATH + id + "/"));
         assertEquals(1, countRegex(res, Pattern.quote(email)));
         assertEquals(2, countRegex(res, Pattern.quote(email2)));
     }
@@ -83,27 +83,27 @@ public class TestSEAdminPageDetails extends ClientTest {
         assertEquals(0, logCountAdmin(id));
         assertEquals(0, logCountUser(clientCookie));
         // changing both leads to 2 entries
-        assertNull(executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + id, "dobd=1&dobm=2&doby=2000&detailupdate", 0));
+        assertNull(executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + id + "/", "dobd=1&dobm=2&doby=2000&detailupdate", 0));
         assertEquals(1, logCountAdmin(id));
         assertEquals(1, logCountUser(clientCookie));
 
         // Sending same data keeps same
-        assertNull(executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + id, "dobd=1&dobm=2&doby=2000&detailupdate", 0));
+        assertNull(executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + id + "/", "dobd=1&dobm=2&doby=2000&detailupdate", 0));
         assertEquals(1, logCountAdmin(id));
         assertEquals(1, logCountUser(clientCookie));
 
         // changing one leads to one entry
-        assertNull(executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + id, "dobd=1&dobm=3&doby=2000&detailupdate", 0));
+        assertNull(executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + id + "/", "dobd=1&dobm=3&doby=2000&detailupdate", 0));
         assertEquals(2, logCountAdmin(id));
         assertEquals(2, logCountUser(clientCookie));
 
         // changing one leads to one entry
-        assertNull(executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + id, "dobd=2&dobm=3&doby=2000&detailupdate", 0));
+        assertNull(executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + id + "/", "dobd=2&dobm=3&doby=2000&detailupdate", 0));
         assertEquals(3, logCountAdmin(id));
         assertEquals(3, logCountUser(clientCookie));
 
         // changing none -> no entry
-        assertNull(executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + id, "dobd=2&dobm=3&doby=2000&detailupdate", 0));
+        assertNull(executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + id + "/", "dobd=2&dobm=3&doby=2000&detailupdate", 0));
         assertEquals(3, logCountAdmin(id));
         assertEquals(3, logCountUser(clientCookie));
 
index a4fb4b437b77d6084087d782ff69c53490d11bad..d1916c10d6bfa4cf139f1e46c633970bff2dab87 100644 (file)
@@ -47,13 +47,13 @@ public class TestSEAdminPageUserDomainSearch extends ClientTest {
     public void testDomainSearch() throws MalformedURLException, UnsupportedEncodingException, IOException, GigiApiException {
         URLConnection uc = post(FindUserByDomainPage.PATH, "process&domain=" + URLEncoder.encode(domainName, "UTF-8"));
 
-        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + tid, uc.getHeaderField("Location"));
+        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + tid + "/", uc.getHeaderField("Location"));
     }
 
     @Test
     public void testDomainSearchById() throws MalformedURLException, UnsupportedEncodingException, IOException, GigiApiException {
         URLConnection uc = post(FindUserByDomainPage.PATH, "process&domain=#" + d.getId());
-        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + tid, uc.getHeaderField("Location"));
+        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + tid + "/", uc.getHeaderField("Location"));
     }
 
     @Test
index bb05a71b71b04b8de58bd76b0b5d3da748606e57..71dfeaee5071f1f52ad3ac95f172f699eab5a849 100644 (file)
@@ -33,7 +33,7 @@ public class TestSEAdminPageUserMailSearch extends ClientTest {
         int id = createVerifiedUser("Först", "Secönd", mail, TEST_PASSWORD);
 
         URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode(mail, "UTF-8"), 0);
-        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + id, uc.getHeaderField("Location"));
+        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + id + "/", uc.getHeaderField("Location"));
     }
 
     @Test
@@ -42,7 +42,7 @@ public class TestSEAdminPageUserMailSearch extends ClientTest {
         int id = createVerifiedUser("Först", "Secönd", mail, TEST_PASSWORD);
 
         URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@example.tld", "UTF-8"), 0);
-        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + id, uc.getHeaderField("Location"));
+        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + id + "/", uc.getHeaderField("Location"));
     }
 
     @Test
@@ -54,8 +54,8 @@ public class TestSEAdminPageUserMailSearch extends ClientTest {
         URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@example.org", "UTF-8"), 0);
 
         String res = IOUtils.readURL(uc);
-        assertThat(res, containsString(SupportUserDetailsPage.PATH + id));
-        assertThat(res, containsString(SupportUserDetailsPage.PATH + id2));
+        assertThat(res, containsString(SupportUserDetailsPage.PATH + id + "/"));
+        assertThat(res, containsString(SupportUserDetailsPage.PATH + id2 + "/"));
     }
 
     @Test
@@ -68,8 +68,8 @@ public class TestSEAdminPageUserMailSearch extends ClientTest {
         URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@_xample.org", "UTF-8"), 0);
 
         String res = IOUtils.readURL(uc);
-        assertThat(res, containsString(SupportUserDetailsPage.PATH + id));
-        assertThat(res, containsString(SupportUserDetailsPage.PATH + id2));
+        assertThat(res, containsString(SupportUserDetailsPage.PATH + id + "/"));
+        assertThat(res, containsString(SupportUserDetailsPage.PATH + id2 + "/"));
     }
 
     @Test
@@ -94,7 +94,7 @@ public class TestSEAdminPageUserMailSearch extends ClientTest {
         createVerifiedEmail(testuser, mail2);
 
         URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode(mail2, "UTF-8"), 0);
-        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + id, uc.getHeaderField("Location"));
+        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + id + "/", uc.getHeaderField("Location"));
     }
 
     @Test
@@ -125,7 +125,7 @@ public class TestSEAdminPageUserMailSearch extends ClientTest {
         createVerifiedEmail(testuser, mail3);
 
         URLConnection uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@example3.org", "UTF-8"), 0);
-        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + id, uc.getHeaderField("Location"));
+        assertEquals("https://" + ServerConstants.getWwwHostNamePortSecure() + SupportUserDetailsPage.PATH + id + "/", uc.getHeaderField("Location"));
 
         uc = post(cookie, FindUserByEmailPage.PATH, "process&email=" + URLEncoder.encode("%@test3.org", "UTF-8"), 0);