mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Support processing parameters sent as a URL-encoded form (#8325)
This commit is contained in:
@@ -437,3 +437,28 @@ func TestLogical_Audit_invalidWrappingToken(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLogical_ShouldParseForm(t *testing.T) {
|
||||
const formCT = "application/x-www-form-urlencoded"
|
||||
|
||||
tests := map[string]struct {
|
||||
prefix string
|
||||
contentType string
|
||||
isForm bool
|
||||
}{
|
||||
"JSON": {`{"a":42}`, formCT, false},
|
||||
"JSON 2": {`[42]`, formCT, false},
|
||||
"JSON w/leading space": {" \n\n\r\t [42] ", formCT, false},
|
||||
"Form": {"a=42&b=dog", formCT, true},
|
||||
"Form w/wrong CT": {"a=42&b=dog", "application/json", false},
|
||||
}
|
||||
|
||||
for name, test := range tests {
|
||||
isForm := isForm([]byte(test.prefix), test.contentType)
|
||||
|
||||
if isForm != test.isForm {
|
||||
t.Fatalf("%s fail: expected isForm %t, got %t", name, test.isForm, isForm)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user