From 35116e236f9785be0646c09114aad5e15e561903 Mon Sep 17 00:00:00 2001 From: in-void Date: Sat, 18 Mar 2023 15:30:42 +0100 Subject: [PATCH] browser extension "not blank" name validation during updates --- .../app/command/update_browser_extension.go | 2 +- tests/browser_extension/browser_extension_test.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/api/browser_extension/app/command/update_browser_extension.go b/internal/api/browser_extension/app/command/update_browser_extension.go index 3a485b2..79de380 100644 --- a/internal/api/browser_extension/app/command/update_browser_extension.go +++ b/internal/api/browser_extension/app/command/update_browser_extension.go @@ -7,7 +7,7 @@ import ( type UpdateBrowserExtension struct { BrowserExtensionId string `uri:"extension_id" validate:"required,uuid4"` - Name string `json:"name" validate:"lte=64"` + Name string `json:"name" validate:"not_blank,lte=64"` BrowserName string `json:"browser_name" validate:"lte=255"` BrowserVersion string `json:"browser_version" validate:"lte=32"` } diff --git a/tests/browser_extension/browser_extension_test.go b/tests/browser_extension/browser_extension_test.go index 353100c..a11717f 100644 --- a/tests/browser_extension/browser_extension_test.go +++ b/tests/browser_extension/browser_extension_test.go @@ -66,6 +66,15 @@ func (s *BrowserExtensionTestSuite) TestUpdateNotExistingBrowserExtension() { assert.Equal(s.T(), 404, response.StatusCode) } +func (s *BrowserExtensionTestSuite) TestUpdateBrowserExtensionSetEmptyName() { + browserExt := tests.CreateBrowserExtension(s.T(), "go-test") + + payload := []byte(`{"name": ""}`) + response := tests.DoPut("/browser_extensions/"+browserExt.Id, payload, nil) + + assert.Equal(s.T(), 400, response.StatusCode) +} + func (s *BrowserExtensionTestSuite) TestDoNotFindNotExistingExtension() { notExistingId := uuid.New()