mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
parent
8d3e493931
commit
7fcc0b0e5e
3
.gitignore
vendored
3
.gitignore
vendored
@ -13,10 +13,11 @@
|
|||||||
|
|
||||||
# Dependency directories (remove the comment below to include it)
|
# Dependency directories (remove the comment below to include it)
|
||||||
exhaust/
|
exhaust/
|
||||||
|
builds/
|
||||||
/.idea/.gitignore
|
/.idea/.gitignore
|
||||||
/.idea/misc.xml
|
/.idea/misc.xml
|
||||||
/.idea/modules.xml
|
/.idea/modules.xml
|
||||||
/.idea/vcs.xml
|
/.idea/vcs.xml
|
||||||
/.idea/webp_server_go.iml
|
/.idea/webp_server_go.iml
|
||||||
remote-raw/
|
remote-raw/
|
||||||
coverage.txt
|
coverage.txt
|
||||||
|
@ -5,13 +5,14 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gofiber/fiber/v2"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -73,7 +74,7 @@ func TestConvert(t *testing.T) {
|
|||||||
"http://127.0.0.1:3333/webp_server.bmp": "image/webp",
|
"http://127.0.0.1:3333/webp_server.bmp": "image/webp",
|
||||||
"http://127.0.0.1:3333/webp_server.png": "image/webp",
|
"http://127.0.0.1:3333/webp_server.png": "image/webp",
|
||||||
"http://127.0.0.1:3333/empty.jpg": "",
|
"http://127.0.0.1:3333/empty.jpg": "",
|
||||||
"http://127.0.0.1:3333/png.jpg": "image/webp",
|
"http://127.0.0.1:3333/png.jpg": "image/png",
|
||||||
"http://127.0.0.1:3333/12314.jpg": "",
|
"http://127.0.0.1:3333/12314.jpg": "",
|
||||||
"http://127.0.0.1:3333/dir1/inside.jpg": "image/webp",
|
"http://127.0.0.1:3333/dir1/inside.jpg": "image/webp",
|
||||||
"http://127.0.0.1:3333/%e5%a4%aa%e7%a5%9e%e5%95%a6.png": "image/webp",
|
"http://127.0.0.1:3333/%e5%a4%aa%e7%a5%9e%e5%95%a6.png": "image/webp",
|
||||||
@ -116,11 +117,10 @@ func TestConvertNotAllowed(t *testing.T) {
|
|||||||
var app = fiber.New()
|
var app = fiber.New()
|
||||||
app.Get("/*", convert)
|
app.Get("/*", convert)
|
||||||
|
|
||||||
// not allowed, but we have the file
|
// not allowed, but we have the file, this should return File extension not allowed
|
||||||
url := "http://127.0.0.1:3333/webp_server.bmp"
|
url := "http://127.0.0.1:3333/webp_server.bmp"
|
||||||
_, data := requestToServer(url, app, chromeUA, acceptWebP)
|
_, data := requestToServer(url, app, chromeUA, acceptWebP)
|
||||||
contentType := getFileContentType(data)
|
assert.Contains(t, string(data), "File extension not allowed")
|
||||||
assert.Equal(t, "image/bmp", contentType)
|
|
||||||
|
|
||||||
// not allowed, random file
|
// not allowed, random file
|
||||||
url = url + "hagdgd"
|
url = url + "hagdgd"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user