Skip to content

Commit

Permalink
[NOJIRA][2.3.2] updated env size limit to 256kb (#196)
Browse files Browse the repository at this point in the history
* updated env size limit to 256kb

* test fixed
  • Loading branch information
trapacska authored Jun 30, 2021
1 parent b2b4fe8 commit df85af5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions cli/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,29 @@ func TestEnvListSizeInBytes(t *testing.T) {

func TestValidateEnv(t *testing.T) {
// Valid - max allowed
str20KBytes := strings.Repeat("a", (20 * 1024))
str64KBytes := strings.Repeat("a", (64 * 1024))
env1 := models.EnvironmentItemModel{
"key": str20KBytes,
"key": str64KBytes,
}
envs := []models.EnvironmentItemModel{env1}

valValue, err := validateEnv("key", str20KBytes, envs)
valValue, err := validateEnv("key", str64KBytes, envs)
require.NoError(t, err)
require.Equal(t, str20KBytes, valValue)
require.Equal(t, str64KBytes, valValue)

// List oversize
// first create a large, but valid env set
for i := 0; i < 3; i++ {
for i := 0; i < 2; i++ {
envs = append(envs, env1)
}

valValue, err = validateEnv("key", str20KBytes, envs)
valValue, err = validateEnv("key", str64KBytes, envs)
require.NoError(t, err)
require.Equal(t, str20KBytes, valValue)
require.Equal(t, str64KBytes, valValue)

// append one more -> too large
envs = append(envs, env1)
_, err = validateEnv("key", str20KBytes, envs)
_, err = validateEnv("key", str64KBytes, envs)
require.Equal(t, errors.New("environment list too large"), err)

// List oversize + too big value
Expand All @@ -68,9 +68,9 @@ func TestValidateEnv(t *testing.T) {
envs = append(envs, env)
}

str21Kbytes := strings.Repeat("a", (21 * 1024))
str257Kbytes := strings.Repeat("a", (257 * 1024))

valValue, err = validateEnv("key", str21Kbytes, envs)
valValue, err = validateEnv("key", str257Kbytes, envs)
require.NoError(t, err)
require.Equal(t, "environment var (key) value too large - rejected", valValue)
}
4 changes: 2 additions & 2 deletions envman/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

const (
envmanConfigFileName = "configs.json"
defaultEnvBytesLimitInKB = 20
defaultEnvListBytesLimitInKB = 100
defaultEnvBytesLimitInKB = 256
defaultEnvListBytesLimitInKB = 256
)

// ConfigsModel ...
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package version

// VERSION ...
const VERSION = "2.3.1"
const VERSION = "2.3.2"

0 comments on commit df85af5

Please sign in to comment.