use of org.springframework.beans.MutablePropertyValues in project spring-boot by spring-projects.
the class SecurityPropertiesTests method testBindingIgnoredMultiValued.
@Test
public void testBindingIgnoredMultiValued() {
this.binder.bind(new MutablePropertyValues(Collections.singletonMap("security.ignored", "/css/**,/images/**")));
assertThat(this.binder.getBindingResult().hasErrors()).isFalse();
assertThat(this.security.getIgnored()).hasSize(2);
}
use of org.springframework.beans.MutablePropertyValues in project spring-boot by spring-projects.
the class SecurityPropertiesTests method testBindingIgnoredDisable.
@Test
public void testBindingIgnoredDisable() {
this.binder.bind(new MutablePropertyValues(Collections.singletonMap("security.ignored", "none")));
assertThat(this.binder.getBindingResult().hasErrors()).isFalse();
assertThat(this.security.getIgnored()).hasSize(1);
}
use of org.springframework.beans.MutablePropertyValues in project spring-boot by spring-projects.
the class SecurityPropertiesTests method testDefaultPasswordAutogeneratedIfEmpty.
@Test
public void testDefaultPasswordAutogeneratedIfEmpty() {
this.binder.bind(new MutablePropertyValues(Collections.singletonMap("security.user.password", "")));
assertThat(this.binder.getBindingResult().hasErrors()).isFalse();
assertThat(this.security.getUser().isDefaultPassword()).isTrue();
}
use of org.springframework.beans.MutablePropertyValues in project spring-boot by spring-projects.
the class SecurityPropertiesTests method testRole.
@Test
public void testRole() {
this.binder.bind(new MutablePropertyValues(Collections.singletonMap("security.user.role", "ADMIN")));
assertThat(this.binder.getBindingResult().hasErrors()).isFalse();
assertThat(this.security.getUser().getRole().toString()).isEqualTo("[ADMIN]");
}
use of org.springframework.beans.MutablePropertyValues in project spring-boot by spring-projects.
the class RelaxedDataBinder method getPropertyValuesForNamePrefix.
private MutablePropertyValues getPropertyValuesForNamePrefix(MutablePropertyValues propertyValues) {
if (!StringUtils.hasText(this.namePrefix) && !this.ignoreNestedProperties) {
return propertyValues;
}
MutablePropertyValues rtn = new MutablePropertyValues();
for (PropertyValue value : propertyValues.getPropertyValues()) {
String name = value.getName();
for (String prefix : new RelaxedNames(stripLastDot(this.namePrefix))) {
for (String separator : new String[] { ".", "_" }) {
String candidate = (StringUtils.hasLength(prefix) ? prefix + separator : prefix);
if (name.startsWith(candidate)) {
name = name.substring(candidate.length());
if (!(this.ignoreNestedProperties && name.contains("."))) {
PropertyOrigin propertyOrigin = OriginCapablePropertyValue.getOrigin(value);
rtn.addPropertyValue(new OriginCapablePropertyValue(name, value.getValue(), propertyOrigin));
}
}
}
}
}
return rtn;
}
Aggregations