|
|
|
@ -56,8 +56,8 @@ public class ShellPropertiesTests { |
|
|
|
public void testBindingAuth() { |
|
|
|
public void testBindingAuth() { |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
binder.bind(new MutablePropertyValues(Collections.singletonMap("shell.auth", |
|
|
|
binder.bind(new MutablePropertyValues( |
|
|
|
"spring"))); |
|
|
|
Collections.singletonMap("shell.auth", "spring"))); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertEquals("spring", props.getAuth()); |
|
|
|
assertEquals("spring", props.getAuth()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -66,7 +66,8 @@ public class ShellPropertiesTests { |
|
|
|
public void testBindingAuthIfEmpty() { |
|
|
|
public void testBindingAuthIfEmpty() { |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
binder.bind(new MutablePropertyValues(Collections.singletonMap("shell.auth", ""))); |
|
|
|
binder.bind( |
|
|
|
|
|
|
|
new MutablePropertyValues(Collections.singletonMap("shell.auth", ""))); |
|
|
|
assertTrue(binder.getBindingResult().hasErrors()); |
|
|
|
assertTrue(binder.getBindingResult().hasErrors()); |
|
|
|
assertEquals("simple", props.getAuth()); |
|
|
|
assertEquals("simple", props.getAuth()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -76,8 +77,8 @@ public class ShellPropertiesTests { |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
binder.setConversionService(new DefaultConversionService()); |
|
|
|
binder.setConversionService(new DefaultConversionService()); |
|
|
|
binder.bind(new MutablePropertyValues(Collections.singletonMap( |
|
|
|
binder.bind(new MutablePropertyValues( |
|
|
|
"shell.command_refresh_interval", "1"))); |
|
|
|
Collections.singletonMap("shell.command_refresh_interval", "1"))); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertEquals(1, props.getCommandRefreshInterval()); |
|
|
|
assertEquals(1, props.getCommandRefreshInterval()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -87,8 +88,8 @@ public class ShellPropertiesTests { |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
binder.setConversionService(new DefaultConversionService()); |
|
|
|
binder.setConversionService(new DefaultConversionService()); |
|
|
|
binder.bind(new MutablePropertyValues(Collections.singletonMap( |
|
|
|
binder.bind(new MutablePropertyValues(Collections |
|
|
|
"shell.command_path_patterns", "pattern1, pattern2"))); |
|
|
|
.singletonMap("shell.command_path_patterns", "pattern1, pattern2"))); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertEquals(2, props.getCommandPathPatterns().length); |
|
|
|
assertEquals(2, props.getCommandPathPatterns().length); |
|
|
|
Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" }, |
|
|
|
Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" }, |
|
|
|
@ -100,8 +101,8 @@ public class ShellPropertiesTests { |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
binder.setConversionService(new DefaultConversionService()); |
|
|
|
binder.setConversionService(new DefaultConversionService()); |
|
|
|
binder.bind(new MutablePropertyValues(Collections.singletonMap( |
|
|
|
binder.bind(new MutablePropertyValues(Collections |
|
|
|
"shell.config_path_patterns", "pattern1, pattern2"))); |
|
|
|
.singletonMap("shell.config_path_patterns", "pattern1, pattern2"))); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertEquals(2, props.getConfigPathPatterns().length); |
|
|
|
assertEquals(2, props.getConfigPathPatterns().length); |
|
|
|
Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" }, |
|
|
|
Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" }, |
|
|
|
@ -113,8 +114,8 @@ public class ShellPropertiesTests { |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
binder.setConversionService(new DefaultConversionService()); |
|
|
|
binder.setConversionService(new DefaultConversionService()); |
|
|
|
binder.bind(new MutablePropertyValues(Collections.singletonMap( |
|
|
|
binder.bind(new MutablePropertyValues(Collections |
|
|
|
"shell.disabled_plugins", "pattern1, pattern2"))); |
|
|
|
.singletonMap("shell.disabled_plugins", "pattern1, pattern2"))); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertEquals(2, props.getDisabledPlugins().length); |
|
|
|
assertEquals(2, props.getDisabledPlugins().length); |
|
|
|
assertArrayEquals(new String[] { "pattern1", "pattern2" }, |
|
|
|
assertArrayEquals(new String[] { "pattern1", "pattern2" }, |
|
|
|
@ -126,8 +127,8 @@ public class ShellPropertiesTests { |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
ShellProperties props = new ShellProperties(); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell"); |
|
|
|
binder.setConversionService(new DefaultConversionService()); |
|
|
|
binder.setConversionService(new DefaultConversionService()); |
|
|
|
binder.bind(new MutablePropertyValues(Collections.singletonMap( |
|
|
|
binder.bind(new MutablePropertyValues(Collections |
|
|
|
"shell.disabled_commands", "pattern1, pattern2"))); |
|
|
|
.singletonMap("shell.disabled_commands", "pattern1, pattern2"))); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertEquals(2, props.getDisabledCommands().length); |
|
|
|
assertEquals(2, props.getDisabledCommands().length); |
|
|
|
assertArrayEquals(new String[] { "pattern1", "pattern2" }, |
|
|
|
assertArrayEquals(new String[] { "pattern1", "pattern2" }, |
|
|
|
@ -271,8 +272,8 @@ public class ShellPropertiesTests { |
|
|
|
public void testDefaultPasswordAutogeneratedIfUnresolovedPlaceholder() { |
|
|
|
public void testDefaultPasswordAutogeneratedIfUnresolovedPlaceholder() { |
|
|
|
SimpleAuthenticationProperties security = new SimpleAuthenticationProperties(); |
|
|
|
SimpleAuthenticationProperties security = new SimpleAuthenticationProperties(); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(security, "security"); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(security, "security"); |
|
|
|
binder.bind(new MutablePropertyValues(Collections.singletonMap( |
|
|
|
binder.bind(new MutablePropertyValues(Collections |
|
|
|
"shell.auth.simple.user.password", "${ADMIN_PASSWORD}"))); |
|
|
|
.singletonMap("shell.auth.simple.user.password", "${ADMIN_PASSWORD}"))); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertTrue(security.getUser().isDefaultPassword()); |
|
|
|
assertTrue(security.getUser().isDefaultPassword()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -281,8 +282,8 @@ public class ShellPropertiesTests { |
|
|
|
public void testDefaultPasswordAutogeneratedIfEmpty() { |
|
|
|
public void testDefaultPasswordAutogeneratedIfEmpty() { |
|
|
|
SimpleAuthenticationProperties security = new SimpleAuthenticationProperties(); |
|
|
|
SimpleAuthenticationProperties security = new SimpleAuthenticationProperties(); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(security, "security"); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(security, "security"); |
|
|
|
binder.bind(new MutablePropertyValues(Collections.singletonMap( |
|
|
|
binder.bind(new MutablePropertyValues( |
|
|
|
"shell.auth.simple.user.password", ""))); |
|
|
|
Collections.singletonMap("shell.auth.simple.user.password", ""))); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertTrue(security.getUser().isDefaultPassword()); |
|
|
|
assertTrue(security.getUser().isDefaultPassword()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -291,8 +292,8 @@ public class ShellPropertiesTests { |
|
|
|
public void testBindingSpring() { |
|
|
|
public void testBindingSpring() { |
|
|
|
SpringAuthenticationProperties props = new SpringAuthenticationProperties(); |
|
|
|
SpringAuthenticationProperties props = new SpringAuthenticationProperties(); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell.auth.spring"); |
|
|
|
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell.auth.spring"); |
|
|
|
binder.bind(new MutablePropertyValues(Collections.singletonMap( |
|
|
|
binder.bind(new MutablePropertyValues( |
|
|
|
"shell.auth.spring.roles", "role1, role2"))); |
|
|
|
Collections.singletonMap("shell.auth.spring.roles", "role1, role2"))); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
assertFalse(binder.getBindingResult().hasErrors()); |
|
|
|
|
|
|
|
|
|
|
|
Properties p = new Properties(); |
|
|
|
Properties p = new Properties(); |
|
|
|
|