From be551aad6b170f1f61c58a8f01d2520d49094bac Mon Sep 17 00:00:00 2001 From: Marcel Jacek Date: Thu, 5 Jun 2025 12:47:25 +0200 Subject: [PATCH 1/2] fix: generate allowed string length in testcases - removed edge from blacklist --- blacklist.txt | 1 - templates/go/api_test.mustache | 14 +++++++++++++- templates/go/utils.mustache | 11 +++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/blacklist.txt b/blacklist.txt index 7f8bf2b..4a10aea 100644 --- a/blacklist.txt +++ b/blacklist.txt @@ -5,7 +5,6 @@ kms airflow -edge customer vpn privateendpoint \ No newline at end of file diff --git a/templates/go/api_test.mustache b/templates/go/api_test.mustache index a90f630..e0e6892 100644 --- a/templates/go/api_test.mustache +++ b/templates/go/api_test.mustache @@ -28,7 +28,19 @@ func Test_{{packageName}}_{{classname}}Service(t *testing.T) { {{#operation}} t.Run("Test {{classname}}Service {{{nickname}}}", func(t *testing.T) { _apiUrlPath := "{{{path}}}"{{#pathParams}} - {{paramName}}Value := {{#isAnyType}}"unspecified type"{{/isAnyType}}{{#isString}}{{#isUuid}}uuid.NewString(){{/isUuid}}{{^isUuid}}"{{paramName}}-value"{{/isUuid}}{{/isString}}{{#isNumber}}123{{/isNumber}}{{#isFloat}}float32(123){{/isFloat}}{{#isDouble}}float64(123){{/isDouble}}{{#isInteger}}int32(123){{/isInteger}}{{#isLong}}int64(123){{/isLong}}{{^isString}}{{^isInteger}}{{defaultValue}}{{/isInteger}}{{/isString}} + {{^minLength}} + {{^maxLength}} + {{paramName}}Value := {{#isAnyType}}"unspecified type"{{/isAnyType}}{{#isString}}{{#isUuid}}uuid.NewString(){{/isUuid}}{{^isUuid}}"{{paramName}}-value"{{/isUuid}}{{/isString}}{{#isNumber}}123{{/isNumber}}{{#isFloat}}float32(123){{/isFloat}}{{#isDouble}}float64(123){{/isDouble}}{{#isInteger}}int32(123){{/isInteger}}{{#isLong}}int64(123){{/isLong}}{{^isString}}{{^isInteger}}{{defaultValue}}{{/isInteger}}{{/isString}} + {{/maxLength}} + {{/minLength}} + {{#minLength}} + {{paramName}}Value := randString({{minLength}}) + {{/minLength}} + {{#maxLength}} + {{^minLength}} + {{paramName}}Value := randString({{maxLength}}) + {{/minLength}} + {{/maxLength}} _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"{{baseName}}"+"}", url.PathEscape(ParameterValueToString({{paramName}}Value, "{{paramName}}")), -1){{/pathParams}} test{{classname}}ServeMux := http.NewServeMux() diff --git a/templates/go/utils.mustache b/templates/go/utils.mustache index 4bd0284..6b84931 100644 --- a/templates/go/utils.mustache +++ b/templates/go/utils.mustache @@ -362,3 +362,14 @@ func IsNil(i interface{}) bool { type MappedNullable interface { ToMap() (map[string]interface{}, error) } + +const letterRunes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + +// randString returns a random string with a specified length. It panics if n <= 0. +func randString(n int) string { + b := make([]byte, n) + for i := range b { + b[i] = letterRunes[rand.Intn(len(letterRunes))] + } + return string(b) +} \ No newline at end of file From 1817adc1404283ac93396b638239e3406f3282a6 Mon Sep 17 00:00:00 2001 From: Marcel Jacek Date: Thu, 5 Jun 2025 14:33:38 +0200 Subject: [PATCH 2/2] add assumerole to blacklist --- blacklist.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blacklist.txt b/blacklist.txt index 4a10aea..12b2f0e 100644 --- a/blacklist.txt +++ b/blacklist.txt @@ -1,5 +1,5 @@ # Transitional file to disable generation for selected services -#assumerole +assumerole #customer #openstack kms