mirror of
https://github.com/hanzoai/ca.git
synced 2026-11-03 18:08:27 +00:00
126 lines
3.1 KiB
Go
126 lines
3.1 KiB
Go
// Code generated by protoc-gen-go-mock. DO NOT EDIT.
|
|
// source: admin.proto
|
|
|
|
package mockpb
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/effective-security/trustyca/api/pb"
|
|
"github.com/effective-security/trustyca/privpb"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// MockAdminServer for testing
|
|
type MockAdminServer struct {
|
|
privpb.AdminServer
|
|
|
|
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 *MockAdminServer) SetResponse(r proto.Message) {
|
|
m.Err = nil
|
|
m.Resps = []proto.Message{r}
|
|
m.Index = 0
|
|
}
|
|
|
|
// SetResponses sets responses without errors
|
|
func (m *MockAdminServer) SetResponses(r []proto.Message) {
|
|
m.Err = nil
|
|
m.Resps = r
|
|
m.Index = 0
|
|
}
|
|
|
|
func (m *MockAdminServer) next() proto.Message {
|
|
c := len(m.Resps)
|
|
idx := m.Index
|
|
m.Index++
|
|
if idx >= c {
|
|
idx = c - 1
|
|
}
|
|
return m.Resps[idx]
|
|
}
|
|
|
|
// ListOrgs lists orgs
|
|
|
|
func (m *MockAdminServer) ListOrgs(ctx context.Context, req *privpb.ListOrgsRequest) (*pb.OrgsResponse, error) {
|
|
if m.Err != nil {
|
|
return nil, m.Err
|
|
}
|
|
return m.next().(*pb.OrgsResponse), nil
|
|
}
|
|
|
|
//
|
|
//// GetOrg returns an org with its budget
|
|
//rpc GetOrg(GetOrgRequest) returns (pb.Org) {
|
|
//option (google.api.http) = {
|
|
//post: "/privpb.Admin/GetOrganization",
|
|
//body: "*"
|
|
//};
|
|
//option (es.api.cli_cmd) = "org get";
|
|
//}
|
|
//// CreateOrg creates an org owned by an existing user
|
|
//rpc CreateOrg(CreateOrgRequest)
|
|
//returns (pb.Organization) {
|
|
//option (google.api.http) = {
|
|
//post: "/privpb.Admin/CreateOrganization",
|
|
//body: "*"
|
|
//};
|
|
//option (es.api.cli_cmd) = "org create";
|
|
//}
|
|
//// UpdateOrg updates an org
|
|
//rpc UpdateOrg(UpdateOrgRequest)
|
|
//returns (pb.Organization) {
|
|
//option (google.api.http) = {
|
|
//post: "/privpb.Admin/UpdateOrganization",
|
|
//body: "*"
|
|
//};
|
|
//option (es.api.cli_cmd) = "org update";
|
|
//}
|
|
//// DeleteOrg deletes an org that has no projects
|
|
//rpc DeleteOrg(DeleteOrgRequest)
|
|
//returns (google.protobuf.Empty) {
|
|
//option (google.api.http) = {
|
|
//post: "/privpb.Admin/DeleteOrganization",
|
|
//body: "*"
|
|
//};
|
|
//option (es.api.cli_cmd) = "org delete";
|
|
//}
|
|
|
|
func (m *MockAdminServer) ListProjects(ctx context.Context, req *privpb.ListProjectsRequest) (*pb.ProjectsResponse, error) {
|
|
if m.Err != nil {
|
|
return nil, m.Err
|
|
}
|
|
return m.next().(*pb.ProjectsResponse), nil
|
|
}
|
|
|
|
// ListIssuers lists the issuers of every org and of the platform, newest
|
|
// first, for support staff; the tenant view of an org is CA.ListIssuers.
|
|
// Private key material is never returned.
|
|
|
|
func (m *MockAdminServer) ListIssuers(ctx context.Context, req *privpb.ListAllIssuersRequest) (*pb.IssuersResponse, error) {
|
|
if m.Err != nil {
|
|
return nil, m.Err
|
|
}
|
|
return m.next().(*pb.IssuersResponse), nil
|
|
}
|
|
|
|
// ListCertificates lists the certificates of every org and of the
|
|
// platform, newest first, for support staff; the tenant view of an org
|
|
// is CA.ListCertificates
|
|
|
|
func (m *MockAdminServer) ListCertificates(ctx context.Context, req *privpb.ListAllCertificatesRequest) (*pb.CertificatesResponse, error) {
|
|
if m.Err != nil {
|
|
return nil, m.Err
|
|
}
|
|
return m.next().(*pb.CertificatesResponse), nil
|
|
}
|