tested real proxmox connection

--> passed
This commit is contained in:
Philipp
2026-06-12 14:25:34 +02:00
parent 1bfc46f03b
commit 452d1fb8b3
9 changed files with 271 additions and 42 deletions
+26 -1
View File
@@ -50,6 +50,31 @@ func TestListTenantAuditReturnsEntries(t *testing.T) {
}
}
func TestListTenantAuditReturnsEmptyArray(t *testing.T) {
handler := NewHandler(&stubRepository{})
req := requestWithPrincipalAndMembership(http.MethodGet, "/tenants/tenant-1/audit", "tenant-1", "owner")
req.SetPathValue("tenantID", "tenant-1")
rec := httptest.NewRecorder()
handler.ListTenantAudit(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("status = %d, want %d", rec.Code, http.StatusOK)
}
var response struct {
Data []Entry `json:"data"`
}
if err := json.Unmarshal(rec.Body.Bytes(), &response); err != nil {
t.Fatalf("unmarshal response: %v", err)
}
if response.Data == nil {
t.Fatalf("data = nil, want empty array")
}
if len(response.Data) != 0 {
t.Fatalf("len(data) = %d, want 0", len(response.Data))
}
}
func TestListTenantAuditReturnsForbiddenForViewer(t *testing.T) {
handler := NewHandler(&stubRepository{})
req := requestWithPrincipalAndMembership(http.MethodGet, "/tenants/tenant-1/audit", "tenant-1", "viewer")
@@ -84,4 +109,4 @@ type stubRepository struct {
func (s *stubRepository) ListTenantAudit(_ context.Context, _ string, _ int, _ int) ([]Entry, error) {
return s.entries, s.err
}
}