Skip to content

Commit

Permalink
checks for the state machine for ca and renewal policy (#18129)
Browse files Browse the repository at this point in the history
  • Loading branch information
janheise authored Feb 2, 2024
1 parent 22a6108 commit d924fb8
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@

import jakarta.inject.Inject;
import org.graylog.plugins.views.storage.migration.state.persistence.DatanodeMigrationConfiguration;
import org.graylog.security.certutil.CaService;
import org.graylog.security.certutil.ca.exceptions.KeyStoreStorageException;
import org.graylog2.plugin.certificates.RenewalPolicy;
import org.graylog2.plugin.cluster.ClusterConfigService;

public class MigrationActionsImpl implements MigrationActions {

private final ClusterConfigService clusterConfigService;
private final CaService caService;

@Inject
public MigrationActionsImpl(ClusterConfigService clusterConfigService) {
public MigrationActionsImpl(final ClusterConfigService clusterConfigService,
final CaService caService) {
this.clusterConfigService = clusterConfigService;
this.caService = caService;
}

@Override
Expand Down Expand Up @@ -86,19 +92,20 @@ public void startMessageProcessing() {

@Override
public boolean caDoesNotExist() {
// TODO: add real test
return true;
try {
return this.caService.get() == null;
} catch (KeyStoreStorageException e) {
return true;
}
}

@Override
public boolean removalPolicyDoesNotExist() {
// TODO: add real test
return true;
return this.clusterConfigService.get(RenewalPolicy.class) == null;
}

@Override
public boolean caAndRemovalPolicyExist() {
// TODO: add real test
return true;
return !caDoesNotExist() && !removalPolicyDoesNotExist();
}
}

0 comments on commit d924fb8

Please sign in to comment.