-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* upgade to go 1.24 * update deps * fix bug: lowercase response headers
- Loading branch information
1 parent
8cc3ac9
commit 647c0c3
Showing
15 changed files
with
254 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ jobs: | |
- id: govulncheck | ||
uses: golang/govulncheck-action@v1 | ||
with: | ||
go-version-input: 1.23 | ||
go-version-input: 1.24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package localizations_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/tufin/oasdiff/checker/localizations" | ||
) | ||
|
||
func TestLang_Exists(t *testing.T) { | ||
require.Equal(t, []string{localizations.LangEn, localizations.LangRu}, localizations.GetSupportedLanguages()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package localizations_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/tufin/oasdiff/checker/localizations" | ||
) | ||
|
||
func TestLocalizations_ExistsNoSunstitute(t *testing.T) { | ||
locales := localizations.New(localizations.LangEn, localizations.LangDefault) | ||
require.Equal(t, "the %s response's property pattern was changed from %s to %s for the status %s", locales.Get("messages.response-property-pattern-changed")) | ||
} | ||
|
||
func TestLocalizations_SetLocal(t *testing.T) { | ||
locales := localizations.New(localizations.LangEn, localizations.LangDefault).SetLocale(localizations.LangEn) | ||
require.Equal(t, "the %s response's property pattern was changed from %s to %s for the status %s", locales.Get("messages.response-property-pattern-changed")) | ||
} | ||
|
||
func TestLocalizations_SetFallbackLocal(t *testing.T) { | ||
locales := localizations.New(localizations.LangEn, localizations.LangDefault).SetFallbackLocale(localizations.LangEn) | ||
require.Equal(t, "the %s response's property pattern was changed from %s to %s for the status %s", locales.Get("messages.response-property-pattern-changed")) | ||
} | ||
|
||
func TestLocalizations_SetLocals(t *testing.T) { | ||
locales := localizations.New(localizations.LangEn, localizations.LangDefault).SetLocales(localizations.LangEn, localizations.LangEn) | ||
require.Equal(t, "the %s response's property pattern was changed from %s to %s for the status %s", locales.Get("messages.response-property-pattern-changed")) | ||
} | ||
|
||
func TestLocalizations_NotExists(t *testing.T) { | ||
locales := localizations.New(localizations.LangEn, localizations.LangDefault) | ||
require.Equal(t, "invalid", locales.Get("invalid")) | ||
} | ||
|
||
func TestLocalizations_ExistsWithSunstitute(t *testing.T) { | ||
locales := localizations.New(localizations.LangEn, localizations.LangDefault) | ||
locales.Localizations = map[string]string{ | ||
"en.messages.response-property-pattern-changed": "{{/* a comment */}}", | ||
} | ||
|
||
replacements := localizations.Replacements{} | ||
require.Equal(t, "", locales.Get("messages.response-property-pattern-changed", &replacements)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package commonparams_test | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/getkin/kin-openapi/openapi3" | ||
"github.com/stretchr/testify/require" | ||
"github.com/tufin/oasdiff/flatten/commonparams" | ||
) | ||
|
||
func TestMove(t *testing.T) { | ||
spec := &openapi3.T{} | ||
spec.Paths = openapi3.NewPathsWithCapacity(1) | ||
spec.Paths.Set("/path", &openapi3.PathItem{ | ||
Parameters: openapi3.Parameters{ | ||
&openapi3.ParameterRef{ | ||
Value: &openapi3.Parameter{ | ||
Name: "X-Header", | ||
In: "query", | ||
}, | ||
}, | ||
}, | ||
}) | ||
spec.Paths.Find("/path").SetOperation(http.MethodGet, &openapi3.Operation{}) | ||
|
||
commonparams.Move(spec) | ||
|
||
require.Empty(t, spec.Paths.Find("/path").Parameters.GetByInAndName("query", "X-Header")) | ||
require.NotEmpty(t, spec.Paths.Find("/path").Get.Parameters.GetByInAndName("query", "X-Header")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package headers_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/getkin/kin-openapi/openapi3" | ||
"github.com/stretchr/testify/require" | ||
"github.com/tufin/oasdiff/flatten/headers" | ||
) | ||
|
||
func TestLowercaseInPath(t *testing.T) { | ||
spec := &openapi3.T{} | ||
spec.Paths = openapi3.NewPathsWithCapacity(1) | ||
spec.Paths.Set("/path", &openapi3.PathItem{ | ||
Parameters: openapi3.Parameters{ | ||
&openapi3.ParameterRef{ | ||
Value: &openapi3.Parameter{ | ||
Name: "X-Header", | ||
In: "query", | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
headers.Lowercase(spec) | ||
|
||
require.Equal(t, "X-Header", spec.Paths.Find("/path").Parameters[0].Value.Name) | ||
} | ||
|
||
func TestLowercaseNonHeader(t *testing.T) { | ||
spec := &openapi3.T{} | ||
spec.Paths = openapi3.NewPathsWithCapacity(1) | ||
spec.Paths.Set("/path", &openapi3.PathItem{ | ||
Parameters: openapi3.Parameters{ | ||
&openapi3.ParameterRef{ | ||
Value: &openapi3.Parameter{ | ||
Name: "X-Header", | ||
In: "header", | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
headers.Lowercase(spec) | ||
|
||
require.Equal(t, "x-header", spec.Paths.Find("/path").Parameters[0].Value.Name) | ||
} | ||
|
||
func TestLowercaseInOperation(t *testing.T) { | ||
spec := &openapi3.T{} | ||
spec.Paths = openapi3.NewPathsWithCapacity(1) | ||
spec.Paths.Set("/path", &openapi3.PathItem{ | ||
Get: &openapi3.Operation{ | ||
Parameters: openapi3.Parameters{ | ||
&openapi3.ParameterRef{ | ||
Value: &openapi3.Parameter{ | ||
Name: "X-Header", | ||
In: "header", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
headers.Lowercase(spec) | ||
|
||
require.Equal(t, "x-header", spec.Paths.Find("/path").GetOperation("GET").Parameters[0].Value.Name) | ||
} | ||
|
||
func TestLowercaseInResponse(t *testing.T) { | ||
spec := &openapi3.T{} | ||
spec.Paths = openapi3.NewPathsWithCapacity(1) | ||
spec.Paths.Set("/path", &openapi3.PathItem{ | ||
Get: &openapi3.Operation{}, | ||
}) | ||
spec.Paths.Find("/path").GetOperation("GET").Responses = openapi3.NewResponsesWithCapacity(1) | ||
spec.Paths.Find("/path").GetOperation("GET").Responses.Set("default", &openapi3.ResponseRef{ | ||
Value: &openapi3.Response{ | ||
Headers: openapi3.Headers{ | ||
"X-Header": &openapi3.HeaderRef{ | ||
Value: &openapi3.Header{ | ||
Parameter: openapi3.Parameter{}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
headers.Lowercase(spec) | ||
|
||
require.Contains(t, spec.Paths.Find("/path").GetOperation("GET").Responses.Default().Value.Headers, "x-header") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.