tested real proxmox connection
--> passed
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user