Validate portable workspace identifiers
This commit is contained in:
25
internal/config/identity_validation_test.go
Normal file
25
internal/config/identity_validation_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIdentityValidationRejectsUnsafeSegments(t *testing.T) {
|
||||
unsafe := []string{"../escape", `campaign\name`, `C:\campaign`, "café", "campaign name", ".", ".."}
|
||||
for _, value := range unsafe {
|
||||
t.Run("campaign/"+strings.ReplaceAll(value, "/", "_"), func(t *testing.T) {
|
||||
cfg := &CampaignConfig{CampaignID: value, Inputs: CampaignInputsConfig{
|
||||
SpeakersFile: "speakers.yml", AutocorrectFile: "autocorrect.yml", GlossaryFile: "glossary.yml", PlayersFile: "players.yml", PartyFile: "party.yml",
|
||||
}}
|
||||
if err := validateCampaign(cfg); err == nil {
|
||||
t.Fatalf("validateCampaign(%q) error = nil, want rejection", value)
|
||||
}
|
||||
})
|
||||
t.Run("session/"+strings.ReplaceAll(value, "/", "_"), func(t *testing.T) {
|
||||
if err := validateSessionIdentifier("session.session_id", value, true); err == nil {
|
||||
t.Fatalf("validateSessionIdentifier(%q) error = nil, want rejection", value)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user