Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add media-type to messages #600

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions checker/check_api_added_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/tufin/oasdiff/diff"
)

// CL: new paths or path operations
// CL: new paths or path operations: endpoint-added
func TestApiAdded_DetectsNewPathsAndNewOperations(t *testing.T) {
s1, err := open("../data/new_endpoints/base.yaml")
require.NoError(t, err)
Expand Down Expand Up @@ -36,7 +36,7 @@ func TestApiAdded_DetectsNewPathsAndNewOperations(t *testing.T) {
require.Equal(t, "/api/test3", e1.Path)
}

// CL: new paths or path operations
// CL: new paths or path operations: endpoint-added
func TestApiAdded_DetectsModifiedPathsWithPathParam(t *testing.T) {
s1, err := open("../data/new_endpoints/base_with_path_param.yaml")
require.NoError(t, err)
Expand Down
16 changes: 9 additions & 7 deletions checker/check_api_deprecation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestBreaking_DeprecationPast(t *testing.T) {
require.Empty(t, errs)
}

// BC: deprecating an operation with a deprecation policy and an invalid sunset date is breaking
// BC: deprecating an operation with a deprecation policy and an invalid sunset date is breaking: api-deprecated-sunset-parse
func TestBreaking_DeprecationWithInvalidSunset(t *testing.T) {

s1, err := open(getDeprecationFile("base.yaml"))
Expand All @@ -64,7 +64,7 @@ func TestBreaking_DeprecationWithInvalidSunset(t *testing.T) {
require.Equal(t, "failed to parse sunset date: 'sunset date doesn't conform with RFC3339: invalid'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// BC: deprecating an operation with a deprecation policy and an invalid stability level is breaking
// BC: deprecating an operation with a deprecation policy and an invalid stability level is breaking: api-invalid-stability-level
func TestBreaking_DeprecationWithInvalidStabilityLevel(t *testing.T) {

s1, err := open(getDeprecationFile("base.yaml"))
Expand Down Expand Up @@ -100,7 +100,7 @@ func TestBreaking_DeprecationWithoutSunsetNoPolicy(t *testing.T) {
require.Empty(t, errs)
}

// BC: deprecating an operation with a deprecation policy but without specifying sunset date is breaking
// BC: deprecating an operation with a deprecation policy but without specifying sunset date is breaking: api-deprecated-sunset-missing
func TestBreaking_DeprecationWithoutSunsetWithPolicy(t *testing.T) {

s1, err := open(getDeprecationFile("base.yaml"))
Expand Down Expand Up @@ -211,7 +211,7 @@ func toJson(t *testing.T, value string) json.RawMessage {
return data
}

// BC: deprecating an operation with a deprecation policy and sunset date before required deprecation period is breaking
// BC: deprecating an operation with a deprecation policy and sunset date before required deprecation period is breaking: api-sunset-date-too-small
func TestBreaking_DeprecationWithEarlySunset(t *testing.T) {
s1, err := open(getDeprecationFile("base.yaml"))
require.NoError(t, err)
Expand All @@ -231,7 +231,7 @@ func TestBreaking_DeprecationWithEarlySunset(t *testing.T) {
require.Equal(t, fmt.Sprintf("sunset date '%s' is too small, must be at least '10' days from now", sunsetDate), errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// BC: deprecating an operation with a deprecation policy and sunset date after required deprecation period is not breaking
// BC: deprecating an operation with a deprecation policy and sunset date after required deprecation period is not breaking: endpoint-deprecated
func TestBreaking_DeprecationWithProperSunset(t *testing.T) {

s1, err := open(getDeprecationFile("base.yaml"))
Expand All @@ -249,6 +249,7 @@ func TestBreaking_DeprecationWithProperSunset(t *testing.T) {
require.Len(t, errs, 1)
// only a non-breaking change detected
require.Equal(t, checker.INFO, errs[0].GetLevel())
require.Equal(t, checker.EndpointDeprecatedId, errs[0].GetId())
require.Equal(t, "endpoint deprecated", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

Expand All @@ -267,7 +268,7 @@ func TestBreaking_DeprecationPathPast(t *testing.T) {
require.Empty(t, errs)
}

// CL: path operations that became deprecated
// CL: path operations that became deprecated: endpoint-deprecated
func TestApiDeprecated_DetectsDeprecatedOperations(t *testing.T) {
s1, err := open("../data/deprecation/base.yaml")
require.NoError(t, err)
Expand All @@ -290,7 +291,7 @@ func TestApiDeprecated_DetectsDeprecatedOperations(t *testing.T) {
require.Equal(t, "endpoint deprecated", e0.GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// CL: path operations that were re-activated
// CL: path operations that were re-activated: endpoint-reactivated
func TestApiDeprecated_DetectsReactivatedOperations(t *testing.T) {
s1, err := open("../data/deprecation/deprecated-future.yaml")
require.NoError(t, err)
Expand All @@ -313,6 +314,7 @@ func TestApiDeprecated_DetectsReactivatedOperations(t *testing.T) {
require.Equal(t, "endpoint reactivated", e0.GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// BC: specifying an invalid stability level is breaking: api-invalid-stability-level
func TestBreaking_InvaidStability(t *testing.T) {

s1, err := open(getDeprecationFile("invalid-stability.yaml"))
Expand Down
8 changes: 5 additions & 3 deletions checker/check_api_operation_id_updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/tufin/oasdiff/load"
)

// CL: removing an existing operation id
// CL: removing an existing operation id: api-operation-id-removed
func TestOperationIdRemoved(t *testing.T) {
s1, err := open("../data/checker/operation_id_removed_base.yaml")
require.NoError(t, err)
Expand All @@ -31,9 +31,11 @@ func TestOperationIdRemoved(t *testing.T) {
Source: load.NewSource("../data/checker/operation_id_removed_base.yaml"),
OperationId: "createOneGroup",
}, errs[0])

require.Equal(t, "api operation id 'createOneGroup' removed and replaced with ''", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// CL: updating an existing operation id
// CL: updating an existing operation id: api-operation-id-removed
func TestOperationIdUpdated(t *testing.T) {
s1, err := open("../data/checker/operation_id_removed_base.yaml")
require.NoError(t, err)
Expand All @@ -59,7 +61,7 @@ func TestOperationIdUpdated(t *testing.T) {
require.Equal(t, "api operation id 'createOneGroup' removed and replaced with 'newOperationId'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// CL: adding a new operation id
// CL: adding a new operation id: api-operation-id-added
func TestOperationIdAdded(t *testing.T) {
s1, err := open("../data/checker/operation_id_added_base.yaml")
require.NoError(t, err)
Expand Down
12 changes: 6 additions & 6 deletions checker/check_api_removed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/tufin/oasdiff/diff"
)

// BC: deleting an operation before sunset date is breaking
// BC: deleting an operation before sunset date is breaking: api-removed-before-sunset
func TestBreaking_RemoveBeforeSunset(t *testing.T) {

s1, err := open(getDeprecationFile("deprecated-future.yaml"))
Expand Down Expand Up @@ -41,7 +41,7 @@ func TestBreaking_DeprecationNoSunset(t *testing.T) {
require.Empty(t, errs)
}

// BC: removing the path without a deprecation policy and without specifying sunset date is breaking if some APIs are not alpha stability level
// BC: removing the path without a deprecation policy and without specifying sunset date is breaking if some APIs are not alpha stability level: api-path-removed-without-deprecation
func TestBreaking_RemovedPathForAlphaBreaking(t *testing.T) {
s1, err := open(getDeprecationFile("base-alpha-stability.yaml"))
require.NoError(t, err)
Expand All @@ -61,7 +61,7 @@ func TestBreaking_RemovedPathForAlphaBreaking(t *testing.T) {
require.Equal(t, "api path removed without deprecation", errs[1].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// BC: removing the path without a deprecation policy and without specifying sunset date is breaking if some APIs are not draft stability level
// BC: removing the path without a deprecation policy and without specifying sunset date is breaking if some APIs are not draft stability level: api-path-removed-without-deprecation
func TestBreaking_RemovedPathForDraftBreaking(t *testing.T) {
s1, err := open(getDeprecationFile("base-alpha-stability.yaml"))
require.NoError(t, err)
Expand All @@ -83,7 +83,7 @@ func TestBreaking_RemovedPathForDraftBreaking(t *testing.T) {
require.Equal(t, "api path removed without deprecation", errs[1].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// BC: deleting a path with some operations having sunset date in the future is breaking
// BC: deleting a path with some operations having sunset date in the future is breaking: api-path-removed-before-sunset
func TestBreaking_DeprecationPathMixed(t *testing.T) {

s1, err := open(getDeprecationFile("deprecated-path-mixed.yaml"))
Expand All @@ -101,7 +101,7 @@ func TestBreaking_DeprecationPathMixed(t *testing.T) {
require.Equal(t, "api path removed before the sunset date '9999-08-10'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// BC: removing a deprecated enpoint with an invalid date is breaking
// BC: removing a deprecated enpoint with an invalid date is breaking: api-path-sunset-parse
func TestBreaking_RemoveEndpointWithInvalidSunset(t *testing.T) {

s1, err := open(getDeprecationFile("deprecated-invalid.yaml"))
Expand All @@ -122,7 +122,7 @@ func TestBreaking_RemoveEndpointWithInvalidSunset(t *testing.T) {
require.Equal(t, "../data/deprecation/deprecated-invalid.yaml", errs[0].GetSource())
}

// test sunset date without double quotes, see https://github.com/Tufin/oasdiff/pull/198/files
// test sunset date without double quotes, see https://github.com/Tufin/oasdiff/pull/198/files: api-path-removed-before-sunset
func TestBreaking_DeprecationPathMixed_RFC3339_Sunset(t *testing.T) {

s1, err := open(getDeprecationFile("deprecated-path-mixed-rfc3339-sunset.yaml"))
Expand Down
32 changes: 16 additions & 16 deletions checker/check_api_security_updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/tufin/oasdiff/load"
)

// CL: adding a new global security to the API
// CL: adding a new global security to the API: api-global-security-added
func TestAPIGlobalSecurityyAdded(t *testing.T) {
s1, err := open("../data/checker/api_security_global_added_base.yaml")
require.NoError(t, err)
Expand All @@ -25,10 +25,10 @@ func TestAPIGlobalSecurityyAdded(t *testing.T) {
Args: []any{"petstore_auth"},
Level: checker.INFO,
}, errs[0])
require.Equal(t, "the security scheme 'petstore_auth' was added to the API", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
require.Equal(t, "security scheme 'petstore_auth' was added", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// CL: removing a global security from the API
// CL: removing a global security from the API: api-global-security-removed
func TestAPIGlobalSecurityyDeleted(t *testing.T) {
s1, err := open("../data/checker/api_security_global_added_revision.yaml")
require.NoError(t, err)
Expand All @@ -44,10 +44,10 @@ func TestAPIGlobalSecurityyDeleted(t *testing.T) {
Args: []any{"petstore_auth"},
Level: checker.INFO,
}, errs[0])
require.Equal(t, "the security scheme 'petstore_auth' was removed from the API", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
require.Equal(t, "removed security scheme 'petstore_auth'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// CL: removing a security scope from an API global security
// CL: removing a security scope from an API global security: api-global-security-scope-removed
func TestAPIGlobalSecurityScopeRemoved(t *testing.T) {
s1, err := open("../data/checker/api_security_global_added_revision.yaml")
require.NoError(t, err)
Expand All @@ -64,10 +64,10 @@ func TestAPIGlobalSecurityScopeRemoved(t *testing.T) {
Args: []any{"read:pets", "petstore_auth"},
Level: checker.INFO,
}, errs[0])
require.Equal(t, "the security scope 'read:pets' was removed from the global security scheme 'petstore_auth'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
require.Equal(t, "removed security scope 'read:pets' from global security scheme 'petstore_auth'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// CL: adding a security scope from an API global security
// CL: adding a security scope from an API global security: api-global-security-scope-added
func TestAPIGlobalSecurityScopeAdded(t *testing.T) {
s1, err := open("../data/checker/api_security_global_added_revision.yaml")
require.NoError(t, err)
Expand All @@ -84,10 +84,10 @@ func TestAPIGlobalSecurityScopeAdded(t *testing.T) {
Args: []any{"read:pets", "petstore_auth"},
Level: checker.INFO,
}, errs[0])
require.Equal(t, "the security scope 'read:pets' was added to the global security scheme 'petstore_auth'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
require.Equal(t, "security scope 'read:pets' was added to global security scheme 'petstore_auth'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// CL: adding a new security to the API endpoint
// CL: adding a new security to the API endpoint: api-security-added
func TestAPISecurityAdded(t *testing.T) {
s1, err := open("../data/checker/api_security_added_base.yaml")
require.NoError(t, err)
Expand All @@ -106,10 +106,10 @@ func TestAPISecurityAdded(t *testing.T) {
Path: "/subscribe",
Source: load.NewSource("../data/checker/api_security_added_revision.yaml"),
}, errs[0])
require.Equal(t, "the endpoint scheme security 'petstore_auth' was added to the API", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
require.Equal(t, "endpoint scheme security 'petstore_auth' was added", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// CL: removing a new security to the API endpoint
// CL: removing a new security to the API endpoint: api-security-removed
func TestAPISecurityDeleted(t *testing.T) {
s1, err := open("../data/checker/api_security_added_revision.yaml")
require.NoError(t, err)
Expand All @@ -128,10 +128,10 @@ func TestAPISecurityDeleted(t *testing.T) {
Path: "/subscribe",
Source: load.NewSource("../data/checker/api_security_added_base.yaml"),
}, errs[0])
require.Equal(t, "the endpoint scheme security 'petstore_auth' was removed from the API", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
require.Equal(t, "removed endpoint scheme security 'petstore_auth'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// CL: removing a security scope from an API endpoint security
// CL: removing a security scope from an API endpoint security: api-security-scope-removed
func TestAPISecurityScopeRemoved(t *testing.T) {
s1, err := open("../data/checker/api_security_updated_base.yaml")
require.NoError(t, err)
Expand All @@ -150,10 +150,10 @@ func TestAPISecurityScopeRemoved(t *testing.T) {
Path: "/subscribe",
Source: load.NewSource("../data/checker/api_security_updated_revision.yaml"),
}, errs[0])
require.Equal(t, "the security scope 'read:pets' was removed from the endpoint's security scheme 'petstore_auth'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
require.Equal(t, "removed security scope 'read:pets' from endpoint security scheme 'petstore_auth'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// CL: adding a security scope to an API endpoint security
// CL: adding a security scope to an API endpoint security: api-security-scope-added
func TestAPISecurityScopeAdded(t *testing.T) {
s1, err := open("../data/checker/api_security_updated_revision.yaml")
require.NoError(t, err)
Expand All @@ -172,5 +172,5 @@ func TestAPISecurityScopeAdded(t *testing.T) {
Path: "/subscribe",
Source: load.NewSource("../data/checker/api_security_updated_base.yaml"),
}, errs[0])
require.Equal(t, "the security scope 'read:pets' was added to the endpoint's security scheme 'petstore_auth'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
require.Equal(t, "security scope 'read:pets' was added to endpoint security scheme 'petstore_auth'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}
8 changes: 4 additions & 4 deletions checker/check_api_sunset_changed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/tufin/oasdiff/diff"
)

// BC: deleting sunset header for a deprecated endpoint is breaking
// BC: deleting sunset header for a deprecated endpoint is breaking: sunset-deleted
func TestBreaking_SunsetDeletedForDeprecatedEndpoint(t *testing.T) {

s1, err := open(getDeprecationFile("deprecated-with-sunset.yaml"))
Expand All @@ -26,7 +26,7 @@ func TestBreaking_SunsetDeletedForDeprecatedEndpoint(t *testing.T) {
require.Equal(t, "api sunset date deleted, but deprecated=true kept", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// BC: changing sunset to an earlier date for a deprecated endpoint with a deprecation policy is breaking
// BC: changing sunset to an earlier date for a deprecated endpoint with a deprecation policy is breaking: api-sunset-date-changed-too-small
func TestBreaking_SunsetModifiedForDeprecatedEndpoint(t *testing.T) {

s1, err := open(getDeprecationFile("deprecated-future.yaml"))
Expand All @@ -44,7 +44,7 @@ func TestBreaking_SunsetModifiedForDeprecatedEndpoint(t *testing.T) {
require.Equal(t, "api sunset date changed to earlier date from '9999-08-10' to '2022-08-10', new sunset date must be not earlier than '9999-08-10' at least '180' days from now", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// BC: changing sunset to an invalid date for a deprecated endpoint is breaking
// BC: changing sunset to an invalid date for a deprecated endpoint is breaking: api-path-sunset-parse
func TestBreaking_SunsetModifiedToInvalidForDeprecatedEndpoint(t *testing.T) {

s1, err := open(getDeprecationFile("deprecated-future.yaml"))
Expand All @@ -62,7 +62,7 @@ func TestBreaking_SunsetModifiedToInvalidForDeprecatedEndpoint(t *testing.T) {
require.Equal(t, "failed to parse sunset date: 'sunset date doesn't conform with RFC3339: invalid-date'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// BC: changing sunset from an invalid date for a deprecated endpoint is breaking
// BC: changing sunset from an invalid date for a deprecated endpoint is breaking: api-path-sunset-parse
func TestBreaking_SunsetModifiedFromInvalidForDeprecatedEndpoint(t *testing.T) {

s1, err := open(getDeprecationFile("deprecated-invalid.yaml"))
Expand Down
10 changes: 5 additions & 5 deletions checker/check_api_tag_updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/tufin/oasdiff/load"
)

// CL: adding a new tag
// CL: adding a new tag: api-tag-added
func TestTagAdded(t *testing.T) {
s1, err := open("../data/checker/tag_added_base.yaml")
require.NoError(t, err)
Expand All @@ -31,10 +31,10 @@ func TestTagAdded(t *testing.T) {
Source: load.NewSource("../data/checker/tag_added_base.yaml"),
OperationId: "createOneGroup",
}, errs[0])
require.Equal(t, "api tag 'newTag' added", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
require.Equal(t, "added api tag 'newTag'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
}

// CL: removing an existing tag
// CL: removing an existing tag: api-tag-removed
func TestTagRemoved(t *testing.T) {
s1, err := open("../data/checker/tag_removed_base.yaml")
require.NoError(t, err)
Expand All @@ -57,11 +57,11 @@ func TestTagRemoved(t *testing.T) {
Source: load.NewSource("../data/checker/tag_removed_base.yaml"),
OperationId: "createOneGroup",
}, errs[0])
require.Equal(t, "api tag 'Test' removed", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))
require.Equal(t, "removed api tag 'Test'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer()))

}

// CL: updating an existing tag
// CL: updating an existing tag: api-tag-removed, api-tag-added
func TestTagUpdated(t *testing.T) {
s1, err := open("../data/checker/tag_removed_base.yaml")
require.NoError(t, err)
Expand Down
Loading
Loading