use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters in project cloudbreak by hortonworks.
the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV2JumpgateIsEnabled.
@Test
void testFetchAndSaveCcmParametersWhenCcmV2JumpgateIsEnabled() {
Stack stack = getAStack();
stack.setTunnel(Tunnel.CCMV2_JUMPGATE);
DefaultCcmV2JumpgateParameters defaultCcmV2JumpgateParameters = mock(DefaultCcmV2JumpgateParameters.class);
FreeIpa freeIpa = mock(FreeIpa.class);
when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
when(freeIpa.getDomain()).thenReturn("cldr.work.site");
when(ccmV2JumpgateParameterSupplier.getCcmV2JumpgateParameters(anyString(), any(Optional.class), anyString(), anyString())).thenReturn(defaultCcmV2JumpgateParameters);
when(defaultCcmV2JumpgateParameters.getAgentCrn()).thenReturn("testAgentCrn");
when(hostDiscoveryService.determineGatewayFqdn(any(), any())).thenReturn("datahub.master0.cldr.work.site");
CcmConnectivityParameters ccmParameters = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.fetchAndSaveCcmParameters(stack));
assertEquals(CcmConnectivityMode.CCMV2_JUMPGATE, ccmParameters.getConnectivityMode(), "CCM V2 Jumpgate should be enabled.");
assertEquals(defaultCcmV2JumpgateParameters, ccmParameters.getCcmV2JumpgateParameters(), "CCM V2 Jumpgate Parameters should match.");
verify(ccmV2JumpgateParameterSupplier, times(1)).getCcmV2JumpgateParameters(anyString(), any(Optional.class), anyString(), anyString());
verifyNoInteractions(ccmParameterSupplier);
verify(stackService, times(1)).setCcmV2AgentCrnByStackId(100L, "testAgentCrn");
}
Aggregations