Placeholder Plugin Providers for Repos and added testPlugin struct (#1532)
* Create minimalistic plugin map and test plugin. * Pass secrets and attributes to the plugin when creating catalogs or sets. Add tests for CreateSet and CreateCatalog repo methods. * make fmt and extract out getPrivateCatalog and getCatalog helper methods. * Exporting TestPluginServer so it can be used in the handlers. * Keep separate persisted data from host catalogs lookups which facilitate passing it onto the plugins. * Add TODO to merge get Catalog and get Persisted data. * Adding tests for unimplemented being returned by the plugin. * Use GetFields() instead of AsMap() to confirm attributes should be populated. Make clone consistent between catalog and sets. Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
This commit is contained in:
1 parent
ea939a4445
commit
bbfef2802f
30 files changed
+669
-227
No files matched your search
@@ -10,6 +10,8 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/plugin/host"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/structpb"
|
||||
)
|
||||
|
||||
func TestHostSet_Create(t *testing.T) {
|
||||
@@ -37,7 +39,7 @@ func TestHostSet_Create(t *testing.T) {
|
||||
catalogId: "",
|
||||
},
|
||||
want: &HostSet{HostSet: &store.HostSet{
|
||||
Attributes: []byte("{}"),
|
||||
Attributes: []byte{},
|
||||
}},
|
||||
wantErr: true,
|
||||
},
|
||||
@@ -49,7 +51,7 @@ func TestHostSet_Create(t *testing.T) {
|
||||
want: &HostSet{
|
||||
HostSet: &store.HostSet{
|
||||
CatalogId: cat.GetPublicId(),
|
||||
Attributes: []byte("{}"),
|
||||
Attributes: []byte{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -65,7 +67,7 @@ func TestHostSet_Create(t *testing.T) {
|
||||
HostSet: &store.HostSet{
|
||||
CatalogId: cat.GetPublicId(),
|
||||
Name: "test-name",
|
||||
Attributes: []byte("{}"),
|
||||
Attributes: []byte{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -81,7 +83,7 @@ func TestHostSet_Create(t *testing.T) {
|
||||
HostSet: &store.HostSet{
|
||||
CatalogId: cat.GetPublicId(),
|
||||
Name: "test-name",
|
||||
Attributes: []byte("{}"),
|
||||
Attributes: []byte{},
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
@@ -98,7 +100,7 @@ func TestHostSet_Create(t *testing.T) {
|
||||
HostSet: &store.HostSet{
|
||||
CatalogId: cat2.GetPublicId(),
|
||||
Name: "test-name",
|
||||
Attributes: []byte("{}"),
|
||||
Attributes: []byte{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -114,7 +116,7 @@ func TestHostSet_Create(t *testing.T) {
|
||||
HostSet: &store.HostSet{
|
||||
CatalogId: cat.GetPublicId(),
|
||||
Description: "test-description",
|
||||
Attributes: []byte("{}"),
|
||||
Attributes: []byte{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -123,13 +125,18 @@ func TestHostSet_Create(t *testing.T) {
|
||||
args: args{
|
||||
catalogId: cat.GetPublicId(),
|
||||
opts: []Option{
|
||||
WithAttributes(map[string]interface{}{"foo": "bar"}),
|
||||
WithAttributes(&structpb.Struct{Fields: map[string]*structpb.Value{"foo": structpb.NewStringValue("bar")}}),
|
||||
},
|
||||
},
|
||||
want: &HostSet{
|
||||
HostSet: &store.HostSet{
|
||||
CatalogId: cat.GetPublicId(),
|
||||
Attributes: []byte(`{"foo":"bar"}`),
|
||||
CatalogId: cat.GetPublicId(),
|
||||
Attributes: func() []byte {
|
||||
st := &structpb.Struct{Fields: map[string]*structpb.Value{"foo": structpb.NewStringValue("bar")}}
|
||||
b, err := proto.Marshal(st)
|
||||
require.NoError(t, err)
|
||||
return b
|
||||
}(),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -145,7 +152,7 @@ func TestHostSet_Create(t *testing.T) {
|
||||
HostSet: &store.HostSet{
|
||||
CatalogId: cat.GetPublicId(),
|
||||
PreferredEndpoints: []string{"cidr:1.2.3.4"},
|
||||
Attributes: []byte("{}"),
|
||||
Attributes: []byte{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user