### Question:
FromConfigRegistryAuthHandler implements RegistryAuthHandler { @Override public AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { if (registryAuthConfig.getUsername(kind) != null) { if (registryAuthConfig.getPassword(kind) == null) { throw new IllegalArgumentException("No 'password' given while using <authConfig> in configuration for mode " + kind); } log.debug("AuthConfig: credentials from plugin config"); return AuthConfig.fromRegistryAuthConfig(registryAuthConfig, kind, decryptor); } return null; } FromConfigRegistryAuthHandler(RegistryAuthConfig registryAuthConfig, KitLogger log); @Override String getId(); @Override AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor);  }### Answer:
@Test public void testFromPluginConfiguration() throws IOException { FromConfigRegistryAuthHandler handler = new FromConfigRegistryAuthHandler(setupAuthConfigFactoryWithConfigData(), log); AuthConfig config = handler.create(RegistryAuthConfig.Kind.PUSH, null, null, s -> s); verifyAuthConfig(config, "roland", "secret", "roland@jolokia.org"); }
@Test public void testFromPluginConfigurationPull() throws IOException { FromConfigRegistryAuthHandler handler = new FromConfigRegistryAuthHandler(setupAuthConfigFactoryWithConfigDataForKind(RegistryAuthConfig.Kind.PULL), log); AuthConfig config = handler.create(RegistryAuthConfig.Kind.PULL, null, null, s -> s); verifyAuthConfig(config, "roland", "secret", "roland@jolokia.org"); }
@Test public void testFromPluginConfigurationFailed() throws IOException { FromConfigRegistryAuthHandler handler = new FromConfigRegistryAuthHandler( new RegistryAuthConfig.Builder().addDefaultConfig(RegistryAuth.USERNAME, "admin").build(), log); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage(containsString("password")); handler.create(RegistryAuthConfig.Kind.PUSH, null, null, s -> s); }