@Test public void testBindingKey() { KeyAuthenticationProperties props = load(KeyAuthenticationProperties.class, "management.shell.auth.key.path=~/.ssh/test.pem"); Properties p = new Properties(); props.applyToCrshShellConfig(p); assertThat(p.get("crash.auth.key.path")).isEqualTo("~/.ssh/test.pem"); }
@Test public void testBindingKeyIgnored() { KeyAuthenticationProperties props = load(KeyAuthenticationProperties.class); Properties p = new Properties(); props.applyToCrshShellConfig(p); assertThat(p.get("crash.auth.key.path")).isNull(); }
@Test public void testBindingKey() { KeyAuthenticationProperties props = new KeyAuthenticationProperties(); RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell.auth.key"); binder.setConversionService(new DefaultConversionService()); Map<String, String> map = new HashMap<String, String>(); map.put("shell.auth.key.path", "~/.ssh/test.pem"); binder.bind(new MutablePropertyValues(map)); assertFalse(binder.getBindingResult().hasErrors()); Properties p = new Properties(); props.applyToCrshShellConfig(p); assertEquals("~/.ssh/test.pem", p.get("crash.auth.key.path")); }
@Test public void testBindingKeyIgnored() { KeyAuthenticationProperties props = new KeyAuthenticationProperties(); RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell.auth.key"); binder.setConversionService(new DefaultConversionService()); Map<String, String> map = new HashMap<String, String>(); binder.bind(new MutablePropertyValues(map)); assertFalse(binder.getBindingResult().hasErrors()); Properties p = new Properties(); props.applyToCrshShellConfig(p); assertNull(p.get("crash.auth.key.path")); }
@Bean @ConditionalOnProperty(prefix = AUTH_PREFIX, name = "type", havingValue = "key") @ConditionalOnMissingBean(CrshShellAuthenticationProperties.class) public KeyAuthenticationProperties keyAuthenticationProperties() { return new KeyAuthenticationProperties(); }
@Bean @ConditionalOnProperty(prefix = "shell", name = "auth", havingValue = "key") @ConditionalOnMissingBean(CrshShellAuthenticationProperties.class) public KeyAuthenticationProperties keyAuthenticationProperties() { return new KeyAuthenticationProperties(); }