Commit 13dd77aa authored by Loïck Bonniot's avatar Loïck Bonniot

[p] Add GetContract API

parent 9c2d90f8
Pipeline #610 passed with stage
...@@ -83,6 +83,10 @@ func init() { ...@@ -83,6 +83,10 @@ func init() {
var _ context.Context var _ context.Context
var _ grpc.ClientConn var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion1
// Client API for Client service // Client API for Client service
type ClientClient interface { type ClientClient interface {
......
...@@ -62,6 +62,10 @@ func init() { ...@@ -62,6 +62,10 @@ func init() {
var _ context.Context var _ context.Context
var _ grpc.ClientConn var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion1
// Client API for Demonstrator service // Client API for Demonstrator service
type DemonstratorClient interface { type DemonstratorClient interface {
......
...@@ -15,6 +15,8 @@ It has these top-level messages: ...@@ -15,6 +15,8 @@ It has these top-level messages:
RegisteredUser RegisteredUser
Empty Empty
PostContractRequest PostContractRequest
GetContractRequest
Contract
JoinSignatureRequest JoinSignatureRequest
UserConnected UserConnected
User User
...@@ -146,6 +148,35 @@ func (m *PostContractRequest) String() string { return proto.CompactT ...@@ -146,6 +148,35 @@ func (m *PostContractRequest) String() string { return proto.CompactT
func (*PostContractRequest) ProtoMessage() {} func (*PostContractRequest) ProtoMessage() {}
func (*PostContractRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } func (*PostContractRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
// GetContractRequest message contains the uuid of the asked contract
type GetContractRequest struct {
Uuid string `protobuf:"bytes,1,opt,name=uuid" json:"uuid,omitempty"`
}
func (m *GetContractRequest) Reset() { *m = GetContractRequest{} }
func (m *GetContractRequest) String() string { return proto.CompactTextString(m) }
func (*GetContractRequest) ProtoMessage() {}
func (*GetContractRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
// Contract is the return value when a contract is fetched from the platform.
// The contract is in json format to avoid duplicating structures.
type Contract struct {
ErrorCode *ErrorCode `protobuf:"bytes,1,opt,name=errorCode" json:"errorCode,omitempty"`
Json []byte `protobuf:"bytes,2,opt,name=json,proto3" json:"json,omitempty"`
}
func (m *Contract) Reset() { *m = Contract{} }
func (m *Contract) String() string { return proto.CompactTextString(m) }
func (*Contract) ProtoMessage() {}
func (*Contract) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
func (m *Contract) GetErrorCode() *ErrorCode {
if m != nil {
return m.ErrorCode
}
return nil
}
// JoinSignatureRequest message contains the contract to join unique identifier // JoinSignatureRequest message contains the contract to join unique identifier
// and the port the client will be listening at // and the port the client will be listening at
type JoinSignatureRequest struct { type JoinSignatureRequest struct {
...@@ -156,7 +187,7 @@ type JoinSignatureRequest struct { ...@@ -156,7 +187,7 @@ type JoinSignatureRequest struct {
func (m *JoinSignatureRequest) Reset() { *m = JoinSignatureRequest{} } func (m *JoinSignatureRequest) Reset() { *m = JoinSignatureRequest{} }
func (m *JoinSignatureRequest) String() string { return proto.CompactTextString(m) } func (m *JoinSignatureRequest) String() string { return proto.CompactTextString(m) }
func (*JoinSignatureRequest) ProtoMessage() {} func (*JoinSignatureRequest) ProtoMessage() {}
func (*JoinSignatureRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } func (*JoinSignatureRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} }
// UserConnected is emitted by the platform to the client to announce a new client connection // UserConnected is emitted by the platform to the client to announce a new client connection
type UserConnected struct { type UserConnected struct {
...@@ -168,7 +199,7 @@ type UserConnected struct { ...@@ -168,7 +199,7 @@ type UserConnected struct {
func (m *UserConnected) Reset() { *m = UserConnected{} } func (m *UserConnected) Reset() { *m = UserConnected{} }
func (m *UserConnected) String() string { return proto.CompactTextString(m) } func (m *UserConnected) String() string { return proto.CompactTextString(m) }
func (*UserConnected) ProtoMessage() {} func (*UserConnected) ProtoMessage() {}
func (*UserConnected) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } func (*UserConnected) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
func (m *UserConnected) GetErrorCode() *ErrorCode { func (m *UserConnected) GetErrorCode() *ErrorCode {
if m != nil { if m != nil {
...@@ -194,7 +225,7 @@ type User struct { ...@@ -194,7 +225,7 @@ type User struct {
func (m *User) Reset() { *m = User{} } func (m *User) Reset() { *m = User{} }
func (m *User) String() string { return proto.CompactTextString(m) } func (m *User) String() string { return proto.CompactTextString(m) }
func (*User) ProtoMessage() {} func (*User) ProtoMessage() {}
func (*User) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } func (*User) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
// ReadySignRequest contains the contract unique identitier that is ready to be signed // ReadySignRequest contains the contract unique identitier that is ready to be signed
type ReadySignRequest struct { type ReadySignRequest struct {
...@@ -204,7 +235,7 @@ type ReadySignRequest struct { ...@@ -204,7 +235,7 @@ type ReadySignRequest struct {
func (m *ReadySignRequest) Reset() { *m = ReadySignRequest{} } func (m *ReadySignRequest) Reset() { *m = ReadySignRequest{} }
func (m *ReadySignRequest) String() string { return proto.CompactTextString(m) } func (m *ReadySignRequest) String() string { return proto.CompactTextString(m) }
func (*ReadySignRequest) ProtoMessage() {} func (*ReadySignRequest) ProtoMessage() {}
func (*ReadySignRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } func (*ReadySignRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
// LaunchSignature is emitted by the platform when every signers are ready // LaunchSignature is emitted by the platform when every signers are ready
type LaunchSignature struct { type LaunchSignature struct {
...@@ -217,7 +248,7 @@ type LaunchSignature struct { ...@@ -217,7 +248,7 @@ type LaunchSignature struct {
func (m *LaunchSignature) Reset() { *m = LaunchSignature{} } func (m *LaunchSignature) Reset() { *m = LaunchSignature{} }
func (m *LaunchSignature) String() string { return proto.CompactTextString(m) } func (m *LaunchSignature) String() string { return proto.CompactTextString(m) }
func (*LaunchSignature) ProtoMessage() {} func (*LaunchSignature) ProtoMessage() {}
func (*LaunchSignature) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } func (*LaunchSignature) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} }
func (m *LaunchSignature) GetErrorCode() *ErrorCode { func (m *LaunchSignature) GetErrorCode() *ErrorCode {
if m != nil { if m != nil {
...@@ -233,6 +264,8 @@ func init() { ...@@ -233,6 +264,8 @@ func init() {
proto.RegisterType((*RegisteredUser)(nil), "api.RegisteredUser") proto.RegisterType((*RegisteredUser)(nil), "api.RegisteredUser")
proto.RegisterType((*Empty)(nil), "api.Empty") proto.RegisterType((*Empty)(nil), "api.Empty")
proto.RegisterType((*PostContractRequest)(nil), "api.PostContractRequest") proto.RegisterType((*PostContractRequest)(nil), "api.PostContractRequest")
proto.RegisterType((*GetContractRequest)(nil), "api.GetContractRequest")
proto.RegisterType((*Contract)(nil), "api.Contract")
proto.RegisterType((*JoinSignatureRequest)(nil), "api.JoinSignatureRequest") proto.RegisterType((*JoinSignatureRequest)(nil), "api.JoinSignatureRequest")
proto.RegisterType((*UserConnected)(nil), "api.UserConnected") proto.RegisterType((*UserConnected)(nil), "api.UserConnected")
proto.RegisterType((*User)(nil), "api.User") proto.RegisterType((*User)(nil), "api.User")
...@@ -245,6 +278,10 @@ func init() { ...@@ -245,6 +278,10 @@ func init() {
var _ context.Context var _ context.Context
var _ grpc.ClientConn var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion1
// Client API for Platform service // Client API for Platform service
type PlatformClient interface { type PlatformClient interface {
...@@ -252,6 +289,7 @@ type PlatformClient interface { ...@@ -252,6 +289,7 @@ type PlatformClient interface {
Auth(ctx context.Context, in *AuthRequest, opts ...grpc.CallOption) (*RegisteredUser, error) Auth(ctx context.Context, in *AuthRequest, opts ...grpc.CallOption) (*RegisteredUser, error)
Unregister(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ErrorCode, error) Unregister(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ErrorCode, error)
PostContract(ctx context.Context, in *PostContractRequest, opts ...grpc.CallOption) (*ErrorCode, error) PostContract(ctx context.Context, in *PostContractRequest, opts ...grpc.CallOption) (*ErrorCode, error)
GetContract(ctx context.Context, in *GetContractRequest, opts ...grpc.CallOption) (*Contract, error)
JoinSignature(ctx context.Context, in *JoinSignatureRequest, opts ...grpc.CallOption) (Platform_JoinSignatureClient, error) JoinSignature(ctx context.Context, in *JoinSignatureRequest, opts ...grpc.CallOption) (Platform_JoinSignatureClient, error)
ReadySign(ctx context.Context, in *ReadySignRequest, opts ...grpc.CallOption) (*LaunchSignature, error) ReadySign(ctx context.Context, in *ReadySignRequest, opts ...grpc.CallOption) (*LaunchSignature, error)
} }
...@@ -300,6 +338,15 @@ func (c *platformClient) PostContract(ctx context.Context, in *PostContractReque ...@@ -300,6 +338,15 @@ func (c *platformClient) PostContract(ctx context.Context, in *PostContractReque
return out, nil return out, nil
} }
func (c *platformClient) GetContract(ctx context.Context, in *GetContractRequest, opts ...grpc.CallOption) (*Contract, error) {
out := new(Contract)
err := grpc.Invoke(ctx, "/api.Platform/GetContract", 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) (Platform_JoinSignatureClient, error) { func (c *platformClient) JoinSignature(ctx context.Context, in *JoinSignatureRequest, opts ...grpc.CallOption) (Platform_JoinSignatureClient, error) {
stream, err := grpc.NewClientStream(ctx, &_Platform_serviceDesc.Streams[0], c.cc, "/api.Platform/JoinSignature", opts...) stream, err := grpc.NewClientStream(ctx, &_Platform_serviceDesc.Streams[0], c.cc, "/api.Platform/JoinSignature", opts...)
if err != nil { if err != nil {
...@@ -348,6 +395,7 @@ type PlatformServer interface { ...@@ -348,6 +395,7 @@ type PlatformServer interface {
Auth(context.Context, *AuthRequest) (*RegisteredUser, error) Auth(context.Context, *AuthRequest) (*RegisteredUser, error)
Unregister(context.Context, *Empty) (*ErrorCode, error) Unregister(context.Context, *Empty) (*ErrorCode, error)
PostContract(context.Context, *PostContractRequest) (*ErrorCode, error) PostContract(context.Context, *PostContractRequest) (*ErrorCode, error)
GetContract(context.Context, *GetContractRequest) (*Contract, error)
JoinSignature(*JoinSignatureRequest, Platform_JoinSignatureServer) error JoinSignature(*JoinSignatureRequest, Platform_JoinSignatureServer) error
ReadySign(context.Context, *ReadySignRequest) (*LaunchSignature, error) ReadySign(context.Context, *ReadySignRequest) (*LaunchSignature, error)
} }
...@@ -404,6 +452,18 @@ func _Platform_PostContract_Handler(srv interface{}, ctx context.Context, dec fu ...@@ -404,6 +452,18 @@ func _Platform_PostContract_Handler(srv interface{}, ctx context.Context, dec fu
return out, nil return out, nil
} }
func _Platform_GetContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error) (interface{}, error) {
in := new(GetContractRequest)
if err := dec(in); err != nil {
return nil, err
}
out, err := srv.(PlatformServer).GetContract(ctx, in)
if err != nil {
return nil, err
}
return out, nil
}
func _Platform_JoinSignature_Handler(srv interface{}, stream grpc.ServerStream) error { func _Platform_JoinSignature_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(JoinSignatureRequest) m := new(JoinSignatureRequest)
if err := stream.RecvMsg(m); err != nil { if err := stream.RecvMsg(m); err != nil {
...@@ -457,6 +517,10 @@ var _Platform_serviceDesc = grpc.ServiceDesc{ ...@@ -457,6 +517,10 @@ var _Platform_serviceDesc = grpc.ServiceDesc{
MethodName: "PostContract", MethodName: "PostContract",
Handler: _Platform_PostContract_Handler, Handler: _Platform_PostContract_Handler,
}, },
{
MethodName: "GetContract",
Handler: _Platform_GetContract_Handler,
},
{ {
MethodName: "ReadySign", MethodName: "ReadySign",
Handler: _Platform_ReadySign_Handler, Handler: _Platform_ReadySign_Handler,
...@@ -472,45 +536,48 @@ var _Platform_serviceDesc = grpc.ServiceDesc{ ...@@ -472,45 +536,48 @@ var _Platform_serviceDesc = grpc.ServiceDesc{
} }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 636 bytes of a gzipped FileDescriptorProto // 684 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x54, 0x6d, 0x6b, 0x13, 0x41, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x54, 0xdf, 0x6f, 0x12, 0x4f,
0x10, 0xce, 0x25, 0xd7, 0x97, 0x4c, 0x9b, 0xf4, 0xd8, 0x54, 0x89, 0x81, 0x4a, 0x59, 0x04, 0x45, 0x10, 0xe7, 0xe0, 0xda, 0xc2, 0x50, 0xe8, 0x65, 0xe9, 0xf7, 0x2b, 0x92, 0xd4, 0x34, 0x1b, 0x13,
0x24, 0x29, 0x11, 0x04, 0xfd, 0x76, 0x8d, 0xa1, 0xad, 0x48, 0x28, 0x9b, 0x46, 0xc1, 0x6f, 0xe7, 0x1b, 0x63, 0xa0, 0xc1, 0x44, 0xa3, 0x6f, 0x14, 0x49, 0x5b, 0xd3, 0x90, 0x66, 0x29, 0x9a, 0xf8,
0xdd, 0xb6, 0x39, 0x9a, 0x7b, 0x71, 0x77, 0x0f, 0xe9, 0x37, 0xff, 0x87, 0xe0, 0xdf, 0xf2, 0xe7, 0x76, 0x1e, 0xdb, 0x72, 0x96, 0xfb, 0xe1, 0xee, 0x12, 0xd3, 0x37, 0xff, 0x04, 0xdf, 0x4d, 0xfc,
0xe8, 0xee, 0xde, 0xed, 0xf5, 0x2e, 0x06, 0xa1, 0xfd, 0x70, 0xdd, 0x99, 0x9d, 0x7d, 0x66, 0x9e, 0x57, 0x75, 0x77, 0xef, 0xf6, 0x38, 0xf0, 0x62, 0x02, 0x0f, 0xc7, 0xce, 0xec, 0xec, 0x67, 0x66,
0x67, 0x66, 0x02, 0x47, 0xc1, 0x35, 0xe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, 0x3a, 0x28, 0x9b,
0xc0, 0x6c, 0xea, 0x71, 0xe9, 0xd4, 0x92, 0x85, 0xd7, 0xb2, 0x61, 0x41, 0xff, 0xa5, 0x44, 0xac,
0x0f, 0x4f, 0x27, 0x61, 0x78, 0x63, 0x34, 0x70, 0xe9, 0xf3, 0xae, 0x7e, 0xee, 0x5f, 0xfe, 0x09,
0x00, 0x00, 0xff, 0xff, 0x57, 0x09, 0xac, 0xbb, 0x0f, 0x06, 0x00, 0x00,
} }
...@@ -7,6 +7,7 @@ service Platform { ...@@ -7,6 +7,7 @@ service Platform {
rpc Auth(AuthRequest) returns (RegisteredUser) {} rpc Auth(AuthRequest) returns (RegisteredUser) {}
rpc Unregister(Empty) returns (ErrorCode) {} rpc Unregister(Empty) returns (ErrorCode) {}
rpc PostContract(PostContractRequest) returns (ErrorCode) {} rpc PostContract(PostContractRequest) returns (ErrorCode) {}
rpc GetContract(GetContractRequest) returns (Contract) {}
rpc JoinSignature(JoinSignatureRequest) returns (stream UserConnected) {} rpc JoinSignature(JoinSignatureRequest) returns (stream UserConnected) {}
rpc ReadySign(ReadySignRequest) returns (LaunchSignature) {} // Warning, LaunchSignature can be emitted with a very high delay rpc ReadySign(ReadySignRequest) returns (LaunchSignature) {} // Warning, LaunchSignature can be emitted with a very high delay
} }
...@@ -63,6 +64,18 @@ message PostContractRequest { ...@@ -63,6 +64,18 @@ message PostContractRequest {
string comment = 4; string comment = 4;
} }
// GetContractRequest message contains the uuid of the asked contract
message GetContractRequest {
string uuid = 1;
}
// Contract is the return value when a contract is fetched from the platform.
// The contract is in json format to avoid duplicating structures.
Please register or sign in to reply
message Contract {
ErrorCode errorCode = 1;
bytes json = 2;
}
// JoinSignatureRequest message contains the contract to join unique identifier // JoinSignatureRequest message contains the contract to join unique identifier
// and the port the client will be listening at // and the port the client will be listening at
message JoinSignatureRequest { message JoinSignatureRequest {
......
...@@ -14,7 +14,6 @@ import ( ...@@ -14,7 +14,6 @@ import (
"gopkg.in/mgo.v2/bson" "gopkg.in/mgo.v2/bson"
) )
var err error
var collection *mgdb.MongoCollection var collection *mgdb.MongoCollection
var manager *mgdb.MongoManager var manager *mgdb.MongoManager
var dbURI string var dbURI string
...@@ -28,6 +27,7 @@ func TestMain(m *testing.M) { ...@@ -28,6 +27,7 @@ func TestMain(m *testing.M) {
dbURI = "mongodb://localhost/dfss-test" dbURI = "mongodb://localhost/dfss-test"
} }
var err error
manager, err = mgdb.NewManager(dbURI) manager, err = mgdb.NewManager(dbURI)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
...@@ -157,16 +157,26 @@ func TestCheckAuthorization(t *testing.T) { ...@@ -157,16 +157,26 @@ func TestCheckAuthorization(t *testing.T) {
createDataset() createDataset()
id := addTestContract() id := addTestContract()
assert.T(t, repository.CheckAuthorization(user1.CertHash, id)) res, err := repository.GetWithSigner(user1.CertHash, id)
assert.T(t, !repository.CheckAuthorization(user1.CertHash, bson.NewObjectId())) assert.Equal(t, nil, err)
assert.T(t, !repository.CheckAuthorization(user2.CertHash, id)) assert.T(t, res != nil)
assert.T(t, !repository.CheckAuthorization(user2.CertHash, bson.NewObjectId())) res, err = repository.GetWithSigner(user1.CertHash, bson.NewObjectId())
assert.Equal(t, nil, err)
assert.T(t, res == nil)
res, err = repository.GetWithSigner(user2.CertHash, id)
assert.Equal(t, nil, err)
assert.T(t, res == nil)
res, err = repository.GetWithSigner(user2.CertHash, bson.NewObjectId())
assert.Equal(t, nil, err)
assert.T(t, res == nil)
contract := entities.Contract{} contract := entities.Contract{}
_ = repository.Collection.FindByID(entities.Contract{ID: id}, &contract) _ = repository.Collection.FindByID(entities.Contract{ID: id}, &contract)
contract.Ready = false contract.Ready = false
_, _ = repository.Collection.UpdateByID(contract) _, _ = repository.Collection.UpdateByID(contract)
// Not valid if contract is not ready // Still valid if contract is not ready
assert.T(t, !repository.CheckAuthorization(user1.CertHash, id)) res, _ = repository.GetWithSigner(user1.CertHash, id)
assert.T(t, res != nil)
assert.T(t, !res.Ready)
} }
...@@ -20,7 +20,6 @@ var user1, user2, user3 *entities.User ...@@ -20,7 +20,6 @@ var user1, user2, user3 *entities.User
var defaultHash = sha512.Sum512([]byte{0}) var defaultHash = sha512.Sum512([]byte{0})
func createDataset() { func createDataset() {
user1 = entities.NewUser() // Regular user user1 = entities.NewUser() // Regular user
user2 = entities.NewUser() // Regular user user2 = entities.NewUser() // Regular user
user3 = entities.NewUser() // Non-auth user user3 = entities.NewUser() // Non-auth user
...@@ -43,14 +42,11 @@ func createDataset() { ...@@ -43,14 +42,11 @@ func createDataset() {
_, _ = manager.Get("users").Insert(user1) _, _ = manager.Get("users").Insert(user1)
_, _ = manager.Get("users").Insert(user2) _, _ = manager.Get("users").Insert(user2)
_, _ = manager.Get("users").Insert(user3) _, _ = manager.Get("users").Insert(user3)
} }
func dropDataset() { func dropDataset() {
_ = manager.Get("users").Drop() _ = manager.Get("users").Drop()
_ = manager.Get("contracts").Drop() _ = manager.Get("contracts").Drop()
} }
func clientTest(t *testing.T) api.PlatformClient { func clientTest(t *testing.T) api.PlatformClient {
......
package contract
import (
"dfss/dfssp/api"
"dfss/dfssp/entities"
"dfss/mgdb"
"gopkg.in/mgo.v2/bson"
)
// Fetch returns the protobuf message when asking a specific contract containing a specific user.
func Fetch(db *mgdb.MongoManager, contractUUID string, clientHash []byte) *api.Contract {
if !bson.IsObjectIdHex(contractUUID) {
return &api.Contract{
ErrorCode: &api.ErrorCode{Code: api.ErrorCode_INVARG},
}
}
repository := entities.NewContractRepository(db.Get("contracts"))
contract, _ := repository.GetWithSigner(clientHash, bson.ObjectIdHex(contractUUID))
if contract == nil {
return &api.Contract{
ErrorCode: &api.ErrorCode{Code: api.ErrorCode_BADAUTH},
}
}
data, err := GetJSON(contract, nil)
if err != nil {
return &api.Contract{
ErrorCode: &api.ErrorCode{Code: api.ErrorCode_INTERR},
}
}
return &api.Contract{
ErrorCode: &api.ErrorCode{Code: api.ErrorCode_SUCCESS},
Json: data,
}
}
package contract_test
import (
"encoding/json"
"testing"
"dfss/dfssp/api"
"dfss/dfssp/contract"
"dfss/dfssp/entities"
"github.com/bmizerany/assert"
"golang.org/x/net/context"
"gopkg.in/mgo.v2/bson"
)
var contract1 *entities.Contract
func insertTestContract(insertUser1 bool) {
contract1 = entities.NewContract()
if insertUser1 {
contract1.AddSigner(&user1.ID, user1.Email, user1.CertHash)
}
contract1.AddSigner(&user2.ID, user2.Email, user2.CertHash)
_, _ = manager.Get("contracts").Insert(contract1)
}
func TestGetContract(t *testing.T) {
dropDataset()
createDataset()
insertTestContract(true)