feat: 模型 group 落定为 audit.guichumo.com

- AuditLog.GROUP 常量替换占位(查询端点/测试挂载路径均引用该常量)
- role-template.yaml apiGroups、UI QUERY_ENDPOINT 同步
- README 改为"模型 group 与权限标识"说明,并标注 group 为已落库数据身份、
  启用产生记录后不可随意变更
- 技术方案注明占位示例与落定值(文档中其余 audit.example.com 保留为设计示例)
- ./gradlew test --rerun-tasks 50 例全绿,插件与 UI 构建通过
This commit is contained in:
2026-11-21 17:28:36 +08:00
parent a488360d46
commit 67d9745cd1
7 changed files with 24 additions and 23 deletions
@@ -57,7 +57,7 @@ class OperationAuditPluginTest {
var schemeManager = mock(SchemeManager.class);
var cleaner = mock(RetentionCleaner.class);
var scheme = mock(Scheme.class);
var gvk = new GroupVersionKind("audit.example.com", "v1alpha1", "AuditLog");
var gvk = new GroupVersionKind("audit.guichumo.com", "v1alpha1", "AuditLog");
org.mockito.Mockito.when(schemeManager.fetch(gvk))
.thenReturn(java.util.Optional.of(scheme));
@@ -44,7 +44,7 @@ class AuditQueryEndpointTest {
@Test
void shouldQueryWithDefaults() {
webClient.get()
.uri("/apis/audit.example.com/v1alpha1/auditlogs/-/query")
.uri("/apis/audit.guichumo.com/v1alpha1/auditlogs/-/query")
.exchange()
.expectStatus().isOk();
@@ -61,7 +61,7 @@ class AuditQueryEndpointTest {
@Test
void shouldApplyEqualityFieldSelectors() {
webClient.get()
.uri("/apis/audit.example.com/v1alpha1/auditlogs/-/query"
.uri("/apis/audit.guichumo.com/v1alpha1/auditlogs/-/query"
+ "?fieldSelector=spec.username=admin"
+ "&fieldSelector=spec.method=POST"
+ "&fieldSelector=spec.statusCode=500")
@@ -83,7 +83,7 @@ class AuditQueryEndpointTest {
@Test
void shouldApplyResultFilter() {
webClient.get()
.uri("/apis/audit.example.com/v1alpha1/auditlogs/-/query?result=failure")
.uri("/apis/audit.guichumo.com/v1alpha1/auditlogs/-/query?result=failure")
.exchange()
.expectStatus().isOk();
@@ -99,7 +99,7 @@ class AuditQueryEndpointTest {
@Test
void shouldRejectInvalidResultFilter() {
webClient.get()
.uri("/apis/audit.example.com/v1alpha1/auditlogs/-/query?result=unknown")
.uri("/apis/audit.guichumo.com/v1alpha1/auditlogs/-/query?result=unknown")
.exchange()
.expectStatus().isBadRequest();
}
@@ -109,7 +109,7 @@ class AuditQueryEndpointTest {
var start = Instant.parse("2026-11-01T00:00:00Z");
var end = Instant.parse("2026-11-21T00:00:00Z");
webClient.get()
.uri("/apis/audit.example.com/v1alpha1/auditlogs/-/query"
.uri("/apis/audit.guichumo.com/v1alpha1/auditlogs/-/query"
+ "?keyword=hello&startTime=" + start + "&endTime=" + end)
.exchange()
.expectStatus().isOk();
@@ -130,7 +130,7 @@ class AuditQueryEndpointTest {
@Test
void shouldRejectNonWhitelistedFieldSelector() {
webClient.get()
.uri("/apis/audit.example.com/v1alpha1/auditlogs/-/query"
.uri("/apis/audit.guichumo.com/v1alpha1/auditlogs/-/query"
+ "?fieldSelector=spec.userAgent=evil")
.exchange()
.expectStatus().isBadRequest();
@@ -139,7 +139,7 @@ class AuditQueryEndpointTest {
@Test
void shouldRejectInvalidTimeFormat() {
webClient.get()
.uri("/apis/audit.example.com/v1alpha1/auditlogs/-/query?startTime=not-a-time")
.uri("/apis/audit.guichumo.com/v1alpha1/auditlogs/-/query?startTime=not-a-time")
.exchange()
.expectStatus().isBadRequest();
}
@@ -147,7 +147,7 @@ class AuditQueryEndpointTest {
@Test
void shouldRejectInvalidFieldSelectorTerm() {
webClient.get()
.uri("/apis/audit.example.com/v1alpha1/auditlogs/-/query?fieldSelector=noequals")
.uri("/apis/audit.guichumo.com/v1alpha1/auditlogs/-/query?fieldSelector=noequals")
.exchange()
.expectStatus().isBadRequest();
}
@@ -155,7 +155,7 @@ class AuditQueryEndpointTest {
@Test
void shouldClampPageSizeAndForceTimeSort() {
webClient.get()
.uri("/apis/audit.example.com/v1alpha1/auditlogs/-/query"
.uri("/apis/audit.guichumo.com/v1alpha1/auditlogs/-/query"
+ "?page=3&size=500&sort=spec.username,asc")
.exchange()
.expectStatus().isOk();
@@ -173,7 +173,7 @@ class AuditQueryEndpointTest {
@Test
void shouldSupportAscendingTimeSort() {
webClient.get()
.uri("/apis/audit.example.com/v1alpha1/auditlogs/-/query"
.uri("/apis/audit.guichumo.com/v1alpha1/auditlogs/-/query"
+ "?sort=metadata.creationTimestamp,asc")
.exchange()
.expectStatus().isOk();