New domain options and properties for Debian Bookworm #1

Closed
hsh-timotheuspokorra wants to merge 41 commits from TP-202311-vhost-bookworm into rel_4.0
Showing only changes of commit 0941515461 - Show all commits

View File

@ -61,7 +61,7 @@ public class DomainTest {
} }
@Test @Test
public void testUpdate() { public void testUpdateWithoutPermissionFail() {
String user = "aaa00"; String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>(); Map<String, String> setParams = new HashMap<String, String>();
@ -99,6 +99,100 @@ public class DomainTest {
assertEquals(count + 1, getDomsCount()); assertEquals(count + 1, getDomsCount());
} }
@Test
public void testUpdateDomain() {
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
// first create the domain
Map<String, Object> setParams = new HashMap<String, Object>();
setParams.put("name", "exampleupdate.de");
setParams.put("user", "aaa00-admin");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams };
try {
Object execute = client.execute(MODULE + ".add", params);
assertTrue(execute instanceof Map<?, ?>);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
// check initial values
Map<String, String> whereParams = new HashMap<String, String>();
whereParams.put("name", "exampleupdate.de");
params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".search", params);
if (execute instanceof Object[]) {
Object[] result = (Object[]) execute;
assertTrue("expected 1 result, but got " + result.length, 1 == result.length);
for (Object o : result) {
if (o instanceof Map<?, ?>) {
Map<?, ?> row = (Map<?, ?>) o;
assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name")));
assertTrue("ValidSubdomainNames should be * but is " + row.get("validsubdomainnames"), "*".equals(row.get("validsubdomainnames")));
Object[] domainoptions = (Object[]) row.get("domainoptions");
String options = "";
for (Object option: domainoptions) {
options += option + " ";
}
String defaultDomainOptions = "htdocsfallback indexes dkim autoconfig greylisting includes letsencrypt multiviews ";
assertTrue("Domainoptions should be " + defaultDomainOptions + " but are " + options, defaultDomainOptions.equals(options));
}
else {
fail("Map<?, ?> expected");
}
}
}
else {
fail("Object[] expected");
}
} catch (XmlRpcException e) {
fail(e.getMessage());
}
// now update the domain
setParams = new HashMap<String, Object>();
whereParams = new HashMap<String, String>();
setParams.put("validsubdomainnames", "www2");
setParams.put("domainoptions", new String[] {"greylisting", "letsencrypt"});
whereParams.put("name", "exampleupdate.de");
params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams, whereParams };
try {
Object execute = client.execute(MODULE + ".update", params);
if (execute instanceof Object[]) {
Object[] result = (Object[]) execute;
assertTrue("expected 1 result, but got " + result.length, 1 == result.length);
for (Object o : result) {
if (o instanceof Map<?, ?>) {
Map<?, ?> row = (Map<?, ?>) o;
assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name")));
assertTrue("ValidSubdomainNames should be www2 but is " + row.get("validsubdomainnames"), "www2".equals(row.get("validsubdomainnames")));
Object[] domainoptions = (Object[]) row.get("domainoptions");
String options = "";
for (Object option: domainoptions) {
options += option + " ";
}
assertTrue("Domainoptions should be greylisting letsencrypt but are " + options, "greylisting letsencrypt ".equals(options));
}
else {
fail("Map<?, ?> expected");
}
}
}
else {
fail("Object[] expected");
}
} catch (XmlRpcException e) {
fail(e.getMessage());
}
}
@Test @Test
public void testCreateForeignSubdomain() throws UnknownHostException, IOException { public void testCreateForeignSubdomain() throws UnknownHostException, IOException {
int count = getDomsCount(); int count = getDomsCount();