Removes old discovery hack ignoring 403 and 404

Kubernetes-commit: 298cb361c85be02d6336437bde37c8a4ccf5583a
This commit is contained in:
Sean Sullivan
2023-02-17 12:47:05 -08:00
committed by Kubernetes Publisher
parent 02d652e007
commit bc1864f6cf
3 changed files with 115 additions and 56 deletions

View File

@@ -65,6 +65,22 @@ func TestServerSupportsVersion(t *testing.T) {
expectErr: func(err error) bool { return strings.Contains(err.Error(), `server does not support API version "v1"`) },
statusCode: http.StatusOK,
},
{
name: "Status 403 Forbidden for core/v1 group returns error and is unsupported",
requiredVersion: schema.GroupVersion{Version: "v1"},
serverVersions: []string{"/version1", v1.SchemeGroupVersion.String()},
expectErr: func(err error) bool { return strings.Contains(err.Error(), "unknown") },
statusCode: http.StatusForbidden,
},
{
name: "Status 404 Not Found for core/v1 group returns empty and is unsupported",
requiredVersion: schema.GroupVersion{Version: "v1"},
serverVersions: []string{"/version1", v1.SchemeGroupVersion.String()},
expectErr: func(err error) bool {
return strings.Contains(err.Error(), "server could not find the requested resource")
},
statusCode: http.StatusNotFound,
},
{
name: "connection refused error",
serverVersions: []string{"version1"},
@@ -72,11 +88,6 @@ func TestServerSupportsVersion(t *testing.T) {
expectErr: func(err error) bool { return strings.Contains(err.Error(), "connection refused") },
statusCode: http.StatusOK,
},
{
name: "discovery fails due to 404 Not Found errors and thus serverVersions is empty, use requested GroupVersion",
requiredVersion: schema.GroupVersion{Version: "version1"},
statusCode: http.StatusNotFound,
},
}
for _, test := range tests {