统一公开 API 为 /api/v1 前缀 #21
@@ -40,6 +40,18 @@ func TestReceiveSecurityEventUsesPreparedReceiverBeforeFirstActivation(t *testin
|
||||
}
|
||||
}
|
||||
|
||||
func TestReceiveSecurityEventReturnsNotFoundWithoutConfiguredReceiver(t *testing.T) {
|
||||
server := &Server{identityRuntime: identityruntime.NewManager(nil, &preparedReceiverBuilder{})}
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/security-events/ssf", nil)
|
||||
response := httptest.NewRecorder()
|
||||
|
||||
server.receiveSecurityEvent(response, request)
|
||||
|
||||
if response.Code != http.StatusNotFound {
|
||||
t.Fatalf("unconfigured SSF status=%d, want %d", response.Code, http.StatusNotFound)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSecurityEventWriteAuditFailsClosedBeforeMutation(t *testing.T) {
|
||||
server := &Server{}
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/admin/system/security-events/connection/verify", nil)
|
||||
|
||||
@@ -105,7 +105,10 @@ func (manager *Manager) SecurityEventReceiver() http.Handler {
|
||||
if runtime := manager.Current(); runtime != nil && runtime.SecurityEvents != nil {
|
||||
return runtime.SecurityEvents
|
||||
}
|
||||
return manager.SecurityEventManager()
|
||||
if securityEventManager := manager.SecurityEventManager(); securityEventManager != nil {
|
||||
return securityEventManager
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SecurityEventManager resolves the manager used by administrative recovery
|
||||
|
||||
@@ -630,6 +630,14 @@ func TestSecurityEventManagerExposesPreparedRecoveryManagerWithoutActiveRuntime(
|
||||
}
|
||||
}
|
||||
|
||||
func TestSecurityEventReceiverReturnsNilWithoutConfiguredManager(t *testing.T) {
|
||||
manager := NewManager(&runtimeRepositoryFake{}, &runtimeBuilderFake{})
|
||||
|
||||
if manager.SecurityEventReceiver() != nil {
|
||||
t.Fatal("unconfigured security event receiver should be nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSecurityEventManagerPrefersActiveRuntime(t *testing.T) {
|
||||
active := &securityevents.ConnectionManager{}
|
||||
prepared := &securityevents.ConnectionManager{}
|
||||
|
||||
Reference in New Issue
Block a user