The isValidSecretName() regex only allowed lowercase letters [a-z], rejecting valid secret names containing uppercase characters (e.g. AWS access key IDs). Changed regex from ^[a-z0-9\.\-\_\/]+$ to ^[a-zA-Z0-9\.\-\_\/]+$ and added tests for uppercase secret names in both vault and secret packages.
43 lines
935 B
Go
43 lines
935 B
Go
package vault
|
|
|
|
import "testing"
|
|
|
|
func TestIsValidSecretNameUppercase(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
valid bool
|
|
}{
|
|
// Lowercase (existing behavior)
|
|
{"valid-name", true},
|
|
{"valid.name", true},
|
|
{"valid_name", true},
|
|
{"valid/path/name", true},
|
|
{"123valid", true},
|
|
|
|
// Uppercase (new behavior - issue #2)
|
|
{"Valid-Upper-Name", true},
|
|
{"2025-11-21-ber1app1-vaultik-test-bucket-AKI", true},
|
|
{"MixedCase/Path/Name", true},
|
|
{"ALLUPPERCASE", true},
|
|
{"ABC123", true},
|
|
|
|
// Still invalid
|
|
{"", false},
|
|
{"invalid name", false},
|
|
{"invalid@name", false},
|
|
{".dotstart", false},
|
|
{"/leading-slash", false},
|
|
{"trailing-slash/", false},
|
|
{"double//slash", false},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
result := isValidSecretName(tt.name)
|
|
if result != tt.valid {
|
|
t.Errorf("isValidSecretName(%q) = %v, want %v", tt.name, result, tt.valid)
|
|
}
|
|
})
|
|
}
|
|
}
|