mirror of
https://github.com/twofas/2fas-server.git
synced 2024-12-25 02:20:43 +01:00
fix validation icons requests image dimension
This commit is contained in:
parent
fc85ba05f7
commit
35da1c7e67
@ -50,7 +50,7 @@ func processB64PngImage(b64Img string) (image.Image, io.Reader, error) {
|
|||||||
|
|
||||||
func validateImage(img image.Image) error {
|
func validateImage(img image.Image) error {
|
||||||
imageWidth := img.Bounds().Dx()
|
imageWidth := img.Bounds().Dx()
|
||||||
imageHeight := img.Bounds().Dx()
|
imageHeight := img.Bounds().Dy()
|
||||||
|
|
||||||
validDimensions := []*image.Point{
|
validDimensions := []*image.Point{
|
||||||
{X: 120, Y: 120},
|
{X: 120, Y: 120},
|
||||||
|
@ -33,6 +33,34 @@ func (s *IconsRequestsTestSuite) TestCreateIconRequest() {
|
|||||||
assert.Equal(s.T(), "desc", iconRequest.Description)
|
assert.Equal(s.T(), "desc", iconRequest.Description)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *IconsRequestsTestSuite) TestCreateIconRequestWithNotAllowedIconDimensions() {
|
||||||
|
img := faker.New().Image().Image(120, 60)
|
||||||
|
|
||||||
|
pngImg, err := ioutil.ReadFile(img.Name())
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
s.T().Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
iconBase64Encoded := base64.StdEncoding.EncodeToString(pngImg)
|
||||||
|
|
||||||
|
payload := []byte(`
|
||||||
|
{
|
||||||
|
"caller_id":"some-caller-uniq-name",
|
||||||
|
"service_name":"some-service",
|
||||||
|
"issuers": ["fb"],
|
||||||
|
"description":"desc",
|
||||||
|
"light_icon":"` + iconBase64Encoded + `"
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
var iconRequest *queries.IconRequestPresenter
|
||||||
|
|
||||||
|
response := tests.DoPost("mobile/icons/requests", payload, &iconRequest)
|
||||||
|
|
||||||
|
assert.Equal(s.T(), 400, response.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *IconsRequestsTestSuite) TestDeleteIconRequest() {
|
func (s *IconsRequestsTestSuite) TestDeleteIconRequest() {
|
||||||
iconRequest := createIconRequest(s.T(), "service")
|
iconRequest := createIconRequest(s.T(), "service")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user