Skip to content

Commit 3c72abe

Browse files
committed
test(learnings): add path traversal test and fix case-sensitive list assertion
1 parent b5b49ca commit 3c72abe

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

agent/tools/learnings_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ func TestLearningReadToolListTopics(t *testing.T) {
7070
if err != nil {
7171
t.Fatalf("Execute: %v", err)
7272
}
73-
if !strings.Contains(result, "go") || !strings.Contains(result, "sql") {
73+
lower := strings.ToLower(result)
74+
if !strings.Contains(lower, "go") || !strings.Contains(lower, "sql") {
7475
t.Errorf("expected both topics, got: %s", result)
7576
}
7677
}

service/learnings/store_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ func TestReadNotFound(t *testing.T) {
8080
}
8181
}
8282

83+
func TestReadRejectsPathTraversal(t *testing.T) {
84+
dir := t.TempDir()
85+
st := New(dir)
86+
87+
for _, bad := range []string{"../etc/passwd", "foo/bar", "test\\path"} {
88+
_, err := st.Read(bad)
89+
if err == nil {
90+
t.Errorf("expected error for topic %q", bad)
91+
}
92+
}
93+
}
94+
8395
func TestList(t *testing.T) {
8496
dir := t.TempDir()
8597
st := New(dir)

0 commit comments

Comments
 (0)