Cover all REST handlers with httptest-based tests using real SQLite: zones (list, get, create, update, delete), records (list, get, create, update, delete with validation/conflict cases), requireAdmin middleware (admin, non-admin, missing context), and utility functions (writeJSON, writeError, extractBearerToken, tokenInfoFromContext). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
278 lines
11 KiB
Go
278 lines
11 KiB
Go
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
// versions:
|
|
// - protoc-gen-go-grpc v1.6.1
|
|
// - protoc v6.32.1
|
|
// source: proto/mcns/v1/record.proto
|
|
|
|
package mcnsv1
|
|
|
|
import (
|
|
context "context"
|
|
grpc "google.golang.org/grpc"
|
|
codes "google.golang.org/grpc/codes"
|
|
status "google.golang.org/grpc/status"
|
|
)
|
|
|
|
// This is a compile-time assertion to ensure that this generated file
|
|
// is compatible with the grpc package it is being compiled against.
|
|
// Requires gRPC-Go v1.64.0 or later.
|
|
const _ = grpc.SupportPackageIsVersion9
|
|
|
|
const (
|
|
RecordService_ListRecords_FullMethodName = "/mcns.v1.RecordService/ListRecords"
|
|
RecordService_CreateRecord_FullMethodName = "/mcns.v1.RecordService/CreateRecord"
|
|
RecordService_GetRecord_FullMethodName = "/mcns.v1.RecordService/GetRecord"
|
|
RecordService_UpdateRecord_FullMethodName = "/mcns.v1.RecordService/UpdateRecord"
|
|
RecordService_DeleteRecord_FullMethodName = "/mcns.v1.RecordService/DeleteRecord"
|
|
)
|
|
|
|
// RecordServiceClient is the client API for RecordService service.
|
|
//
|
|
// 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.
|
|
//
|
|
// RecordService manages DNS records within zones.
|
|
type RecordServiceClient interface {
|
|
ListRecords(ctx context.Context, in *ListRecordsRequest, opts ...grpc.CallOption) (*ListRecordsResponse, error)
|
|
CreateRecord(ctx context.Context, in *CreateRecordRequest, opts ...grpc.CallOption) (*Record, error)
|
|
GetRecord(ctx context.Context, in *GetRecordRequest, opts ...grpc.CallOption) (*Record, error)
|
|
UpdateRecord(ctx context.Context, in *UpdateRecordRequest, opts ...grpc.CallOption) (*Record, error)
|
|
DeleteRecord(ctx context.Context, in *DeleteRecordRequest, opts ...grpc.CallOption) (*DeleteRecordResponse, error)
|
|
}
|
|
|
|
type recordServiceClient struct {
|
|
cc grpc.ClientConnInterface
|
|
}
|
|
|
|
func NewRecordServiceClient(cc grpc.ClientConnInterface) RecordServiceClient {
|
|
return &recordServiceClient{cc}
|
|
}
|
|
|
|
func (c *recordServiceClient) ListRecords(ctx context.Context, in *ListRecordsRequest, opts ...grpc.CallOption) (*ListRecordsResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(ListRecordsResponse)
|
|
err := c.cc.Invoke(ctx, RecordService_ListRecords_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *recordServiceClient) CreateRecord(ctx context.Context, in *CreateRecordRequest, opts ...grpc.CallOption) (*Record, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(Record)
|
|
err := c.cc.Invoke(ctx, RecordService_CreateRecord_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *recordServiceClient) GetRecord(ctx context.Context, in *GetRecordRequest, opts ...grpc.CallOption) (*Record, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(Record)
|
|
err := c.cc.Invoke(ctx, RecordService_GetRecord_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *recordServiceClient) UpdateRecord(ctx context.Context, in *UpdateRecordRequest, opts ...grpc.CallOption) (*Record, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(Record)
|
|
err := c.cc.Invoke(ctx, RecordService_UpdateRecord_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *recordServiceClient) DeleteRecord(ctx context.Context, in *DeleteRecordRequest, opts ...grpc.CallOption) (*DeleteRecordResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(DeleteRecordResponse)
|
|
err := c.cc.Invoke(ctx, RecordService_DeleteRecord_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
// RecordServiceServer is the server API for RecordService service.
|
|
// All implementations must embed UnimplementedRecordServiceServer
|
|
// for forward compatibility.
|
|
//
|
|
// RecordService manages DNS records within zones.
|
|
type RecordServiceServer interface {
|
|
ListRecords(context.Context, *ListRecordsRequest) (*ListRecordsResponse, error)
|
|
CreateRecord(context.Context, *CreateRecordRequest) (*Record, error)
|
|
GetRecord(context.Context, *GetRecordRequest) (*Record, error)
|
|
UpdateRecord(context.Context, *UpdateRecordRequest) (*Record, error)
|
|
DeleteRecord(context.Context, *DeleteRecordRequest) (*DeleteRecordResponse, error)
|
|
mustEmbedUnimplementedRecordServiceServer()
|
|
}
|
|
|
|
// UnimplementedRecordServiceServer must be embedded to have
|
|
// forward compatible implementations.
|
|
//
|
|
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
|
// pointer dereference when methods are called.
|
|
type UnimplementedRecordServiceServer struct{}
|
|
|
|
func (UnimplementedRecordServiceServer) ListRecords(context.Context, *ListRecordsRequest) (*ListRecordsResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method ListRecords not implemented")
|
|
}
|
|
func (UnimplementedRecordServiceServer) CreateRecord(context.Context, *CreateRecordRequest) (*Record, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method CreateRecord not implemented")
|
|
}
|
|
func (UnimplementedRecordServiceServer) GetRecord(context.Context, *GetRecordRequest) (*Record, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method GetRecord not implemented")
|
|
}
|
|
func (UnimplementedRecordServiceServer) UpdateRecord(context.Context, *UpdateRecordRequest) (*Record, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method UpdateRecord not implemented")
|
|
}
|
|
func (UnimplementedRecordServiceServer) DeleteRecord(context.Context, *DeleteRecordRequest) (*DeleteRecordResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method DeleteRecord not implemented")
|
|
}
|
|
func (UnimplementedRecordServiceServer) mustEmbedUnimplementedRecordServiceServer() {}
|
|
func (UnimplementedRecordServiceServer) testEmbeddedByValue() {}
|
|
|
|
// UnsafeRecordServiceServer may be embedded to opt out of forward compatibility for this service.
|
|
// Use of this interface is not recommended, as added methods to RecordServiceServer will
|
|
// result in compilation errors.
|
|
type UnsafeRecordServiceServer interface {
|
|
mustEmbedUnimplementedRecordServiceServer()
|
|
}
|
|
|
|
func RegisterRecordServiceServer(s grpc.ServiceRegistrar, srv RecordServiceServer) {
|
|
// If the following call panics, it indicates UnimplementedRecordServiceServer was
|
|
// embedded by pointer and is nil. This will cause panics if an
|
|
// unimplemented method is ever invoked, so we test this at initialization
|
|
// time to prevent it from happening at runtime later due to I/O.
|
|
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
|
t.testEmbeddedByValue()
|
|
}
|
|
s.RegisterService(&RecordService_ServiceDesc, srv)
|
|
}
|
|
|
|
func _RecordService_ListRecords_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(ListRecordsRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(RecordServiceServer).ListRecords(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: RecordService_ListRecords_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(RecordServiceServer).ListRecords(ctx, req.(*ListRecordsRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _RecordService_CreateRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(CreateRecordRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(RecordServiceServer).CreateRecord(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: RecordService_CreateRecord_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(RecordServiceServer).CreateRecord(ctx, req.(*CreateRecordRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _RecordService_GetRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(GetRecordRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(RecordServiceServer).GetRecord(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: RecordService_GetRecord_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(RecordServiceServer).GetRecord(ctx, req.(*GetRecordRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _RecordService_UpdateRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(UpdateRecordRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(RecordServiceServer).UpdateRecord(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: RecordService_UpdateRecord_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(RecordServiceServer).UpdateRecord(ctx, req.(*UpdateRecordRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _RecordService_DeleteRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(DeleteRecordRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(RecordServiceServer).DeleteRecord(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: RecordService_DeleteRecord_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(RecordServiceServer).DeleteRecord(ctx, req.(*DeleteRecordRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
// RecordService_ServiceDesc is the grpc.ServiceDesc for RecordService service.
|
|
// It's only intended for direct use with grpc.RegisterService,
|
|
// and not to be introspected or modified (even as a copy)
|
|
var RecordService_ServiceDesc = grpc.ServiceDesc{
|
|
ServiceName: "mcns.v1.RecordService",
|
|
HandlerType: (*RecordServiceServer)(nil),
|
|
Methods: []grpc.MethodDesc{
|
|
{
|
|
MethodName: "ListRecords",
|
|
Handler: _RecordService_ListRecords_Handler,
|
|
},
|
|
{
|
|
MethodName: "CreateRecord",
|
|
Handler: _RecordService_CreateRecord_Handler,
|
|
},
|
|
{
|
|
MethodName: "GetRecord",
|
|
Handler: _RecordService_GetRecord_Handler,
|
|
},
|
|
{
|
|
MethodName: "UpdateRecord",
|
|
Handler: _RecordService_UpdateRecord_Handler,
|
|
},
|
|
{
|
|
MethodName: "DeleteRecord",
|
|
Handler: _RecordService_DeleteRecord_Handler,
|
|
},
|
|
},
|
|
Streams: []grpc.StreamDesc{},
|
|
Metadata: "proto/mcns/v1/record.proto",
|
|
}
|