### Question:
SystemPropertyRegistryAuthHandler implements RegistryAuthHandler { @Override public AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String username = registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.USERNAME); String password = registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.PASSWORD); if (username == null) { return null; } if (password == null) { throw new IllegalArgumentException("No password provided for username " + username); } log.debug("AuthConfig: credentials from system properties"); return new AuthConfig.Builder() .username(username) .password(password, decryptor) .email(registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.EMAIL)) .auth(registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.AUTH)) .build(); } SystemPropertyRegistryAuthHandler(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 testEmpty() throws Exception { String userHome = System.getProperty("user.home"); try { File tempDir = Files.createTempDirectory("d-m-p").toFile(); System.setProperty("user.home", tempDir.getAbsolutePath()); assertEquals(handler.create(RegistryAuthConfig.Kind.PUSH, null, "blubberbla:1611", s->s), null); } finally { System.setProperty("user.home", userHome); } }
@Test public void testSystemProperty() throws Exception { System.setProperty("docker.push.username", "roland"); System.setProperty("docker.push.password", "secret"); System.setProperty("docker.push.email", "roland@jolokia.org"); try { AuthConfig config = handler.create(RegistryAuthConfig.Kind.PUSH, null, null, s -> s); verifyAuthConfig(config,"roland","secret","roland@jolokia.org"); } finally { System.clearProperty("docker.push.username"); System.clearProperty("docker.push.password"); System.clearProperty("docker.push.email"); } }