Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions authbridge/cmd/abctl/tui/pipeline_pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ func (m *model) rebuildPipelineTable() {
for _, p := range m.pipeline.Inbound {
rows = append(rows, pipelineRow(p, counts[p.Name], m.pipeline.Inbound))
}
// Divider between inbound and outbound.
rows = append(rows, table.Row{"", "", "── (app) ──", "", "", "", ""})
// Divider between inbound and outbound. Cell count MUST match the 6
// columns defined in newPipelineTable (#, DIRECTION, PLUGIN, DEPS, BODY,
// EVENTS) — bubbles' table.renderRow indexes columns by cell position and
// panics on a mismatch.
rows = append(rows, table.Row{"", "", "── (app) ──", "", "", ""})
for _, p := range m.pipeline.Outbound {
rows = append(rows, pipelineRow(p, counts[p.Name], m.pipeline.Outbound))
}
Expand Down
38 changes: 38 additions & 0 deletions authbridge/cmd/abctl/tui/pipeline_pane_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package tui

import (
"testing"

"github.com/kagenti/kagenti-extensions/authbridge/cmd/abctl/apiclient"
)

// TestRebuildPipelineTable_AllRowsMatchColumnCount is a regression guard:
// every row added to the pipeline table — including the inbound/outbound
// "(app)" divider — must have exactly as many cells as the table has columns.
// The divider previously carried 7 cells against 6 columns, which made
// bubbles' table.renderRow panic ("index out of range [6] with length 6")
// the moment abctl rendered any pipeline.
func TestRebuildPipelineTable_AllRowsMatchColumnCount(t *testing.T) {
m := &model{
pipeline: &apiclient.PipelineView{
Inbound: []apiclient.PipelinePlugin{{Name: "jwt-validation", Direction: "inbound", Position: 1}},
Outbound: []apiclient.PipelinePlugin{{Name: "token-exchange", Direction: "outbound", Position: 1}},
},
pipelineTbl: newPipelineTable(),
}

// Must not panic: the buggy 7-cell divider panicked here via
// SetRows → UpdateViewport → renderRow.
m.rebuildPipelineTable()

rows := m.pipelineTbl.Rows()
if len(rows) != 3 { // inbound plugin + divider + outbound plugin
t.Fatalf("rows = %d, want 3 (inbound + divider + outbound)", len(rows))
}
const wantCells = 6 // #, DIRECTION, PLUGIN, DEPS, BODY, EVENTS
for i, r := range rows {
if len(r) != wantCells {
t.Errorf("row %d has %d cells, want %d (must match column count)", i, len(r), wantCells)
}
}
}
Loading