github.com/nspcc-dev/neo-go@v0.105.2-0.20240517133400-6be757af3eba/pkg/services/oracle/request_test.go (about)

     1  package oracle
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  )
     8  
     9  func TestCheckContentType(t *testing.T) {
    10  	allowedTypes := []string{"application/json", "text/plain"}
    11  	require.True(t, checkMediaType("application/json", allowedTypes))
    12  	require.True(t, checkMediaType("application/json; param=value", allowedTypes))
    13  	require.True(t, checkMediaType("text/plain; filename=file.txt", allowedTypes))
    14  
    15  	require.False(t, checkMediaType("image/gif", allowedTypes))
    16  	require.True(t, checkMediaType("image/gif", nil))
    17  
    18  	require.False(t, checkMediaType("invalid format", allowedTypes))
    19  }