@Test public void testCreateMachineUserAndGenerateKeys() { Optional<AltusCredential> altusCredential = Optional.of(new AltusCredential("accessKey", "secretKey".toCharArray())); when(altusIAMService.generateMachineUserWithAccessKey(any(), any(), any(), anyBoolean())).thenReturn(altusCredential); underTest.generateDatabusMachineUserForFluent(stack, telemetry); assertEquals("secretKey", new String(altusCredential.get().getPrivateKey())); verify(altusIAMService, times(1)).generateMachineUserWithAccessKey(any(), any(), any(), anyBoolean()); }
public Optional<AltusCredential> generateDatabusMachineUserForFluent(Stack stack, Telemetry telemetry) { if (isMeteringOrAnyDataBusBasedFeatureSupported(stack, telemetry)) { return ThreadBasedUserCrnProvider.doAsInternalActor(() -> altusIAMService.generateMachineUserWithAccessKey( getFluentDatabusMachineUserName(stack), ThreadBasedUserCrnProvider.getUserCrn(), Crn.fromString(stack.getResourceCrn()).getAccountId(), telemetry.isUseSharedAltusCredentialEnabled())); } return Optional.empty(); }
AltusMachineUserService { public Optional<AltusCredential> generateDatabusMachineUserForFluent(Stack stack, Telemetry telemetry) { if (isMeteringOrAnyDataBusBasedFeatureSupported(stack, telemetry)) { return ThreadBasedUserCrnProvider.doAsInternalActor(() -> altusIAMService.generateMachineUserWithAccessKey( getFluentDatabusMachineUserName(stack), ThreadBasedUserCrnProvider.getUserCrn(), Crn.fromString(stack.getResourceCrn()).getAccountId(), telemetry.isUseSharedAltusCredentialEnabled())); } return Optional.empty(); } }
AltusMachineUserService { public Optional<AltusCredential> generateDatabusMachineUserForFluent(Stack stack, Telemetry telemetry) { if (isMeteringOrAnyDataBusBasedFeatureSupported(stack, telemetry)) { return ThreadBasedUserCrnProvider.doAsInternalActor(() -> altusIAMService.generateMachineUserWithAccessKey( getFluentDatabusMachineUserName(stack), ThreadBasedUserCrnProvider.getUserCrn(), Crn.fromString(stack.getResourceCrn()).getAccountId(), telemetry.isUseSharedAltusCredentialEnabled())); } return Optional.empty(); } AltusMachineUserService(AltusIAMService altusIAMService, ClusterService clusterService); }
AltusMachineUserService { public Optional<AltusCredential> generateDatabusMachineUserForFluent(Stack stack, Telemetry telemetry) { if (isMeteringOrAnyDataBusBasedFeatureSupported(stack, telemetry)) { return ThreadBasedUserCrnProvider.doAsInternalActor(() -> altusIAMService.generateMachineUserWithAccessKey( getFluentDatabusMachineUserName(stack), ThreadBasedUserCrnProvider.getUserCrn(), Crn.fromString(stack.getResourceCrn()).getAccountId(), telemetry.isUseSharedAltusCredentialEnabled())); } return Optional.empty(); } AltusMachineUserService(AltusIAMService altusIAMService, ClusterService clusterService); Optional<AltusCredential> generateDatabusMachineUserForFluent(Stack stack, Telemetry telemetry); void clearFluentMachineUser(Stack stack, Telemetry telemetry); DataBusCredential storeDataBusCredential(Optional<AltusCredential> altusCredential, Stack stack); boolean isDataBusCredentialStillExist(Telemetry telemetry, DataBusCredential dataBusCredential, Stack stack); boolean isMeteringOrAnyDataBusBasedFeatureSupported(Stack stack, Telemetry telemetry); }
AltusMachineUserService { public Optional<AltusCredential> generateDatabusMachineUserForFluent(Stack stack, Telemetry telemetry) { if (isMeteringOrAnyDataBusBasedFeatureSupported(stack, telemetry)) { return ThreadBasedUserCrnProvider.doAsInternalActor(() -> altusIAMService.generateMachineUserWithAccessKey( getFluentDatabusMachineUserName(stack), ThreadBasedUserCrnProvider.getUserCrn(), Crn.fromString(stack.getResourceCrn()).getAccountId(), telemetry.isUseSharedAltusCredentialEnabled())); } return Optional.empty(); } AltusMachineUserService(AltusIAMService altusIAMService, ClusterService clusterService); Optional<AltusCredential> generateDatabusMachineUserForFluent(Stack stack, Telemetry telemetry); void clearFluentMachineUser(Stack stack, Telemetry telemetry); DataBusCredential storeDataBusCredential(Optional<AltusCredential> altusCredential, Stack stack); boolean isDataBusCredentialStillExist(Telemetry telemetry, DataBusCredential dataBusCredential, Stack stack); boolean isMeteringOrAnyDataBusBasedFeatureSupported(Stack stack, Telemetry telemetry);  }