@Test public void shouldNotUpdateKeytabs() throws Exception { KeytabConfigurationRequest keytabConfigurationRequest = new KeytabConfigurationRequest(STACK_ID); Stack stack = mock(Stack.class); when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenReturn(stack); victim.accept(new Event<>(keytabConfigurationRequest)); verifyNoMoreInteractions(hostOrchestrator); verify(eventBus).notify(anyString(), any(Event.class)); }
@Override public void accept(Event<KeytabConfigurationRequest> keytabConfigurationRequestEvent) { Long stackId = keytabConfigurationRequestEvent.getData().getResourceId(); Selectable response; try { Stack stack = stackService.getByIdWithListsInTransaction(stackId); Optional<KerberosConfig> kerberosConfigOptional = kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName()); boolean childEnvironment = environmentConfigProvider.isChildEnvironment(stack.getEnvironmentCrn()); if (kerberosDetailService.keytabsShouldBeUpdated(stack.cloudPlatform(), childEnvironment, kerberosConfigOptional)) { GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack); ServiceKeytabResponse serviceKeytabResponse = keytabProvider.getServiceKeytabResponse(stack, primaryGatewayConfig); KeytabModel keytabModel = buildKeytabModel(serviceKeytabResponse); hostOrchestrator.uploadKeytabs(List.of(primaryGatewayConfig), Set.of(keytabModel), ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(stackId, stack.getCluster().getId())); } response = new KeytabConfigurationSuccess(stackId); } catch (Exception e) { LOGGER.info("Error during keytab configuration, stackId: " + stackId, e); KeytabConfigurationException configurationException = new KeytabConfigurationException("Keytab generation failed with: " + e.getMessage(), e); response = new KeytabConfigurationFailed(stackId, configurationException); } eventBus.notify(response.selector(), new Event<>(keytabConfigurationRequestEvent.getHeaders(), response)); }
KeytabConfigurationHandler implements EventHandler<KeytabConfigurationRequest> { @Override public void accept(Event<KeytabConfigurationRequest> keytabConfigurationRequestEvent) { Long stackId = keytabConfigurationRequestEvent.getData().getResourceId(); Selectable response; try { Stack stack = stackService.getByIdWithListsInTransaction(stackId); Optional<KerberosConfig> kerberosConfigOptional = kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName()); boolean childEnvironment = environmentConfigProvider.isChildEnvironment(stack.getEnvironmentCrn()); if (kerberosDetailService.keytabsShouldBeUpdated(stack.cloudPlatform(), childEnvironment, kerberosConfigOptional)) { GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack); ServiceKeytabResponse serviceKeytabResponse = keytabProvider.getServiceKeytabResponse(stack, primaryGatewayConfig); KeytabModel keytabModel = buildKeytabModel(serviceKeytabResponse); hostOrchestrator.uploadKeytabs(List.of(primaryGatewayConfig), Set.of(keytabModel), ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(stackId, stack.getCluster().getId())); } response = new KeytabConfigurationSuccess(stackId); } catch (Exception e) { LOGGER.info("Error during keytab configuration, stackId: " + stackId, e); KeytabConfigurationException configurationException = new KeytabConfigurationException("Keytab generation failed with: " + e.getMessage(), e); response = new KeytabConfigurationFailed(stackId, configurationException); } eventBus.notify(response.selector(), new Event<>(keytabConfigurationRequestEvent.getHeaders(), response)); } }
KeytabConfigurationHandler implements EventHandler<KeytabConfigurationRequest> { @Override public void accept(Event<KeytabConfigurationRequest> keytabConfigurationRequestEvent) { Long stackId = keytabConfigurationRequestEvent.getData().getResourceId(); Selectable response; try { Stack stack = stackService.getByIdWithListsInTransaction(stackId); Optional<KerberosConfig> kerberosConfigOptional = kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName()); boolean childEnvironment = environmentConfigProvider.isChildEnvironment(stack.getEnvironmentCrn()); if (kerberosDetailService.keytabsShouldBeUpdated(stack.cloudPlatform(), childEnvironment, kerberosConfigOptional)) { GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack); ServiceKeytabResponse serviceKeytabResponse = keytabProvider.getServiceKeytabResponse(stack, primaryGatewayConfig); KeytabModel keytabModel = buildKeytabModel(serviceKeytabResponse); hostOrchestrator.uploadKeytabs(List.of(primaryGatewayConfig), Set.of(keytabModel), ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(stackId, stack.getCluster().getId())); } response = new KeytabConfigurationSuccess(stackId); } catch (Exception e) { LOGGER.info("Error during keytab configuration, stackId: " + stackId, e); KeytabConfigurationException configurationException = new KeytabConfigurationException("Keytab generation failed with: " + e.getMessage(), e); response = new KeytabConfigurationFailed(stackId, configurationException); } eventBus.notify(response.selector(), new Event<>(keytabConfigurationRequestEvent.getHeaders(), response)); }  }
KeytabConfigurationHandler implements EventHandler<KeytabConfigurationRequest> { @Override public void accept(Event<KeytabConfigurationRequest> keytabConfigurationRequestEvent) { Long stackId = keytabConfigurationRequestEvent.getData().getResourceId(); Selectable response; try { Stack stack = stackService.getByIdWithListsInTransaction(stackId); Optional<KerberosConfig> kerberosConfigOptional = kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName()); boolean childEnvironment = environmentConfigProvider.isChildEnvironment(stack.getEnvironmentCrn()); if (kerberosDetailService.keytabsShouldBeUpdated(stack.cloudPlatform(), childEnvironment, kerberosConfigOptional)) { GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack); ServiceKeytabResponse serviceKeytabResponse = keytabProvider.getServiceKeytabResponse(stack, primaryGatewayConfig); KeytabModel keytabModel = buildKeytabModel(serviceKeytabResponse); hostOrchestrator.uploadKeytabs(List.of(primaryGatewayConfig), Set.of(keytabModel), ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(stackId, stack.getCluster().getId())); } response = new KeytabConfigurationSuccess(stackId); } catch (Exception e) { LOGGER.info("Error during keytab configuration, stackId: " + stackId, e); KeytabConfigurationException configurationException = new KeytabConfigurationException("Keytab generation failed with: " + e.getMessage(), e); response = new KeytabConfigurationFailed(stackId, configurationException); } eventBus.notify(response.selector(), new Event<>(keytabConfigurationRequestEvent.getHeaders(), response)); }  @Override String selector(); @Override void accept(Event<KeytabConfigurationRequest> keytabConfigurationRequestEvent); }
KeytabConfigurationHandler implements EventHandler<KeytabConfigurationRequest> { @Override public void accept(Event<KeytabConfigurationRequest> keytabConfigurationRequestEvent) { Long stackId = keytabConfigurationRequestEvent.getData().getResourceId(); Selectable response; try { Stack stack = stackService.getByIdWithListsInTransaction(stackId); Optional<KerberosConfig> kerberosConfigOptional = kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName()); boolean childEnvironment = environmentConfigProvider.isChildEnvironment(stack.getEnvironmentCrn()); if (kerberosDetailService.keytabsShouldBeUpdated(stack.cloudPlatform(), childEnvironment, kerberosConfigOptional)) { GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack); ServiceKeytabResponse serviceKeytabResponse = keytabProvider.getServiceKeytabResponse(stack, primaryGatewayConfig); KeytabModel keytabModel = buildKeytabModel(serviceKeytabResponse); hostOrchestrator.uploadKeytabs(List.of(primaryGatewayConfig), Set.of(keytabModel), ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(stackId, stack.getCluster().getId())); } response = new KeytabConfigurationSuccess(stackId); } catch (Exception e) { LOGGER.info("Error during keytab configuration, stackId: " + stackId, e); KeytabConfigurationException configurationException = new KeytabConfigurationException("Keytab generation failed with: " + e.getMessage(), e); response = new KeytabConfigurationFailed(stackId, configurationException); } eventBus.notify(response.selector(), new Event<>(keytabConfigurationRequestEvent.getHeaders(), response)); }  @Override String selector(); @Override void accept(Event<KeytabConfigurationRequest> keytabConfigurationRequestEvent);  }