Files
ai-security-xdr/haobang-security-dm/syslog-consumer/src/test/java/com/common/service/FactWriteOwnershipGuardTest.java
T

27 lines
1.0 KiB
Java
Raw Normal View History

package com.common.service;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
class FactWriteOwnershipGuardTest {
@Test
void legacyModeKeepsRollbackWritePathAvailable() {
FactWriteOwnershipGuard guard = new FactWriteOwnershipGuard("LEGACY_CHANGE_LOG");
assertDoesNotThrow(() -> guard.assertLocalFactWriteAllowed("test"));
}
@Test
void directModesRejectWritesThatWouldBypassRuleTransaction() {
assertThrows(IllegalStateException.class,
() -> new FactWriteOwnershipGuard("DIRECT").assertLocalFactWriteAllowed("test"));
assertThrows(IllegalStateException.class,
() -> new FactWriteOwnershipGuard("DIRECT_SHADOW").assertLocalFactWriteAllowed("test"));
assertThrows(IllegalStateException.class,
() -> new FactWriteOwnershipGuard("FACT_ONLY_REBUILD_REQUIRED")
.assertLocalFactWriteAllowed("test"));
}
}