mirror of
https://github.com/hanzoai/ca.git
synced 2026-11-03 18:08:27 +00:00
96 lines
2.2 KiB
Go
96 lines
2.2 KiB
Go
// Code generated by protoc-gen-go-mock. DO NOT EDIT.
|
|
// source: cis.proto
|
|
|
|
package mockpb
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/effective-security/trustyca/api/pb"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// MockCISServer for testing
|
|
type MockCISServer struct {
|
|
pb.CISServer
|
|
|
|
Reqs []proto.Message
|
|
|
|
// If set, all calls return this error.
|
|
Err error
|
|
|
|
// responses to return if err == nil
|
|
Resps []proto.Message
|
|
Index int
|
|
}
|
|
|
|
// SetResponse sets a single response without errors
|
|
func (m *MockCISServer) SetResponse(r proto.Message) {
|
|
m.Err = nil
|
|
m.Resps = []proto.Message{r}
|
|
m.Index = 0
|
|
}
|
|
|
|
// SetResponses sets responses without errors
|
|
func (m *MockCISServer) SetResponses(r []proto.Message) {
|
|
m.Err = nil
|
|
m.Resps = r
|
|
m.Index = 0
|
|
}
|
|
|
|
func (m *MockCISServer) next() proto.Message {
|
|
c := len(m.Resps)
|
|
idx := m.Index
|
|
m.Index++
|
|
if idx >= c {
|
|
idx = c - 1
|
|
}
|
|
return m.Resps[idx]
|
|
}
|
|
|
|
// GetRoots returns the published trust anchors
|
|
|
|
func (m *MockCISServer) GetRoots(ctx context.Context, req *pb.GetRootsRequest) (*pb.RootsResponse, error) {
|
|
if m.Err != nil {
|
|
return nil, m.Err
|
|
}
|
|
return m.next().(*pb.RootsResponse), nil
|
|
}
|
|
|
|
// GetIssuer returns the issuer chain and status by IKID
|
|
|
|
func (m *MockCISServer) GetIssuer(ctx context.Context, req *pb.GetIssuerInfoRequest) (*pb.IssuerInfo, error) {
|
|
if m.Err != nil {
|
|
return nil, m.Err
|
|
}
|
|
return m.next().(*pb.IssuerInfo), nil
|
|
}
|
|
|
|
// GetCertificate returns the certificate by ID, SKID, Sha256 or issuer
|
|
// and serial number
|
|
|
|
func (m *MockCISServer) GetCertificate(ctx context.Context, req *pb.GetCertificateInfoRequest) (*pb.CertificateResponse, error) {
|
|
if m.Err != nil {
|
|
return nil, m.Err
|
|
}
|
|
return m.next().(*pb.CertificateResponse), nil
|
|
}
|
|
|
|
// GetCertificateStatus returns the revocation status of a certificate
|
|
|
|
func (m *MockCISServer) GetCertificateStatus(ctx context.Context, req *pb.GetCertificateInfoRequest) (*pb.CertificateStatusResponse, error) {
|
|
if m.Err != nil {
|
|
return nil, m.Err
|
|
}
|
|
return m.next().(*pb.CertificateStatusResponse), nil
|
|
}
|
|
|
|
// GetCRL returns the current CRL of the issuer in PEM format
|
|
|
|
func (m *MockCISServer) GetCRL(ctx context.Context, req *pb.GetCrlRequest) (*pb.CrlResponse, error) {
|
|
if m.Err != nil {
|
|
return nil, m.Err
|
|
}
|
|
return m.next().(*pb.CrlResponse), nil
|
|
}
|