oracle: check response Content-Type
If not specified everything is allowed. Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
1853d0c713
commit
8e9302f40b
6 changed files with 90 additions and 13 deletions
19
pkg/services/oracle/request_test.go
Normal file
19
pkg/services/oracle/request_test.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package oracle
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCheckContentType(t *testing.T) {
|
||||
allowedTypes := []string{"application/json", "text/plain"}
|
||||
require.True(t, checkMediaType("application/json", allowedTypes))
|
||||
require.True(t, checkMediaType("application/json; param=value", allowedTypes))
|
||||
require.True(t, checkMediaType("text/plain; filename=file.txt", allowedTypes))
|
||||
|
||||
require.False(t, checkMediaType("image/gif", allowedTypes))
|
||||
require.True(t, checkMediaType("image/gif", nil))
|
||||
|
||||
require.False(t, checkMediaType("invalid format", allowedTypes))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue