Check if sys view is missing in GRPC sys view (#18210)

And return an error instead of panicking.

This situation can occur if a plugin attempts to access the system
view during setup when Vault is checking the plugin metadata.

Fixes #17878.
This commit is contained in:
Christopher Swenson
2022-12-02 10:12:05 -08:00
committed by GitHub
parent 456ac93ce5
commit eabc486b1a
5 changed files with 73 additions and 3 deletions

View File

@@ -6,7 +6,7 @@ import (
"testing"
"time"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/vault/sdk/helper/consts"
"github.com/hashicorp/vault/sdk/logical"
"github.com/hashicorp/vault/sdk/plugin/pb"
@@ -14,6 +14,13 @@ import (
"google.golang.org/protobuf/proto"
)
func TestSystem_GRPC_ReturnsErrIfSystemViewNil(t *testing.T) {
_, err := new(gRPCSystemViewServer).ReplicationState(context.Background(), nil)
if err == nil {
t.Error("Expected error when using server with no impl")
}
}
func TestSystem_GRPC_GRPC_impl(t *testing.T) {
var _ logical.SystemView = new(gRPCSystemViewClient)
}