Skip to content
Snippets Groups Projects
Commit cb0fa51f authored by Malte Bauch's avatar Malte Bauch
Browse files

Update plugin-internal.proto and auth_interceptor tests

parent a89c5a52
No related branches found
No related tags found
1 merge request!401Change the current gosdn plugin implementation from Go's internal plugin system to hashicorp's go-plugins
Pipeline #129494 failed
...@@ -123,7 +123,7 @@ func (x *GetAvailablePluginsResponse) GetPlugins() []*plugin_registry.Plugin { ...@@ -123,7 +123,7 @@ func (x *GetAvailablePluginsResponse) GetPlugins() []*plugin_registry.Plugin {
return nil return nil
} }
type PluginSchemaRequest struct { type GetPluginSchemaRequest struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
...@@ -132,8 +132,8 @@ type PluginSchemaRequest struct { ...@@ -132,8 +132,8 @@ type PluginSchemaRequest struct {
Pid string `protobuf:"bytes,2,opt,name=pid,proto3" json:"pid,omitempty"` Pid string `protobuf:"bytes,2,opt,name=pid,proto3" json:"pid,omitempty"`
} }
func (x *PluginSchemaRequest) Reset() { func (x *GetPluginSchemaRequest) Reset() {
*x = PluginSchemaRequest{} *x = GetPluginSchemaRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_gosdn_plugin_internal_plugin_internal_proto_msgTypes[2] mi := &file_gosdn_plugin_internal_plugin_internal_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
...@@ -141,13 +141,13 @@ func (x *PluginSchemaRequest) Reset() { ...@@ -141,13 +141,13 @@ func (x *PluginSchemaRequest) Reset() {
} }
} }
func (x *PluginSchemaRequest) String() string { func (x *GetPluginSchemaRequest) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*PluginSchemaRequest) ProtoMessage() {} func (*GetPluginSchemaRequest) ProtoMessage() {}
func (x *PluginSchemaRequest) ProtoReflect() protoreflect.Message { func (x *GetPluginSchemaRequest) ProtoReflect() protoreflect.Message {
mi := &file_gosdn_plugin_internal_plugin_internal_proto_msgTypes[2] mi := &file_gosdn_plugin_internal_plugin_internal_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
...@@ -159,19 +159,19 @@ func (x *PluginSchemaRequest) ProtoReflect() protoreflect.Message { ...@@ -159,19 +159,19 @@ func (x *PluginSchemaRequest) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use PluginSchemaRequest.ProtoReflect.Descriptor instead. // Deprecated: Use GetPluginSchemaRequest.ProtoReflect.Descriptor instead.
func (*PluginSchemaRequest) Descriptor() ([]byte, []int) { func (*GetPluginSchemaRequest) Descriptor() ([]byte, []int) {
return file_gosdn_plugin_internal_plugin_internal_proto_rawDescGZIP(), []int{2} return file_gosdn_plugin_internal_plugin_internal_proto_rawDescGZIP(), []int{2}
} }
func (x *PluginSchemaRequest) GetTimestamp() int64 { func (x *GetPluginSchemaRequest) GetTimestamp() int64 {
if x != nil { if x != nil {
return x.Timestamp return x.Timestamp
} }
return 0 return 0
} }
func (x *PluginSchemaRequest) GetPid() string { func (x *GetPluginSchemaRequest) GetPid() string {
if x != nil { if x != nil {
return x.Pid return x.Pid
} }
...@@ -246,33 +246,34 @@ var file_gosdn_plugin_internal_plugin_internal_proto_rawDesc = []byte{ ...@@ -246,33 +246,34 @@ var file_gosdn_plugin_internal_plugin_internal_proto_rawDesc = []byte{
0x75, 0x67, 0x69, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6f, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6f,
0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73,
0x74, 0x72, 0x79, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x74, 0x72, 0x79, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x07, 0x70, 0x6c, 0x75, 0x67,
0x69, 0x6e, 0x73, 0x22, 0x45, 0x0a, 0x13, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x69, 0x6e, 0x73, 0x22, 0x48, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e,
0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a,
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x70,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x69, 0x64, 0x22, 0x2b, 0x0a, 0x13, 0x50, 0x6c, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x69, 0x64, 0x22, 0x2b, 0x0a,
0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x13, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x61, 0x79,
0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x01, 0x20,
0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x32, 0xec, 0x01, 0x0a, 0x15, 0x50, 0x6c, 0x75, 0x67, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x32, 0xf2, 0x01, 0x0a, 0x15, 0x50,
0x69, 0x6e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x53, 0x65, 0x72,
0x65, 0x12, 0x69, 0x0a, 0x10, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x76, 0x69, 0x63, 0x65, 0x12, 0x69, 0x0a, 0x10, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c,
0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x31, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x31, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e,
0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x47, 0x65,
0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e,
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e,
0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79,
0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, 0x0a, 0x0c,
0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x2a, 0x2e, 0x67,
0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x74, 0x65,
0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d,
0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e,
0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c,
0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x61, 0x79, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x75,
0x6c, 0x6f, 0x61, 0x64, 0x30, 0x01, 0x42, 0x3b, 0x5a, 0x39, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x66, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x67, 0x6f,
0x62, 0x69, 0x2e, 0x68, 0x2d, 0x64, 0x61, 0x2e, 0x64, 0x65, 0x2f, 0x64, 0x61, 0x6e, 0x65, 0x74, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73,
0x2f, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x6f, 0x74, 0x72, 0x79, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x73, 0x64, 0x6e, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65,
0x6e, 0x61, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x6d, 0x61, 0x12, 0x2d, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69,
0x6e, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6c,
0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x2a, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e,
0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e,
0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x30, 0x01, 0x42,
0x3b, 0x5a, 0x39, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x66, 0x62, 0x69, 0x2e, 0x68, 0x2d, 0x64, 0x61,
0x2e, 0x64, 0x65, 0x2f, 0x64, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f,
0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x70, 0x6c, 0x75,
0x67, 0x69, 0x6e, 0x2d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
...@@ -291,7 +292,7 @@ var file_gosdn_plugin_internal_plugin_internal_proto_msgTypes = make([]protoimpl ...@@ -291,7 +292,7 @@ var file_gosdn_plugin_internal_plugin_internal_proto_msgTypes = make([]protoimpl
var file_gosdn_plugin_internal_plugin_internal_proto_goTypes = []interface{}{ var file_gosdn_plugin_internal_plugin_internal_proto_goTypes = []interface{}{
(*GetAvailablePluginsRequest)(nil), // 0: gosdn.plugin_internal.GetAvailablePluginsRequest (*GetAvailablePluginsRequest)(nil), // 0: gosdn.plugin_internal.GetAvailablePluginsRequest
(*GetAvailablePluginsResponse)(nil), // 1: gosdn.plugin_internal.GetAvailablePluginsResponse (*GetAvailablePluginsResponse)(nil), // 1: gosdn.plugin_internal.GetAvailablePluginsResponse
(*PluginSchemaRequest)(nil), // 2: gosdn.plugin_internal.PluginSchemaRequest (*GetPluginSchemaRequest)(nil), // 2: gosdn.plugin_internal.GetPluginSchemaRequest
(*PluginSchemaPayload)(nil), // 3: gosdn.plugin_internal.PluginSchemaPayload (*PluginSchemaPayload)(nil), // 3: gosdn.plugin_internal.PluginSchemaPayload
(*plugin_registry.Plugin)(nil), // 4: gosdn.plugin_registry.Plugin (*plugin_registry.Plugin)(nil), // 4: gosdn.plugin_registry.Plugin
(*plugin_registry.GetResponse)(nil), // 5: gosdn.plugin_registry.GetResponse (*plugin_registry.GetResponse)(nil), // 5: gosdn.plugin_registry.GetResponse
...@@ -299,9 +300,9 @@ var file_gosdn_plugin_internal_plugin_internal_proto_goTypes = []interface{}{ ...@@ -299,9 +300,9 @@ var file_gosdn_plugin_internal_plugin_internal_proto_goTypes = []interface{}{
var file_gosdn_plugin_internal_plugin_internal_proto_depIdxs = []int32{ var file_gosdn_plugin_internal_plugin_internal_proto_depIdxs = []int32{
4, // 0: gosdn.plugin_internal.GetAvailablePluginsResponse.plugins:type_name -> gosdn.plugin_registry.Plugin 4, // 0: gosdn.plugin_internal.GetAvailablePluginsResponse.plugins:type_name -> gosdn.plugin_registry.Plugin
0, // 1: gosdn.plugin_internal.PluginInternalService.AvailablePlugins:input_type -> gosdn.plugin_internal.GetAvailablePluginsRequest 0, // 1: gosdn.plugin_internal.PluginInternalService.AvailablePlugins:input_type -> gosdn.plugin_internal.GetAvailablePluginsRequest
2, // 2: gosdn.plugin_internal.PluginInternalService.PluginSchema:input_type -> gosdn.plugin_internal.PluginSchemaRequest 2, // 2: gosdn.plugin_internal.PluginInternalService.GetPluginSchema:input_type -> gosdn.plugin_internal.GetPluginSchemaRequest
5, // 3: gosdn.plugin_internal.PluginInternalService.AvailablePlugins:output_type -> gosdn.plugin_registry.GetResponse 5, // 3: gosdn.plugin_internal.PluginInternalService.AvailablePlugins:output_type -> gosdn.plugin_registry.GetResponse
3, // 4: gosdn.plugin_internal.PluginInternalService.PluginSchema:output_type -> gosdn.plugin_internal.PluginSchemaPayload 3, // 4: gosdn.plugin_internal.PluginInternalService.GetPluginSchema:output_type -> gosdn.plugin_internal.PluginSchemaPayload
3, // [3:5] is the sub-list for method output_type 3, // [3:5] is the sub-list for method output_type
1, // [1:3] is the sub-list for method input_type 1, // [1:3] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension type_name
...@@ -340,7 +341,7 @@ func file_gosdn_plugin_internal_plugin_internal_proto_init() { ...@@ -340,7 +341,7 @@ func file_gosdn_plugin_internal_plugin_internal_proto_init() {
} }
} }
file_gosdn_plugin_internal_plugin_internal_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_gosdn_plugin_internal_plugin_internal_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PluginSchemaRequest); i { switch v := v.(*GetPluginSchemaRequest); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
......
...@@ -20,7 +20,7 @@ const _ = grpc.SupportPackageIsVersion7 ...@@ -20,7 +20,7 @@ const _ = grpc.SupportPackageIsVersion7
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type PluginInternalServiceClient interface { type PluginInternalServiceClient interface {
AvailablePlugins(ctx context.Context, in *GetAvailablePluginsRequest, opts ...grpc.CallOption) (*plugin_registry.GetResponse, error) AvailablePlugins(ctx context.Context, in *GetAvailablePluginsRequest, opts ...grpc.CallOption) (*plugin_registry.GetResponse, error)
PluginSchema(ctx context.Context, in *PluginSchemaRequest, opts ...grpc.CallOption) (PluginInternalService_PluginSchemaClient, error) GetPluginSchema(ctx context.Context, in *GetPluginSchemaRequest, opts ...grpc.CallOption) (PluginInternalService_GetPluginSchemaClient, error)
} }
type pluginInternalServiceClient struct { type pluginInternalServiceClient struct {
...@@ -40,12 +40,12 @@ func (c *pluginInternalServiceClient) AvailablePlugins(ctx context.Context, in * ...@@ -40,12 +40,12 @@ func (c *pluginInternalServiceClient) AvailablePlugins(ctx context.Context, in *
return out, nil return out, nil
} }
func (c *pluginInternalServiceClient) PluginSchema(ctx context.Context, in *PluginSchemaRequest, opts ...grpc.CallOption) (PluginInternalService_PluginSchemaClient, error) { func (c *pluginInternalServiceClient) GetPluginSchema(ctx context.Context, in *GetPluginSchemaRequest, opts ...grpc.CallOption) (PluginInternalService_GetPluginSchemaClient, error) {
stream, err := c.cc.NewStream(ctx, &PluginInternalService_ServiceDesc.Streams[0], "/gosdn.plugin_internal.PluginInternalService/PluginSchema", opts...) stream, err := c.cc.NewStream(ctx, &PluginInternalService_ServiceDesc.Streams[0], "/gosdn.plugin_internal.PluginInternalService/GetPluginSchema", opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
x := &pluginInternalServicePluginSchemaClient{stream} x := &pluginInternalServiceGetPluginSchemaClient{stream}
if err := x.ClientStream.SendMsg(in); err != nil { if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err return nil, err
} }
...@@ -55,16 +55,16 @@ func (c *pluginInternalServiceClient) PluginSchema(ctx context.Context, in *Plug ...@@ -55,16 +55,16 @@ func (c *pluginInternalServiceClient) PluginSchema(ctx context.Context, in *Plug
return x, nil return x, nil
} }
type PluginInternalService_PluginSchemaClient interface { type PluginInternalService_GetPluginSchemaClient interface {
Recv() (*PluginSchemaPayload, error) Recv() (*PluginSchemaPayload, error)
grpc.ClientStream grpc.ClientStream
} }
type pluginInternalServicePluginSchemaClient struct { type pluginInternalServiceGetPluginSchemaClient struct {
grpc.ClientStream grpc.ClientStream
} }
func (x *pluginInternalServicePluginSchemaClient) Recv() (*PluginSchemaPayload, error) { func (x *pluginInternalServiceGetPluginSchemaClient) Recv() (*PluginSchemaPayload, error) {
m := new(PluginSchemaPayload) m := new(PluginSchemaPayload)
if err := x.ClientStream.RecvMsg(m); err != nil { if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err return nil, err
...@@ -77,7 +77,7 @@ func (x *pluginInternalServicePluginSchemaClient) Recv() (*PluginSchemaPayload, ...@@ -77,7 +77,7 @@ func (x *pluginInternalServicePluginSchemaClient) Recv() (*PluginSchemaPayload,
// for forward compatibility // for forward compatibility
type PluginInternalServiceServer interface { type PluginInternalServiceServer interface {
AvailablePlugins(context.Context, *GetAvailablePluginsRequest) (*plugin_registry.GetResponse, error) AvailablePlugins(context.Context, *GetAvailablePluginsRequest) (*plugin_registry.GetResponse, error)
PluginSchema(*PluginSchemaRequest, PluginInternalService_PluginSchemaServer) error GetPluginSchema(*GetPluginSchemaRequest, PluginInternalService_GetPluginSchemaServer) error
mustEmbedUnimplementedPluginInternalServiceServer() mustEmbedUnimplementedPluginInternalServiceServer()
} }
...@@ -88,8 +88,8 @@ type UnimplementedPluginInternalServiceServer struct { ...@@ -88,8 +88,8 @@ type UnimplementedPluginInternalServiceServer struct {
func (UnimplementedPluginInternalServiceServer) AvailablePlugins(context.Context, *GetAvailablePluginsRequest) (*plugin_registry.GetResponse, error) { func (UnimplementedPluginInternalServiceServer) AvailablePlugins(context.Context, *GetAvailablePluginsRequest) (*plugin_registry.GetResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AvailablePlugins not implemented") return nil, status.Errorf(codes.Unimplemented, "method AvailablePlugins not implemented")
} }
func (UnimplementedPluginInternalServiceServer) PluginSchema(*PluginSchemaRequest, PluginInternalService_PluginSchemaServer) error { func (UnimplementedPluginInternalServiceServer) GetPluginSchema(*GetPluginSchemaRequest, PluginInternalService_GetPluginSchemaServer) error {
return status.Errorf(codes.Unimplemented, "method PluginSchema not implemented") return status.Errorf(codes.Unimplemented, "method GetPluginSchema not implemented")
} }
func (UnimplementedPluginInternalServiceServer) mustEmbedUnimplementedPluginInternalServiceServer() {} func (UnimplementedPluginInternalServiceServer) mustEmbedUnimplementedPluginInternalServiceServer() {}
...@@ -122,24 +122,24 @@ func _PluginInternalService_AvailablePlugins_Handler(srv interface{}, ctx contex ...@@ -122,24 +122,24 @@ func _PluginInternalService_AvailablePlugins_Handler(srv interface{}, ctx contex
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _PluginInternalService_PluginSchema_Handler(srv interface{}, stream grpc.ServerStream) error { func _PluginInternalService_GetPluginSchema_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(PluginSchemaRequest) m := new(GetPluginSchemaRequest)
if err := stream.RecvMsg(m); err != nil { if err := stream.RecvMsg(m); err != nil {
return err return err
} }
return srv.(PluginInternalServiceServer).PluginSchema(m, &pluginInternalServicePluginSchemaServer{stream}) return srv.(PluginInternalServiceServer).GetPluginSchema(m, &pluginInternalServiceGetPluginSchemaServer{stream})
} }
type PluginInternalService_PluginSchemaServer interface { type PluginInternalService_GetPluginSchemaServer interface {
Send(*PluginSchemaPayload) error Send(*PluginSchemaPayload) error
grpc.ServerStream grpc.ServerStream
} }
type pluginInternalServicePluginSchemaServer struct { type pluginInternalServiceGetPluginSchemaServer struct {
grpc.ServerStream grpc.ServerStream
} }
func (x *pluginInternalServicePluginSchemaServer) Send(m *PluginSchemaPayload) error { func (x *pluginInternalServiceGetPluginSchemaServer) Send(m *PluginSchemaPayload) error {
return x.ServerStream.SendMsg(m) return x.ServerStream.SendMsg(m)
} }
...@@ -157,8 +157,8 @@ var PluginInternalService_ServiceDesc = grpc.ServiceDesc{ ...@@ -157,8 +157,8 @@ var PluginInternalService_ServiceDesc = grpc.ServiceDesc{
}, },
Streams: []grpc.StreamDesc{ Streams: []grpc.StreamDesc{
{ {
StreamName: "PluginSchema", StreamName: "GetPluginSchema",
Handler: _PluginInternalService_PluginSchema_Handler, Handler: _PluginInternalService_GetPluginSchema_Handler,
ServerStreams: true, ServerStreams: true,
}, },
}, },
......
...@@ -8,7 +8,7 @@ option go_package = "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/plugin-internal"; ...@@ -8,7 +8,7 @@ option go_package = "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/plugin-internal";
service PluginInternalService { service PluginInternalService {
rpc AvailablePlugins(GetAvailablePluginsRequest) returns (gosdn.plugin_registry.GetResponse); rpc AvailablePlugins(GetAvailablePluginsRequest) returns (gosdn.plugin_registry.GetResponse);
rpc PluginSchema(PluginSchemaRequest) returns (stream PluginSchemaPayload); rpc GetPluginSchema(GetPluginSchemaRequest) returns (stream PluginSchemaPayload);
} }
message GetAvailablePluginsRequest { message GetAvailablePluginsRequest {
...@@ -20,7 +20,7 @@ message GetAvailablePluginsResponse { ...@@ -20,7 +20,7 @@ message GetAvailablePluginsResponse {
repeated gosdn.plugin_registry.Plugin plugins = 2; repeated gosdn.plugin_registry.Plugin plugins = 2;
} }
message PluginSchemaRequest { message GetPluginSchemaRequest {
int64 timestamp = 1; int64 timestamp = 1;
string pid = 2; string pid = 2;
} }
......
...@@ -14,8 +14,10 @@ import ( ...@@ -14,8 +14,10 @@ import (
"code.fbi.h-da.de/danet/gosdn/controller/nucleus" "code.fbi.h-da.de/danet/gosdn/controller/nucleus"
"code.fbi.h-da.de/danet/gosdn/controller/rbac" "code.fbi.h-da.de/danet/gosdn/controller/rbac"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/grpc/test/bufconn" "google.golang.org/grpc/test/bufconn"
) )
...@@ -178,6 +180,10 @@ func TestAuthInterceptor_Stream(t *testing.T) { ...@@ -178,6 +180,10 @@ func TestAuthInterceptor_Stream(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
tokenWithMissingRights, err := createTestUserToken("testUser", true, authServer.userService, authServer.jwtManager)
if err != nil {
t.Fatal(err)
}
ctx := context.Background() ctx := context.Background()
conn, err := grpc.DialContext( conn, err := grpc.DialContext(
...@@ -199,48 +205,74 @@ func TestAuthInterceptor_Stream(t *testing.T) { ...@@ -199,48 +205,74 @@ func TestAuthInterceptor_Stream(t *testing.T) {
type args struct { type args struct {
ctx context.Context ctx context.Context
request *pipb.PluginSchemaRequest request *pipb.GetPluginSchemaRequest
} }
tests := []struct { tests := []struct {
name string name string
args args args args
want bool statusCode codes.Code
wantErr bool
}{ }{
{ {
name: "default stream interceptor", name: "default stream interceptor",
args: args{ args: args{
ctx: metadata.NewOutgoingContext(context.Background(), metadata.Pairs("authorize", validToken)), ctx: metadata.NewOutgoingContext(context.Background(), metadata.Pairs("authorize", validToken)),
request: &pipb.PluginSchemaRequest{ request: &pipb.GetPluginSchemaRequest{
Pid: pluginID,
},
},
statusCode: codes.OK,
wantErr: false,
},
{
name: "user without sufficient rights",
args: args{
ctx: metadata.NewOutgoingContext(context.Background(), metadata.Pairs("authorize", tokenWithMissingRights)),
request: &pipb.GetPluginSchemaRequest{
Pid: pluginID, Pid: pluginID,
}, },
}, },
want: true, statusCode: codes.PermissionDenied,
wantErr: true,
}, },
{ {
name: "error stream interceptor", name: "user not authenticated",
args: args{ args: args{
ctx: metadata.NewOutgoingContext(context.Background(), metadata.Pairs("authorize", "foo")), ctx: metadata.NewOutgoingContext(context.Background(), metadata.Pairs("authorize", "foo")),
request: &pipb.PluginSchemaRequest{ request: &pipb.GetPluginSchemaRequest{
Pid: pluginID, Pid: pluginID,
}, },
}, },
want: false, statusCode: codes.Unauthenticated,
wantErr: true,
}, },
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
got, err := client.PluginSchema(tt.args.ctx, tt.args.request) got, err := client.GetPluginSchema(tt.args.ctx, tt.args.request)
if err != nil { if err != nil {
t.Errorf("AuthInterceptor.Stream() = %v", err) t.Errorf("AuthInterceptor.Stream() = %v", err)
return return
} }
payload, err := got.Recv() _, err = got.Recv()
if (payload != nil) != tt.want { if (err != nil) != tt.wantErr {
t.Errorf("AuthInterceptor.Stream() = %v", tt.want) t.Errorf("AuthInterceptor.Stream() = got error: %v, wantErr: %v", err, tt.wantErr)
return return
} }
if tt.wantErr {
statusCode, ok := status.FromError(err)
if !ok {
t.Errorf("AuthInterceptor.Stream() = %v", err)
return
}
if statusCode.Code() != tt.statusCode {
t.Errorf("AuthInterceptor.Stream() = got error with status code: %v, want: %v", statusCode.Code(), tt.statusCode)
return
}
}
}) })
} }
} }
......
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/plugin" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/plugin"
"code.fbi.h-da.de/danet/gosdn/controller/metrics" "code.fbi.h-da.de/danet/gosdn/controller/metrics"
"code.fbi.h-da.de/danet/gosdn/controller/store" "code.fbi.h-da.de/danet/gosdn/controller/store"
"github.com/google/uuid"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
...@@ -40,13 +41,13 @@ func (pis *PluginInternalServer) AvailablePlugins(ctx context.Context, request * ...@@ -40,13 +41,13 @@ func (pis *PluginInternalServer) AvailablePlugins(ctx context.Context, request *
return pis.pluginRegistryClient.GetAll(ctx, getAllRequest) return pis.pluginRegistryClient.GetAll(ctx, getAllRequest)
} }
func (pis *PluginInternalServer) GetPluginSchema(ctx context.Context, stream pipb.PluginInternalService_PluginSchemaServer) error { func (pis *PluginInternalServer) GetPluginSchema(request *pipb.GetPluginSchemaRequest, stream pipb.PluginInternalService_GetPluginSchemaServer) error {
labels := prometheus.Labels{"service": "plugin", "rpc": "get plugin schema"} labels := prometheus.Labels{"service": "plugin", "rpc": "get plugin schema"}
start := metrics.StartHook(labels, grpcRequestsTotal) start := metrics.StartHook(labels, grpcRequestsTotal)
defer metrics.FinishHook(labels, start, grpcRequestDurationSecondsTotal, grpcRequestDurationSeconds) defer metrics.FinishHook(labels, start, grpcRequestDurationSecondsTotal, grpcRequestDurationSeconds)
buffer := make([]byte, int(MB)) buffer := make([]byte, int(MB))
plugin, err := pis.pluginService.Get(store.Query{}) plugin, err := pis.pluginService.Get(store.Query{ID: uuid.MustParse(request.GetPid())})
if err != nil { if err != nil {
return handleRPCError(labels, err) return handleRPCError(labels, err)
} }
......
...@@ -128,7 +128,7 @@ func createTestRoles(roleService rbacInterfaces.RoleService) error { ...@@ -128,7 +128,7 @@ func createTestRoles(roleService rbacInterfaces.RoleService) error {
"/gosdn.core.CoreService/GetPnd", "/gosdn.core.CoreService/GetPnd",
"/gosdn.core.CoreService/GetPndList", "/gosdn.core.CoreService/GetPndList",
"/gosdn.rbac.UserService/GetUsers", "/gosdn.rbac.UserService/GetUsers",
"/gosdn.plugin_internal.PluginInternalService/PluginSchema", "/gosdn.plugin_internal.PluginInternalService/GetPluginSchema",
}, },
}, },
{ {
...@@ -253,7 +253,7 @@ func getMockPlugin(t *testing.T) plugin.Plugin { ...@@ -253,7 +253,7 @@ func getMockPlugin(t *testing.T) plugin.Plugin {
mockPlugin := &mocks.Plugin{} mockPlugin := &mocks.Plugin{}
mockPlugin.On("ID").Return(pluginUUID) mockPlugin.On("ID").Return(pluginUUID)
mockPlugin.On("SchemaTreeGzip").Return([]byte("schema_test")) mockPlugin.On("SchemaTreeGzip").Return([]byte("schema_test"), nil)
return mockPlugin return mockPlugin
} }
......
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
"os" "os"
"code.fbi.h-da.de/danet/gosdn/controller/plugin/shared" "code.fbi.h-da.de/danet/gosdn/controller/plugin/shared"
generated "code.fbi.h-da.de/danet/gosdn/plugins/openconfig/generated" generated "code.fbi.h-da.de/danet/gosdn/plugins/examples/openconfig/generated"
"code.fbi.h-da.de/danet/gosdn/plugins/sdk" "code.fbi.h-da.de/danet/gosdn/plugins/sdk"
"github.com/hashicorp/go-plugin" "github.com/hashicorp/go-plugin"
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment