Skip to content
Snippets Groups Projects
Commit c04b5f10 authored by srosse's avatar srosse
Browse files

OO-1445: allow olat.(local.)properties settings for registration module

parent d0816e58
No related branches found
No related tags found
No related merge requests found
......@@ -99,6 +99,7 @@ public class RegistrationModule extends AbstractOLATModule {
}
public void setSelfRegistrationEnabled(boolean enable) {
selfRegistrationEnabled = enable;
String value = enable ? "true" : "false";
setStringProperty("registration.enabled", value, true);
}
......@@ -111,42 +112,45 @@ public class RegistrationModule extends AbstractOLATModule {
}
public void setStaticPropertyMappingEnabled(boolean enable) {
staticPropertyMappingEnabled = enable;
String value = enable ? "true" : "false";
setStringProperty("static.prop.mapping.enabled", value, true);
}
public String getStaticPropertyMappingName() {
return staticPropertyMappingName;
return staticPropertyMappingName;
}
public void setStaticPropertyMappingName(String value) {
value = StringHelper.containsNonWhitespace(value) ? value : "";
setStringProperty("static.prop.mapping", value, true);
staticPropertyMappingName = StringHelper.containsNonWhitespace(value) ? value : "";
setStringProperty("static.prop.mapping", staticPropertyMappingName, true);
}
public String getStaticPropertyMappingValue() {
return staticPropertyMappingValue;
return staticPropertyMappingValue;
}
public void setStaticPropertyMappingValue(String value) {
value = StringHelper.containsNonWhitespace(value) ? value : "";
setStringProperty("static.prop.mapping.value", value, true);
staticPropertyMappingValue = StringHelper.containsNonWhitespace(value) ? value : "";
setStringProperty("static.prop.mapping.value", staticPropertyMappingValue, true);
}
public boolean isSelfRegistrationLinkEnabled(){
return selfRegistrationLinkEnabled;
return selfRegistrationLinkEnabled;
}
public void setSelfRegistrationLinkEnabled(boolean enable) {
selfRegistrationLinkEnabled = enable;
String value = enable ? "true" : "false";
setStringProperty("registration.link.enabled", value, true);
}
public boolean isSelfRegistrationLoginEnabled(){
return selfRegistrationLoginEnabled;
return selfRegistrationLoginEnabled;
}
public void setSelfRegistrationLoginEnabled(boolean enable) {
selfRegistrationLoginEnabled = enable;
String value = enable ? "true" : "false";
setStringProperty("registration.login.enabled", value, true);
}
......@@ -156,7 +160,8 @@ public class RegistrationModule extends AbstractOLATModule {
}
public void setDomainListRaw(String list) {
setStringProperty("registration.domains", normalizeDomainList(list), true);
domainList = normalizeDomainList(list);
setStringProperty("registration.domains", domainList, true);
}
private String normalizeDomainList(String list) {
......@@ -210,35 +215,43 @@ public class RegistrationModule extends AbstractOLATModule {
public void init() {
//registration enabled/disabled
String enabledObj = getStringPropertyValue("registration.enabled", true);
selfRegistrationEnabled = "true".equals(enabledObj);
if(StringHelper.containsNonWhitespace(enabledObj)) {
selfRegistrationEnabled = "true".equals(enabledObj);
}
//link registration enabled/disabled (rest)
String linkEnabledObj = getStringPropertyValue("registration.link.enabled", true);
selfRegistrationLinkEnabled = "true".equals(linkEnabledObj);
if(StringHelper.containsNonWhitespace(linkEnabledObj)) {
selfRegistrationLinkEnabled = "true".equals(linkEnabledObj);
}
//link on the login page for registration enabled/disabled
String loginEnabledObj = getStringPropertyValue("registration.login.enabled", true);
selfRegistrationLoginEnabled = "true".equals(loginEnabledObj);
if(StringHelper.containsNonWhitespace(loginEnabledObj)) {
selfRegistrationLoginEnabled = "true".equals(loginEnabledObj);
}
//white list of domains
String domainObj = getStringPropertyValue("registration.domains", true);
if(StringHelper.containsNonWhitespace(domainObj)) {
domainList = domainObj;
} else {
} else {// allowed because to olat.properties for this
domainList = null; // reset
}
//static property mapping enabled/disabled
String enabledPropObj = getStringPropertyValue("static.prop.mapping.enabled", true);
staticPropertyMappingEnabled = "true".equals(enabledPropObj);
if(StringHelper.containsNonWhitespace(enabledPropObj)) {
staticPropertyMappingEnabled = "true".equals(enabledPropObj);
}
String propKeyObj = getStringPropertyValue("static.prop.mapping", true);
String propKeyObj = getStringPropertyValue("static.prop.mapping", false);
if(StringHelper.containsNonWhitespace(propKeyObj)) {
staticPropertyMappingName = propKeyObj;
} else {
staticPropertyMappingName = null; // reset
}
String propValueObj = getStringPropertyValue("static.prop.mapping.value", true);
String propValueObj = getStringPropertyValue("static.prop.mapping.value", false);
if(StringHelper.containsNonWhitespace(propValueObj)) {
staticPropertyMappingValue = propValueObj;
} else {
......
......@@ -32,11 +32,9 @@ import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.util.EntityUtils;
import org.junit.Before;
import org.junit.Test;
import org.olat.core.id.Identity;
import org.olat.core.id.UserConstants;
import org.olat.restapi.RestConnection;
import org.olat.test.JunitTestHelper;
import org.olat.test.OlatJerseyTestCase;
......@@ -51,17 +49,6 @@ import org.olat.test.OlatJerseyTestCase;
*/
public class RegistrationTest extends OlatJerseyTestCase {
private static Identity owner1;
@Before
@Override
public void setUp() throws Exception {
super.setUp();
//create a course with learn group
owner1 = JunitTestHelper.createAndPersistIdentityAsUser("rest-one");
}
@Test
public void testRegistration() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
......@@ -79,10 +66,12 @@ public class RegistrationTest extends OlatJerseyTestCase {
@Test
public void testRedirectRegistration() throws IOException, URISyntaxException {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("rest-reg");
RestConnection conn = new RestConnection();
URI uri = conn.getContextURI().path("registration")
.queryParam("email", owner1.getUser().getProperty(UserConstants.EMAIL, null)).build();
.queryParam("email", id.getUser().getProperty(UserConstants.EMAIL, null)).build();
HttpPut put = conn.createPut(uri, "*/*", "de", true);
HttpResponse response = conn.execute(put);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment