/** * Returns whether the trust alias should be set and it is not (e.g. because the upgrade of an * instance with hosts already configured) */ public static boolean isTrustAliasMissing(ComputeState computeState) { URI hostUri = ContainerDescription.getDockerHostUri(computeState); return UriUtils.HTTPS_SCHEME.equalsIgnoreCase(hostUri.getScheme()) && (getTrustAlias(computeState) == null); }
@Test public void testGetTrustAlias() { final String alias = "alias"; ComputeService.ComputeState state = new ComputeService.ComputeState(); state.customProperties = new HashMap<>(); state.customProperties.put(ContainerHostService.SSL_TRUST_ALIAS_PROP_NAME, alias); String result = ContainerHostUtil.getTrustAlias(state); assertEquals(alias, result); // negative test state.customProperties = null; result = ContainerHostUtil.getTrustAlias(state); assertNull(result); }
private CommandInput prepareDirectHostOperationCommand(ComputeState hostComputeState, AuthCredentialsServiceState authCredentialsState) { URI dockerUri = ContainerDescription.getDockerHostUri(hostComputeState); CommandInput commandInput = new CommandInput().withDockerUri(dockerUri); if (authCredentialsState != null) { checkAuthCredentialsSupportedType(authCredentialsState, true); commandInput .withCredentials(authCredentialsState) .withProperty(SSL_TRUST_ALIAS_PROP_NAME, ContainerHostUtil.getTrustAlias(hostComputeState)); } return commandInput; }
.withCredentials(credentials) .withProperty(SSL_TRUST_ALIAS_PROP_NAME, ContainerHostUtil.getTrustAlias(hostComputeState));