fix validation icons requests image dimension

This commit is contained in:
in-void 2023-02-07 11:38:28 +01:00
parent fc85ba05f7
commit 35da1c7e67
2 changed files with 29 additions and 1 deletions

View File

@ -50,7 +50,7 @@ func processB64PngImage(b64Img string) (image.Image, io.Reader, error) {
func validateImage(img image.Image) error {
imageWidth := img.Bounds().Dx()
imageHeight := img.Bounds().Dx()
imageHeight := img.Bounds().Dy()
validDimensions := []*image.Point{
{X: 120, Y: 120},

View File

@ -33,6 +33,34 @@ func (s *IconsRequestsTestSuite) TestCreateIconRequest() {
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() {
iconRequest := createIconRequest(s.T(), "service")