Provisioning: Add inline secure values to repository schema (#109594)
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/version"
|
||||
apimachineryversion "k8s.io/apimachinery/pkg/version"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/tests/testinfra"
|
||||
@@ -38,18 +36,9 @@ func TestIntegrationOpenAPIs(t *testing.T) {
|
||||
|
||||
t.Run("check valid version response", func(t *testing.T) {
|
||||
disco := h.NewDiscoveryClient()
|
||||
req := disco.RESTClient().Get().
|
||||
Prefix("version").
|
||||
SetHeader("Accept", "application/json")
|
||||
|
||||
result := req.Do(context.Background())
|
||||
require.NoError(t, result.Error())
|
||||
|
||||
raw, err := result.Raw()
|
||||
require.NoError(t, err)
|
||||
info := apimachineryversion.Info{}
|
||||
err = json.Unmarshal(raw, &info)
|
||||
info, err := disco.ServerVersion()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, runtime.Version(), info.GoVersion)
|
||||
|
||||
// Make sure the gitVersion is parsable
|
||||
v, err := version.Parse(info.GitVersion)
|
||||
@@ -57,10 +46,15 @@ func TestIntegrationOpenAPIs(t *testing.T) {
|
||||
require.Equal(t, info.Major, fmt.Sprintf("%d", v.Major()))
|
||||
require.Equal(t, info.Minor, fmt.Sprintf("%d", v.Minor()))
|
||||
|
||||
// Check that OpenAPI v2 (used by kubectl) returns properly
|
||||
v2, err := disco.OpenAPISchema()
|
||||
require.NoError(t, err, "requesting OpenAPI v2")
|
||||
require.Equal(t, "Grafana API Server", v2.Info.Title)
|
||||
// Check the v3 path resolves properly
|
||||
// NOTE: fetching the v2 schema sometimes returns a 503 in our test infrastructure
|
||||
// Removing the explicit `OneOf` properties from InlineSecureValue in:
|
||||
// https://github.com/grafana/grafana/blob/main/pkg/apimachinery/apis/common/v0alpha1/secure_values.go#L78
|
||||
// will consistently support V2, however kubectl and everything else continues to work
|
||||
paths, err := disco.OpenAPIV3().Paths()
|
||||
|
||||
require.NoError(t, err, "requesting OpenAPI v3")
|
||||
require.NotEmpty(t, paths, "has registered paths")
|
||||
})
|
||||
|
||||
dir := "openapi_snapshots"
|
||||
|
||||
Reference in New Issue
Block a user