@Test public void testOpenShiftConfigFromSystemPropsNegative() throws Exception { try { System.setProperty("docker.useOpenShiftAuth", "false"); executeWithTempHomeDir(homeDir -> { createOpenShiftConfig(homeDir, "openshift_simple_config.yaml"); AuthConfig config = handler.create(RegistryAuthConfig.Kind.PUSH, "roland", null, s->s); assertNull(config); }); } finally { System.getProperties().remove("docker.useOpenShiftAuth"); } }
@Override public AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String useOpenAuthMode = registryAuthConfig.extractFromProperties(props, kind, AUTH_USE_OPENSHIFT_AUTH); if (useOpenAuthMode != null) { boolean useOpenShift = Boolean.valueOf(useOpenAuthMode); if (!useOpenShift) { return null; } log.debug("AuthConfig: OpenShift credentials"); return validateMandatoryOpenShiftLogin(parseOpenShiftConfig()); } boolean useOpenShiftAuth = Optional.ofNullable(registryAuthConfig.getConfigForHandler(getId(), AUTH_USE_OPENSHIFT_AUTH)) .map(Boolean::parseBoolean) .orElse(false); if (useOpenShiftAuth) { log.debug("AuthConfig: OpenShift credentials"); return validateMandatoryOpenShiftLogin(parseOpenShiftConfig()); } return null; }
OpenShiftRegistryAuthHandler implements RegistryAuthHandler { @Override public AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String useOpenAuthMode = registryAuthConfig.extractFromProperties(props, kind, AUTH_USE_OPENSHIFT_AUTH); if (useOpenAuthMode != null) { boolean useOpenShift = Boolean.valueOf(useOpenAuthMode); if (!useOpenShift) { return null; } log.debug("AuthConfig: OpenShift credentials"); return validateMandatoryOpenShiftLogin(parseOpenShiftConfig()); } boolean useOpenShiftAuth = Optional.ofNullable(registryAuthConfig.getConfigForHandler(getId(), AUTH_USE_OPENSHIFT_AUTH)) .map(Boolean::parseBoolean) .orElse(false); if (useOpenShiftAuth) { log.debug("AuthConfig: OpenShift credentials"); return validateMandatoryOpenShiftLogin(parseOpenShiftConfig()); } return null; } }
OpenShiftRegistryAuthHandler implements RegistryAuthHandler { @Override public AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String useOpenAuthMode = registryAuthConfig.extractFromProperties(props, kind, AUTH_USE_OPENSHIFT_AUTH); if (useOpenAuthMode != null) { boolean useOpenShift = Boolean.valueOf(useOpenAuthMode); if (!useOpenShift) { return null; } log.debug("AuthConfig: OpenShift credentials"); return validateMandatoryOpenShiftLogin(parseOpenShiftConfig()); } boolean useOpenShiftAuth = Optional.ofNullable(registryAuthConfig.getConfigForHandler(getId(), AUTH_USE_OPENSHIFT_AUTH)) .map(Boolean::parseBoolean) .orElse(false); if (useOpenShiftAuth) { log.debug("AuthConfig: OpenShift credentials"); return validateMandatoryOpenShiftLogin(parseOpenShiftConfig()); } return null; } OpenShiftRegistryAuthHandler(RegistryAuthConfig registryAuthConfig, KitLogger log); }
OpenShiftRegistryAuthHandler implements RegistryAuthHandler { @Override public AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String useOpenAuthMode = registryAuthConfig.extractFromProperties(props, kind, AUTH_USE_OPENSHIFT_AUTH); if (useOpenAuthMode != null) { boolean useOpenShift = Boolean.valueOf(useOpenAuthMode); if (!useOpenShift) { return null; } log.debug("AuthConfig: OpenShift credentials"); return validateMandatoryOpenShiftLogin(parseOpenShiftConfig()); } boolean useOpenShiftAuth = Optional.ofNullable(registryAuthConfig.getConfigForHandler(getId(), AUTH_USE_OPENSHIFT_AUTH)) .map(Boolean::parseBoolean) .orElse(false); if (useOpenShiftAuth) { log.debug("AuthConfig: OpenShift credentials"); return validateMandatoryOpenShiftLogin(parseOpenShiftConfig()); } return null; } OpenShiftRegistryAuthHandler(RegistryAuthConfig registryAuthConfig, KitLogger log); @Override String getId(); @Override AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor); }
OpenShiftRegistryAuthHandler implements RegistryAuthHandler { @Override public AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String useOpenAuthMode = registryAuthConfig.extractFromProperties(props, kind, AUTH_USE_OPENSHIFT_AUTH); if (useOpenAuthMode != null) { boolean useOpenShift = Boolean.valueOf(useOpenAuthMode); if (!useOpenShift) { return null; } log.debug("AuthConfig: OpenShift credentials"); return validateMandatoryOpenShiftLogin(parseOpenShiftConfig()); } boolean useOpenShiftAuth = Optional.ofNullable(registryAuthConfig.getConfigForHandler(getId(), AUTH_USE_OPENSHIFT_AUTH)) .map(Boolean::parseBoolean) .orElse(false); if (useOpenShiftAuth) { log.debug("AuthConfig: OpenShift credentials"); return validateMandatoryOpenShiftLogin(parseOpenShiftConfig()); } return null; } OpenShiftRegistryAuthHandler(RegistryAuthConfig registryAuthConfig, KitLogger log); @Override String getId(); @Override AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor); static final String AUTH_USE_OPENSHIFT_AUTH; }