mirror of
https://github.com/elyby/chrly.git
synced 2024-12-22 21:19:55 +05:30
Added test for the case, when signing key is not available
This commit is contained in:
parent
968c83db99
commit
f5f8fbc65e
@ -5,6 +5,7 @@ import (
|
||||
"encoding/base64"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"testing"
|
||||
@ -421,6 +422,30 @@ func TestConfig_DeleteSkinByUsername_NotFound(t *testing.T) {
|
||||
]`, string(response))
|
||||
}
|
||||
|
||||
func TestConfig_Authenticate_SignatureKeyNotSet(t *testing.T) {
|
||||
assert := testify.New(t)
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
config, mocks := setupMocks(ctrl)
|
||||
|
||||
req := httptest.NewRequest("POST", "http://localhost", nil)
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
mocks.Auth.EXPECT().Check(gomock.Any()).Return(&auth.SigningKeyNotAvailable{})
|
||||
mocks.Log.EXPECT().Error("Unknown error on validating api request: :err", gomock.Any())
|
||||
|
||||
res := config.Authenticate(http.HandlerFunc(func (resp http.ResponseWriter, req *http.Request) {}))
|
||||
res.ServeHTTP(w, req)
|
||||
|
||||
resp := w.Result()
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(500, resp.StatusCode)
|
||||
response, _ := ioutil.ReadAll(resp.Body)
|
||||
assert.Empty(response)
|
||||
}
|
||||
|
||||
// base64 https://github.com/mathiasbynens/small/blob/0ca3c51/png-transparent.png
|
||||
var OnePxPng = []byte("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user