Derive independent glossary context and protection
This commit is contained in:
33
internal/core/glossary/selection_test.go
Normal file
33
internal/core/glossary/selection_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package glossary
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/config"
|
||||
)
|
||||
|
||||
func TestSelectionRetainsDistinctIdentitiesAndDoesNotExposeExtensions(t *testing.T) {
|
||||
plural := "Shields"
|
||||
collections := map[string]config.GlossaryCollection{
|
||||
"spells": {Entries: []config.GlossaryEntry{{ID: "shield", Name: "Shield", Category: "spell", Aliases: []string{"Ward"}, Plural: &plural, Extra: map[string]any{"private": "do not forward"}}}},
|
||||
"items": {Entries: []config.GlossaryEntry{{ID: "shield", Name: "Shield", Category: "item"}}},
|
||||
}
|
||||
result := Select(collections, []string{"spells", "items", "spells"})
|
||||
if len(result) != 2 || result[0].Collection != "spells" || result[1].Collection != "items" {
|
||||
t.Fatalf("entries=%+v", result)
|
||||
}
|
||||
raw, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.Contains(string(raw), "do not forward") {
|
||||
t.Fatal("extension leaked into prompt projection")
|
||||
}
|
||||
result[0].Aliases[0] = "changed"
|
||||
*result[0].Plural = "changed"
|
||||
if collections["spells"].Entries[0].Aliases[0] != "Ward" || *collections["spells"].Entries[0].Plural != "Shields" {
|
||||
t.Fatal("projection changed configuration")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user