Commit 9903de71 authored by Caro Axel's avatar Caro Axel Committed by Loïck Bonniot
Browse files

[Platform] Add protobuf definitions

parent c46537b3
Pipeline #190 passed with stage
before_script:
- go version
stages:
- test
Unit tests:
stage: test
tags:
- golang
- mongo # Require an available mongo service
- strong # Disable this build on small runners
services:
- "lesterpig/mongo:latest" # Use this light version of mongo
- "lesterpig/postfix:latest"
artifacts:
paths:
- "coverage.html"
script:
- "ln -s $(pwd) $GOPATH/src/dfss"
- "./build/deps.sh"
- "go test -coverprofile auth.part -v dfss/auth"
- "go test -coverprofile mgdb.part -v dfss/mgdb"
- "go test -coverprofile mails.part -v dfss/mails"
- "go test -coverprofile authority.part -v dfss/dfssp/authority"
- "echo 'mode: set' *part > c.out"
- "grep -h -v 'mode: set' *part >> c.out"
- "go tool cover -html=c.out -o coverage.html"
ARM tests:
stage: test
tags:
- arm
script:
- "ln -s -f $(pwd) $GOPATH/src/dfss"
- "./build/deps.sh"
- "go test -cover -short -v dfss/auth"
- "go test -cover -short -v dfss/mgdb"
- "go test -cover -short -v dfss/dfssp/authority"
Code lint:
stage: test
allow_failure: True
tags:
- golang
- lint
script:
- "ln -s $(pwd) $GOPATH/src/dfss"
- "go get github.com/alecthomas/gometalinter"
- "./build/deps.sh"
- "go install ./..."
- "gometalinter --install"
<<<<<<< HEAD
- "gometalinter -t --deadline=300s -j1 --skip=api --skip=fixtures ./..."
=======
- "gometalinter -t --deadline=100s -j1 --skip=api ./..."
>>>>>>> 725843f... Fix lint test script
all:
protoc --go_out=plugins=grpc:. gRPCServices.proto
package api
const (
// INTERR is the error code for an internal server error
INTERR = -1
// SUCCESS is the error code for a successful requeset
SUCCESS = 0
// INVARG is the error code for an invalid argument
INVARG = 1
)
// Code generated by protoc-gen-go.
// source: gRPCServices.proto
// DO NOT EDIT!
/*
Package api is a generated protocol buffer package.
It is generated from these files:
gRPCServices.proto
It has these top-level messages:
RegisterRequest
ErrorCode
AuthRequest
RegisteredUser
Empty
PostContractRequest
JoinSignatureRequest
ReadySignRequest
*/
package api
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import (
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
const _ = proto.ProtoPackageIsVersion1
// RegisterRequest message contains the client's email adress and his
// public key
type RegisterRequest struct {
Email string `protobuf:"bytes,1,opt,name=email" json:"email,omitempty"`
Key string `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"`
}
func (m *RegisterRequest) Reset() { *m = RegisterRequest{} }
func (m *RegisterRequest) String() string { return proto.CompactTextString(m) }
func (*RegisterRequest) ProtoMessage() {}
func (*RegisterRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
// ErrorCode message contains an error code (see dffs/dfssp/api/errorCodes.go)
// and a message
type ErrorCode struct {
Code int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"`
Message string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"`
}
func (m *ErrorCode) Reset() { *m = ErrorCode{} }
func (m *ErrorCode) String() string { return proto.CompactTextString(m) }
func (*ErrorCode) ProtoMessage() {}
func (*ErrorCode) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
// AuthRequest message contains the client's email adress and the token used
// for authentication
type AuthRequest struct {
Email string `protobuf:"bytes,1,opt,name=email" json:"email,omitempty"`
Token string `protobuf:"bytes,2,opt,name=token" json:"token,omitempty"`
}
func (m *AuthRequest) Reset() { *m = AuthRequest{} }
func (m *AuthRequest) String() string { return proto.CompactTextString(m) }
func (*AuthRequest) ProtoMessage() {}
func (*AuthRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
// RegisteredUser message contains the generated client certificate
// and the CA root certificate (PEM-encoded)
type RegisteredUser struct {
RootCert []byte `protobuf:"bytes,1,opt,name=rootCert,proto3" json:"rootCert,omitempty"`
ClientCert []byte `protobuf:"bytes,2,opt,name=clientCert,proto3" json:"clientCert,omitempty"`
}
func (m *RegisteredUser) Reset() { *m = RegisteredUser{} }
func (m *RegisteredUser) String() string { return proto.CompactTextString(m) }
func (*RegisteredUser) ProtoMessage() {}
func (*RegisteredUser) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
// Empty message is an empty message
type Empty struct {
}
func (m *Empty) Reset() { *m = Empty{} }
func (m *Empty) String() string { return proto.CompactTextString(m) }
func (*Empty) ProtoMessage() {}
func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
// PostContractRequest message contains the contract as SHA-512 hash, the list of signers
// as an array of string, and a comment
type PostContractRequest struct {
Contract string `protobuf:"bytes,1,opt,name=contract" json:"contract,omitempty"`
Signer []string `protobuf:"bytes,2,rep,name=signer" json:"signer,omitempty"`
Comment string `protobuf:"bytes,3,opt,name=comment" json:"comment,omitempty"`
}
func (m *PostContractRequest) Reset() { *m = PostContractRequest{} }
func (m *PostContractRequest) String() string { return proto.CompactTextString(m) }
func (*PostContractRequest) ProtoMessage() {}
func (*PostContractRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
// JoinSignatureRequest message contains the contract to join unique identifier
// and the port the client will be listening at
type JoinSignatureRequest struct {
ContractUuid string `protobuf:"bytes,1,opt,name=contractUuid" json:"contractUuid,omitempty"`
Port uint32 `protobuf:"varint,2,opt,name=port" json:"port,omitempty"`
}
func (m *JoinSignatureRequest) Reset() { *m = JoinSignatureRequest{} }
func (m *JoinSignatureRequest) String() string { return proto.CompactTextString(m) }
func (*JoinSignatureRequest) ProtoMessage() {}
func (*JoinSignatureRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
// ReadySignRequest contains the contract unique identitier that is ready to be signed
type ReadySignRequest struct {
ContractUuid string `protobuf:"bytes,1,opt,name=contractUuid" json:"contractUuid,omitempty"`
}
func (m *ReadySignRequest) Reset() { *m = ReadySignRequest{} }
func (m *ReadySignRequest) String() string { return proto.CompactTextString(m) }
func (*ReadySignRequest) ProtoMessage() {}
func (*ReadySignRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
func init() {
proto.RegisterType((*RegisterRequest)(nil), "api.RegisterRequest")
proto.RegisterType((*ErrorCode)(nil), "api.ErrorCode")
proto.RegisterType((*AuthRequest)(nil), "api.AuthRequest")
proto.RegisterType((*RegisteredUser)(nil), "api.RegisteredUser")
proto.RegisterType((*Empty)(nil), "api.Empty")
proto.RegisterType((*PostContractRequest)(nil), "api.PostContractRequest")
proto.RegisterType((*JoinSignatureRequest)(nil), "api.JoinSignatureRequest")
proto.RegisterType((*ReadySignRequest)(nil), "api.ReadySignRequest")
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// Client API for Platform service
type PlatformClient interface {
Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*ErrorCode, error)
Auth(ctx context.Context, in *AuthRequest, opts ...grpc.CallOption) (*RegisteredUser, error)
Unregister(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ErrorCode, error)
PostContract(ctx context.Context, in *PostContractRequest, opts ...grpc.CallOption) (*ErrorCode, error)
JoinSignature(ctx context.Context, in *JoinSignatureRequest, opts ...grpc.CallOption) (*ErrorCode, error)
ReadySign(ctx context.Context, in *ReadySignRequest, opts ...grpc.CallOption) (*ErrorCode, error)
}
type platformClient struct {
cc *grpc.ClientConn
}
func NewPlatformClient(cc *grpc.ClientConn) PlatformClient {
return &platformClient{cc}
}
func (c *platformClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*ErrorCode, error) {
out := new(ErrorCode)
err := grpc.Invoke(ctx, "/api.Platform/Register", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *platformClient) Auth(ctx context.Context, in *AuthRequest, opts ...grpc.CallOption) (*RegisteredUser, error) {
out := new(RegisteredUser)
err := grpc.Invoke(ctx, "/api.Platform/Auth", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *platformClient) Unregister(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ErrorCode, error) {
out := new(ErrorCode)
err := grpc.Invoke(ctx, "/api.Platform/Unregister", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *platformClient) PostContract(ctx context.Context, in *PostContractRequest, opts ...grpc.CallOption) (*ErrorCode, error) {
out := new(ErrorCode)
err := grpc.Invoke(ctx, "/api.Platform/PostContract", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *platformClient) JoinSignature(ctx context.Context, in *JoinSignatureRequest, opts ...grpc.CallOption) (*ErrorCode, error) {
out := new(ErrorCode)
err := grpc.Invoke(ctx, "/api.Platform/JoinSignature", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *platformClient) ReadySign(ctx context.Context, in *ReadySignRequest, opts ...grpc.CallOption) (*ErrorCode, error) {
out := new(ErrorCode)
err := grpc.Invoke(ctx, "/api.Platform/ReadySign", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Platform service
type PlatformServer interface {
Register(context.Context, *RegisterRequest) (*ErrorCode, error)
Auth(context.Context, *AuthRequest) (*RegisteredUser, error)
Unregister(context.Context, *Empty) (*ErrorCode, error)
PostContract(context.Context, *PostContractRequest) (*ErrorCode, error)
JoinSignature(context.Context, *JoinSignatureRequest) (*ErrorCode, error)
ReadySign(context.Context, *ReadySignRequest) (*ErrorCode, error)
}
func RegisterPlatformServer(s *grpc.Server, srv PlatformServer) {
s.RegisterService(&_Platform_serviceDesc, srv)
}
func _Platform_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error) (interface{}, error) {
in := new(RegisterRequest)
if err := dec(in); err != nil {
return nil, err
}
out, err := srv.(PlatformServer).Register(ctx, in)
if err != nil {
return nil, err
}
return out, nil
}
func _Platform_Auth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error) (interface{}, error) {
in := new(AuthRequest)
if err := dec(in); err != nil {
return nil, err
}
out, err := srv.(PlatformServer).Auth(ctx, in)
if err != nil {
return nil, err
}
return out, nil
}
func _Platform_Unregister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error) (interface{}, error) {
in := new(Empty)
if err := dec(in); err != nil {
return nil, err
}
out, err := srv.(PlatformServer).Unregister(ctx, in)
if err != nil {
return nil, err
}
return out, nil
}
func _Platform_PostContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error) (interface{}, error) {
in := new(PostContractRequest)
if err := dec(in); err != nil {
return nil, err
}
out, err := srv.(PlatformServer).PostContract(ctx, in)
if err != nil {
return nil, err
}
return out, nil
}
func _Platform_JoinSignature_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error) (interface{}, error) {
in := new(JoinSignatureRequest)
if err := dec(in); err != nil {
return nil, err
}
out, err := srv.(PlatformServer).JoinSignature(ctx, in)
if err != nil {
return nil, err
}
return out, nil
}
func _Platform_ReadySign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error) (interface{}, error) {
in := new(ReadySignRequest)
if err := dec(in); err != nil {
return nil, err
}
out, err := srv.(PlatformServer).ReadySign(ctx, in)
if err != nil {
return nil, err
}
return out, nil
}
var _Platform_serviceDesc = grpc.ServiceDesc{
ServiceName: "api.Platform",
HandlerType: (*PlatformServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Register",
Handler: _Platform_Register_Handler,
},
{
MethodName: "Auth",
Handler: _Platform_Auth_Handler,
},
{
MethodName: "Unregister",
Handler: _Platform_Unregister_Handler,
},
{
MethodName: "PostContract",
Handler: _Platform_PostContract_Handler,
},
{
MethodName: "JoinSignature",
Handler: _Platform_JoinSignature_Handler,
},
{
MethodName: "ReadySign",
Handler: _Platform_ReadySign_Handler,
},
},
Streams: []grpc.StreamDesc{},
}
var fileDescriptor0 = []byte{
// 416 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 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0x5d, 0x19, 0x72, 0x7d, 0x80,
0xfd, 0x06, 0xa6, 0x9d, 0x9f, 0xf8, 0xd8, 0x4f, 0xd2, 0xf7, 0xf7, 0x6f, 0xd6, 0xd7, 0x1b, 0xf7,
0x3b, 0xbd, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x17, 0x95, 0x89, 0x4a, 0x64, 0x03, 0x00, 0x00,
}
syntax = "proto3";
package api;
service Platform {
rpc Register(RegisterRequest) returns (ErrorCode) {}
rpc Auth(AuthRequest) returns (RegisteredUser) {}
rpc Unregister(Empty) returns (ErrorCode) {}
rpc PostContract(PostContractRequest) returns (ErrorCode) {}
rpc JoinSignature(JoinSignatureRequest) returns (ErrorCode) {}
rpc ReadySign(ReadySignRequest) returns (ErrorCode) {}
}
// RegisterRequest message contains the client's email adress and his
// public key
message RegisterRequest {
string email = 1;
string key = 2;
}
// ErrorCode message contains an error code (see dffs/dfssp/api/errorCodes.go)
// and a message
message ErrorCode {
int32 code = 1;
string message = 2;
}
// AuthRequest message contains the client's email adress and the token used
// for authentication
message AuthRequest {
string email = 1;
string token = 2;
}
// RegisteredUser message contains the generated client certificate
// and the CA root certificate (PEM-encoded)
message RegisteredUser {
bytes rootCert = 1;
bytes clientCert = 2;
}
// Empty message is an empty message
message Empty {
}
// PostContractRequest message contains the contract as SHA-512 hash, the list of signers
// as an array of string, and a comment
message PostContractRequest {
string contract = 1;
repeated string signer = 2;
string comment = 3;
}
// JoinSignatureRequest message contains the contract to join unique identifier
// and the port the client will be listening at
message JoinSignatureRequest {
string contractUuid = 1;
uint32 port =2;
}
// ReadySignRequest contains the contract unique identitier that is ready to be signed
message ReadySignRequest {
string contractUuid = 1;
}
package main
import (
api "dfss/dfssp/api"
"golang.org/x/net/context"
)
type server struct{}
// Register handler
//
// Handle incoming RegisterRequest messages
func (s *server) Register(ctx context.Context, in *api.RegisterRequest) (*api.ErrorCode, error) {
// TODO
_ = new(server)
return nil, nil
}
// Auth handler
//
// Handle incoming AuthRequest messages
func (s *server) Auth(ctx context.Context, in *api.AuthRequest) (*api.RegisteredUser, error) {
// TODO
return nil, nil
}
// Unregister handler
//
// Handle incoming UnregisterRequest messages
func (s *server) Unegister(ctx context.Context, in *api.Empty) (*api.ErrorCode, error) {
// TODO
return nil, nil
}
// PostContract handler
//
// Handle incoming PostContractRequest messages
func (s *server) PostContract(ctx context.Context, in *api.PostContractRequest) (*api.ErrorCode, error) {
// TODO
return nil, nil
}
// JoinSignature handler
//
// Handle incoming JoinSignatureRequest messages
func (s *server) JoinSignature(ctx context.Context, in *api.JoinSignatureRequest) (*api.ErrorCode, error) {
// TODO
return nil, nil
}
// ReadySign handler
//
// Handle incoming ReadySignRequest messages
func (s *server) ReadySign(ctx context.Context, in *api.ReadySignRequest) (*api.ErrorCode, error) {
// TODO
return nil, nil
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment