add more tests (#1763)
* feat: add goctl docker build scripts * chore: add more tests
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -116,3 +117,18 @@ func TestCryptionHandler_Hijack(t *testing.T) {
|
|||||||
writer.Hijack()
|
writer.Hijack()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCryptionHandler_ContentTooLong(t *testing.T) {
|
||||||
|
handler := CryptionHandler(aesKey)(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
}))
|
||||||
|
svr := httptest.NewServer(handler)
|
||||||
|
defer svr.Close()
|
||||||
|
|
||||||
|
body := make([]byte, maxBytes+1)
|
||||||
|
rand.Read(body)
|
||||||
|
req, err := http.NewRequest(http.MethodPost, svr.URL, bytes.NewReader(body))
|
||||||
|
assert.Nil(t, err)
|
||||||
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, http.StatusBadRequest, resp.StatusCode)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
build:
|
build:
|
||||||
go build -ldflags="-s -w" goctl.go
|
go build -ldflags="-s -w" goctl.go
|
||||||
$(if $(shell command -v upx), upx goctl)
|
$(if $(shell command -v upx), upx goctl)
|
||||||
|
|
||||||
mac:
|
mac:
|
||||||
GOOS=darwin go build -ldflags="-s -w" -o goctl-darwin goctl.go
|
GOOS=darwin go build -ldflags="-s -w" -o goctl-darwin goctl.go
|
||||||
$(if $(shell command -v upx), upx goctl-darwin)
|
$(if $(shell command -v upx), upx goctl-darwin)
|
||||||
|
|
||||||
win:
|
win:
|
||||||
GOOS=windows go build -ldflags="-s -w" -o goctl.exe goctl.go
|
GOOS=windows go build -ldflags="-s -w" -o goctl.exe goctl.go
|
||||||
$(if $(shell command -v upx), upx goctl.exe)
|
$(if $(shell command -v upx), upx goctl.exe)
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
GOOS=linux go build -ldflags="-s -w" -o goctl-linux goctl.go
|
GOOS=linux go build -ldflags="-s -w" -o goctl-linux goctl.go
|
||||||
$(if $(shell command -v upx), upx goctl-linux)
|
$(if $(shell command -v upx), upx goctl-linux)
|
||||||
|
|||||||
Reference in New Issue
Block a user