Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dfss
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mpcs
dfss
Commits
72c5ddd3
Commit
72c5ddd3
authored
Mar 28, 2016
by
Caro Axel
Committed by
Loïck Bonniot
Apr 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[t] Add Alert API
- Add mgdb entities to handle resolution protocol - Add unit tests
parent
83c49738
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1784 additions
and
68 deletions
+1784
-68
.gitlab-ci.yml
.gitlab-ci.yml
+6
-1
dfssc/api/client.pb.go
dfssc/api/client.pb.go
+32
-32
dfssc/api/client.proto
dfssc/api/client.proto
+6
-4
dfssc/sign/promises.go
dfssc/sign/promises.go
+4
-3
dfsst/api/resolution.pb.go
dfsst/api/resolution.pb.go
+27
-17
dfsst/api/resolution.proto
dfsst/api/resolution.proto
+8
-2
dfsst/archivesManager/archivesManager.go
dfsst/archivesManager/archivesManager.go
+122
-0
dfsst/archivesManager/archivesManager_test.go
dfsst/archivesManager/archivesManager_test.go
+326
-0
dfsst/checker/promise.go
dfsst/checker/promise.go
+91
-0
dfsst/checker/promise_test.go
dfsst/checker/promise_test.go
+171
-0
dfsst/checker/request.go
dfsst/checker/request.go
+145
-0
dfsst/checker/request_test.go
dfsst/checker/request_test.go
+158
-0
dfsst/entities/signatureArchives.go
dfsst/entities/signatureArchives.go
+112
-0
dfsst/entities/signatureArchives_test.go
dfsst/entities/signatureArchives_test.go
+27
-0
dfsst/resolve/resolve.go
dfsst/resolve/resolve.go
+59
-0
dfsst/resolve/resolve_test.go
dfsst/resolve/resolve_test.go
+189
-0
dfsst/server/server.go
dfsst/server/server.go
+160
-8
dfsst/server/server_test.go
dfsst/server/server_test.go
+109
-0
dfsst/testdata/cert.pem
dfsst/testdata/cert.pem
+11
-0
dfsst/testdata/dfssp_rootCA.pem
dfsst/testdata/dfssp_rootCA.pem
+11
-0
dfsst/testdata/key.pem
dfsst/testdata/key.pem
+9
-0
mgdb/manager.go
mgdb/manager.go
+1
-1
No files found.
.gitlab-ci.yml
View file @
72c5ddd3
...
...
@@ -36,6 +36,11 @@ Unit tests:
-
"
go
test
-coverprofile
dfssc_security.part
-v
dfss/dfssc/security"
-
"
go
test
-coverprofile
dfssc_user.part
-v
dfss/dfssc/user"
-
"
go
test
-coverprofile
dfssc_user.part
-v
dfss/dfssc/sign"
-
"
go
test
-coverprofile
dfsst_archivesManager.part
-v
dfss/dfsst/archivesManager"
-
"
go
test
-coverprofile
dfsst_checker.part
-v
dfss/dfsst/checker"
-
"
go
test
-coverprofile
dfsst_entities.part
-v
dfss/dfsst/entities"
-
"
go
test
-coverprofile
dfsst_resolve.part
-v
dfss/dfsst/resolve"
-
"
go
test
-coverprofile
dfsst_server.part
-v
dfss/dfsst/server"
-
"
echo
'mode:
set'
*part
>
c.out"
-
"
grep
-h
-v
'mode:
set'
*part
>>
c.out"
-
"
go
tool
cover
-html=c.out
-o
coverage.html"
...
...
@@ -80,7 +85,7 @@ Code lint:
-
"
./build/deps.sh"
-
"
cd
$GOPATH/src/dfss
&&
make
install_all"
-
"
gometalinter
--install
--update"
-
"
gometalinter
-t
--deadline=
6
00s
-j1
--skip=api
--skip=fixtures
--skip=gui
--skip=dfssd
--disable=aligncheck
./..."
-
"
gometalinter
-t
--deadline=
9
00s
-j1
--skip=api
--skip=fixtures
--skip=gui
--skip=dfssd
--disable=aligncheck
./..."
Deploy
:
stage
:
deploy
...
...
dfssc/api/client.pb.go
View file @
72c5ddd3
...
...
@@ -36,11 +36,13 @@ var _ = math.Inf
const
_
=
proto
.
ProtoPackageIsVersion1
type
Context
struct
{
RecipientKeyHash
[]
byte
`protobuf:"bytes,1,opt,name=recipientKeyHash,proto3" json:"recipientKeyHash,omitempty"`
SenderKeyHash
[]
byte
`protobuf:"bytes,2,opt,name=senderKeyHash,proto3" json:"senderKeyHash,omitempty"`
SignatureUuid
string
`protobuf:"bytes,3,opt,name=signatureUuid" json:"signatureUuid,omitempty"`
ContractUuid
string
`protobuf:"bytes,4,opt,name=contractUuid" json:"contractUuid,omitempty"`
ContractDocumentHash
string
`protobuf:"bytes,5,opt,name=contractDocumentHash" json:"contractDocumentHash,omitempty"`
RecipientKeyHash
[]
byte
`protobuf:"bytes,1,opt,name=recipientKeyHash,proto3" json:"recipientKeyHash,omitempty"`
SenderKeyHash
[]
byte
`protobuf:"bytes,2,opt,name=senderKeyHash,proto3" json:"senderKeyHash,omitempty"`
Sequence
[]
uint32
`protobuf:"varint,3,rep,name=sequence" json:"sequence,omitempty"`
Signers
[][]
byte
`protobuf:"bytes,4,rep,name=signers,proto3" json:"signers,omitempty"`
ContractDocumentHash
[]
byte
`protobuf:"bytes,5,opt,name=contractDocumentHash,proto3" json:"contractDocumentHash,omitempty"`
SignatureUUID
string
`protobuf:"bytes,6,opt,name=signatureUUID" json:"signatureUUID,omitempty"`
SignedHash
[]
byte
`protobuf:"bytes,7,opt,name=signedHash,proto3" json:"signedHash,omitempty"`
}
func
(
m
*
Context
)
Reset
()
{
*
m
=
Context
{}
}
...
...
@@ -109,10 +111,6 @@ func init() {
var
_
context
.
Context
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
type
ClientClient
interface
{
...
...
@@ -225,27 +223,29 @@ var _Client_serviceDesc = grpc.ServiceDesc{
}
var
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0xe7
,
0x2e
,
0x25
,
0x0c
,
0x1e
,
0xa1
,
0xfd
,
0x5c
,
0xce
,
0xf4
,
0x6f
,
0x93
,
0x3d
,
0xb9
,
0xda
,
0xa1
,
0xdc
,
0x15
,
0x34
,
0x66
,
0x3c
,
0x49
,
0x64
,
0x4e
,
0xf9
,
0xb4
,
0xe1
,
0x09
,
0x99
,
0xa2
,
0x54
,
0x3b
,
0x2a
,
0xe1
,
0xf8
,
0xbb
,
0x0a
,
0xcd
,
0x09
,
0xbe
,
0x0b
,
0x12
,
0x82
,
0xfb
,
0xa2
,
0x38
,
0x35
,
0xe5
,
0x92
,
0x85
,
0xdd
,
0x16
,
0xf9
,
0x5d
,
0x44
,
0x77
,
0x4a
,
0x49
,
0x35
,
0x91
,
0x31
,
0x0f
,
0x2a
,
0xf6
,
0x26
,
0xba
,
0xc8
,
0xff
,
0x9d
,
0xb8
,
0xe0
,
0xec
,
0xf0
,
0x91
,
0x33
,
0x03
,
0x68
,
0x4d
,
0x85
,
0x66
,
0xd2
,
0xda
,
0x13
,
0xc0
,
0x2e
,
0x0e
,
0xe8
,
0xef
,
0xfd
,
0x07
,
0x95
,
0xd7
,
0x26
,
0x3e
,
0xbf
,
0xdb
,
0x9f
,
0x00
,
0x00
,
0x00
,
0xff
,
0xff
,
0xb4
,
0xf1
,
0xe7
,
0x80
,
0xc1
,
0x02
,
0x00
,
0x00
,
}
dfssc/api/client.proto
View file @
72c5ddd3
...
...
@@ -13,16 +13,18 @@ service Client {
message
Context
{
bytes
recipientKeyHash
=
1
;
// SHA-512
bytes
senderKeyHash
=
2
;
// SHA-512
string
signatureUuid
=
3
;
string
contractUuid
=
4
;
string
contractDocumentHash
=
5
;
repeated
uint32
sequence
=
3
;
// Signing sequence
repeated
bytes
signers
=
4
;
// List of the signers' hashes
bytes
contractDocumentHash
=
5
;
string
signatureUUID
=
6
;
bytes
signedHash
=
7
;
// (sequence + signers' hashes + contractDocumentHash + signatureUUID) crypted by the platform
}
// Promise message contains all the required information to verify
// the identity of the sender and receiver, and the actual promise
message
Promise
{
Context
context
=
1
;
uint32
index
=
2
;
uint32
index
=
2
;
// The index of the sequence for this message
bytes
payload
=
3
;
}
...
...
dfssc/sign/promises.go
View file @
72c5ddd3
...
...
@@ -18,9 +18,10 @@ func (m *SignatureManager) createContext(from, to uint32) (*cAPI.Context, error)
return
&
cAPI
.
Context
{
RecipientKeyHash
:
m
.
keyHash
[
to
],
SenderKeyHash
:
m
.
keyHash
[
from
],
ContractDocumentHash
:
m
.
contract
.
File
.
Hash
,
SignatureUuid
:
m
.
uuid
,
ContractUuid
:
m
.
contract
.
UUID
,
Sequence
:
m
.
sequence
,
Signers
:
m
.
keyHash
,
ContractDocumentHash
:
[]
byte
(
m
.
contract
.
File
.
Hash
),
SignatureUUID
:
m
.
uuid
,
},
nil
}
...
...
dfsst/api/resolution.pb.go
View file @
72c5ddd3
...
...
@@ -18,6 +18,7 @@ package api
import
proto
"github.com/golang/protobuf/proto"
import
fmt
"fmt"
import
math
"math"
import
api2
"dfss/dfssc/api"
import
(
context
"golang.org/x/net/context"
...
...
@@ -35,6 +36,7 @@ const _ = proto.ProtoPackageIsVersion1
// Alert message sent by a signer
type
AlertRequest
struct
{
Promises
[]
*
api2
.
Promise
`protobuf:"bytes,1,rep,name=promises" json:"promises,omitempty"`
}
func
(
m
*
AlertRequest
)
Reset
()
{
*
m
=
AlertRequest
{}
}
...
...
@@ -42,8 +44,16 @@ func (m *AlertRequest) String() string { return proto.CompactTextStri
func
(
*
AlertRequest
)
ProtoMessage
()
{}
func
(
*
AlertRequest
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor0
,
[]
int
{
0
}
}
func
(
m
*
AlertRequest
)
GetPromises
()
[]
*
api2
.
Promise
{
if
m
!=
nil
{
return
m
.
Promises
}
return
nil
}
// RecoverRequest message to get a signed contract
type
RecoverRequest
struct
{
SignatureUUID
string
`protobuf:"bytes,1,opt,name=signatureUUID" json:"signatureUUID,omitempty"`
}
func
(
m
*
RecoverRequest
)
Reset
()
{
*
m
=
RecoverRequest
{}
}
...
...
@@ -74,10 +84,6 @@ func init() {
var
_
context
.
Context
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 TTP service
type
TTPClient
interface
{
...
...
@@ -163,17 +169,21 @@ var _TTP_serviceDesc = grpc.ServiceDesc{
}
var
fileDescriptor0
=
[]
byte
{
// 188 bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x09
,
0x6e
,
0x88
,
0x02
,
0xff
,
0xe2
,
0x92
,
0x4f
,
0x49
,
0x2b
,
0x2e
,
0xd6
,
0x07
,
0x11
,
0x25
,
0xfa
,
0x89
,
0x05
,
0x99
,
0xfa
,
0x45
,
0xa9
,
0xc5
,
0xf9
,
0x39
,
0xa5
,
0x25
,
0x99
,
0xf9
,
0x79
,
0x7a
,
0x05
,
0x45
,
0xf9
,
0x25
,
0xf9
,
0x42
,
0xcc
,
0x40
,
0x51
,
0x25
,
0x3e
,
0x2e
,
0x1e
,
0xc7
,
0x9c
,
0xd4
,
0xa2
,
0x92
,
0xa0
,
0xd4
,
0xc2
,
0xd2
,
0xd4
,
0xe2
,
0x12
,
0x25
,
0x01
,
0x2e
,
0xbe
,
0xa0
,
0xd4
,
0xe4
,
0xfc
,
0xb2
,
0xd4
,
0x22
,
0x98
,
0x88
,
0x3d
,
0x17
,
0x77
,
0x48
,
0x48
,
0x40
,
0x50
,
0x6a
,
0x71
,
0x41
,
0x7e
,
0x5e
,
0x71
,
0xaa
,
0x90
,
0x08
,
0x17
,
0x6b
,
0x62
,
0x52
,
0x7e
,
0x51
,
0x89
,
0x04
,
0xa3
,
0x02
,
0xa3
,
0x06
,
0x47
,
0x10
,
0x84
,
0x23
,
0x24
,
0xc5
,
0xc5
,
0x91
,
0x9c
,
0x9f
,
0x57
,
0x52
,
0x94
,
0x98
,
0x5c
,
0x22
,
0xc1
,
0x04
,
0x94
,
0xe0
,
0x09
,
0x82
,
0xf3
,
0x8d
,
0x32
,
0xb9
,
0x98
,
0x81
,
0x06
,
0x08
,
0xe9
,
0x71
,
0xb1
,
0x82
,
0x6d
,
0x12
,
0x12
,
0xd4
,
0x03
,
0x5a
,
0xac
,
0x87
,
0x6c
,
0xab
,
0x94
,
0x00
,
0x58
,
0x08
,
0xc9
,
0x1a
,
0x25
,
0x06
,
0x21
,
0x23
,
0x2e
,
0x76
,
0xa8
,
0x4b
,
0x84
,
0x84
,
0xc1
,
0xd2
,
0xa8
,
0xee
,
0xc2
,
0xa6
,
0x27
,
0x89
,
0x0d
,
0xec
,
0x33
,
0x63
,
0x40
,
0x00
,
0x00
,
0x00
,
0xff
,
0xff
,
0xa7
,
0x4b
,
0x1a
,
0xea
,
0xfc
,
0x00
,
0x00
,
0x00
,
// 245 bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x09
,
0x6e
,
0x88
,
0x02
,
0xff
,
0x6c
,
0x90
,
0xcd
,
0x4a
,
0xc4
,
0x30
,
0x10
,
0xc7
,
0x5d
,
0xcb
,
0x6a
,
0x9d
,
0xad
,
0xa2
,
0xd1
,
0xc3
,
0x52
,
0x0f
,
0x4a
,
0xf1
,
0xd0
,
0x53
,
0x0b
,
0x15
,
0xc4
,
0x9b
,
0x08
,
0x5e
,
0xbc
,
0x2d
,
0x61
,
0xf7
,
0x01
,
0xb2
,
0x71
,
0x94
,
0x40
,
0x4d
,
0x6a
,
0x66
,
0xea
,
0xf3
,
0x1b
,
0x53
,
0x2d
,
0x5b
,
0xd8
,
0x4b
,
0x60
,
0xfe
,
0x1f
,
0x93
,
0x5f
,
0x02
,
0x37
,
0x6f
,
0xef
,
0x44
,
0xf5
,
0xef
,
0xc1
,
0xb5
,
0xea
,
0x4c
,
0xed
,
0x91
,
0x5c
,
0xdb
,
0xb3
,
0x71
,
0xb6
,
0xea
,
0x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,
0x9b
,
0x9a
,
0x69
,
0x01
,
0x00
,
0x00
,
}
dfsst/api/resolution.proto
View file @
72c5ddd3
...
...
@@ -2,16 +2,22 @@ syntax = "proto3";
package
api
;
import
"dfss/dfssc/api/client.proto"
;
service
TTP
{
rpc
Alert
(
AlertRequest
)
returns
(
TTPResponse
)
{}
rpc
Recover
(
RecoverRequest
)
returns
(
TTPResponse
)
{}
}
// Alert message sent by a signer
message
AlertRequest
{}
message
AlertRequest
{
repeated
Promise
promises
=
1
;
}
// RecoverRequest message to get a signed contract
message
RecoverRequest
{}
message
RecoverRequest
{
string
signatureUUID
=
1
;
}
// TTPResponse message to answer an Alert or Recover message
message
TTPResponse
{
...
...
dfsst/archivesManager/archivesManager.go
0 → 100644
View file @
72c5ddd3
package
archivesManager
import
(
cAPI
"dfss/dfssc/api"
"dfss/dfsst/entities"
"dfss/mgdb"
"gopkg.in/mgo.v2/bson"
)
// ArchivesManager : handles the structure of a SignatureArchives, with functions suited for the TTP resolve protocol.
type
ArchivesManager
struct
{
DB
*
mgdb
.
MongoManager
Archives
*
entities
.
SignatureArchives
}
// NewArchivesManager : create a new archivesManager, with the specified mgdb manager, but
// doesn't initialize the signatureArchives. (see function 'InitializeArchives').
func
NewArchivesManager
(
db
*
mgdb
.
MongoManager
)
*
ArchivesManager
{
return
&
ArchivesManager
{
DB
:
db
,
}
}
// InitializeArchives : if an entry in the database for this signature exists, retrieves it, otherwise creates it.
//
// This function should only be called after function IsRequestValid.
func
(
manager
*
ArchivesManager
)
InitializeArchives
(
promise
*
cAPI
.
Promise
,
signatureUUID
bson
.
ObjectId
,
signers
*
[]
entities
.
Signer
)
{
present
,
archives
:=
manager
.
ContainsSignature
(
signatureUUID
)
if
!
present
{
archives
=
entities
.
NewSignatureArchives
(
signatureUUID
,
promise
.
Context
.
Sequence
,
*
signers
,
promise
.
Context
.
ContractDocumentHash
,
promise
.
Context
.
SignedHash
)
}
manager
.
Archives
=
archives
}
// ContainsSignature : checks if the specified signatureUUID matches a SignatureArchives in the database.
// If it exists, returns it.
func
(
manager
*
ArchivesManager
)
ContainsSignature
(
signatureUUID
bson
.
ObjectId
)
(
present
bool
,
archives
*
entities
.
SignatureArchives
)
{
err
:=
manager
.
DB
.
Get
(
"signatures"
)
.
FindByID
(
entities
.
SignatureArchives
{
ID
:
signatureUUID
},
&
archives
)
if
err
!=
nil
{
present
=
false
archives
=
&
entities
.
SignatureArchives
{}
return
}
present
=
true
return
}
// HasReceivedAbortToken : determines if the specified signer has already been sent an abort token in the specified signatureArchives.
func
(
manager
*
ArchivesManager
)
HasReceivedAbortToken
(
signerIndex
uint32
)
bool
{
for
_
,
s
:=
range
manager
.
Archives
.
AbortedSigners
{
if
signerIndex
==
s
.
SignerIndex
{
return
true
}
}
return
false
}
// WasContractSigned : determines if the ttp already generated a signed contract for this signatureArchives, and returns it if true.
func
(
manager
*
ArchivesManager
)
WasContractSigned
()
(
bool
,
[]
byte
)
{
signedContract
:=
manager
.
Archives
.
SignedContract
if
len
(
signedContract
)
!=
0
{
return
true
,
signedContract
}
return
false
,
[]
byte
{}
}
// HasSignerPromised : determines if the specified signer has promised to sign to at least one other signer.
func
(
manager
*
ArchivesManager
)
HasSignerPromised
(
signer
uint32
)
bool
{
for
_
,
p
:=
range
manager
.
Archives
.
ReceivedPromises
{
if
(
p
.
SenderKeyIndex
==
signer
)
&&
(
p
.
RecipientKeyIndex
!=
signer
)
{
return
true
}
}
return
false
}
// AddToAbort : adds the specified signer to the aborted signers of the signatureArchives.
// If the signer is already present, does nothing.
func
(
manager
*
ArchivesManager
)
AddToAbort
(
signerIndex
uint32
)
{
for
_
,
s
:=
range
manager
.
Archives
.
AbortedSigners
{
if
s
.
SignerIndex
==
signerIndex
{
return
}
}
// TODO
// This requires the implementation of promises
var
abortIndex
uint32
abortIndex
=
0
abortedSigner
:=
entities
.
NewAbortedSigner
(
signerIndex
,
abortIndex
)
manager
.
Archives
.
AbortedSigners
=
append
(
manager
.
Archives
.
AbortedSigners
,
*
abortedSigner
)
}
// AddToDishonest : adds the specified signer to the dishonest signers of the signatureArchives.
// If the signer is already present, does nothing.
func
(
manager
*
ArchivesManager
)
AddToDishonest
(
signerIndex
uint32
)
{
for
_
,
s
:=
range
manager
.
Archives
.
DishonestSigners
{
if
s
==
signerIndex
{
return
}
}
manager
.
Archives
.
DishonestSigners
=
append
(
manager
.
Archives
.
DishonestSigners
,
signerIndex
)
}
// AddPromise : adds the specified promises to the list of received promises of the SignatureArchives.
func
(
manager
*
ArchivesManager
)
AddPromise
(
promise
*
entities
.
Promise
)
{
for
_
,
p
:=
range
manager
.
Archives
.
ReceivedPromises
{
if
entities
.
ArePromisesEqual
(
&
p
,
promise
)
{
return
}
}
manager
.
Archives
.
ReceivedPromises
=
append
(
manager
.
Archives
.
ReceivedPromises
,
*
promise
)
}
dfsst/archivesManager/archivesManager_test.go
0 → 100644
View file @
72c5ddd3
package
archivesManager
import
(
"crypto/sha512"
cAPI
"dfss/dfssc/api"
"dfss/dfsst/checker"
"dfss/dfsst/entities"
"dfss/mgdb"
"fmt"
"github.com/bmizerany/assert"
"gopkg.in/mgo.v2/bson"
"os"
"testing"
)
var
(
db
string
collection
*
mgdb
.
MongoCollection
dbManager
*
mgdb
.
MongoManager
sequence
[]
uint32
signers
[][]
byte
contractDocumentHash
[]
byte
signatureUUID
string
signatureUUIDBson
bson
.
ObjectId
signedHash
[]
byte
signersEntities
[]
entities
.
Signer
err
error
)
func
init
()
{
db
=
os
.
Getenv
(
"DFSS_MONGO_URI"
)
if
db
==
""
{
db
=
"mongodb://localhost/dfss-test"
}
sequence
=
[]
uint32
{
0
,
1
,
2
,
0
,
1
,
2
,
0
,
1
,
2
}
for
i
:=
0
;
i
<
3
;
i
++
{
h
:=
sha512
.
Sum512
([]
byte
{
byte
(
i
)})
signer
:=
h
[
:
]
signers
=
append
(
signers
,
signer
)
}
contractDocumentHash
=
[]
byte
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
}
signatureUUIDBson
=
bson
.
NewObjectId
()
signatureUUID
=
signatureUUIDBson
.
Hex
()
signedHash
=
[]
byte
{}
signersEntities
=
make
([]
entities
.
Signer
,
0
)
for
_
,
s
:=
range
signers
{
signerEntity
:=
entities
.
NewSigner
(
s
)
signersEntities
=
append
(
signersEntities
,
*
signerEntity
)
}
}
func
TestMain
(
m
*
testing
.
M
)
{
dbManager
,
err
=
mgdb
.
NewManager
(
db
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
"An error occured during the connection to MongoDB:"
,
err
)
os
.
Exit
(
2
)
}
collection
=
dbManager
.
Get
(
"signatures"
)
err
=
collection
.
Drop
()
code
:=
m
.
Run
()
err
=
collection
.
Drop
()
if
err
!=
nil
{
fmt
.
Println
(
"An error occurred while droping the collection"
)
}
dbManager
.
Close
()
os
.
Exit
(
code
)
}
func
TestInitializeArchives
(
t
*
testing
.
T
)
{
promise
:=
&
cAPI
.
Promise
{
Context
:
&
cAPI
.
Context
{
ContractDocumentHash
:
contractDocumentHash
,
Sequence
:
sequence
,
Signers
:
signers
,
SignatureUUID
:
signatureUUID
,
SignedHash
:
signedHash
,
},
}
archives
:=
entities
.
NewSignatureArchives
(
signatureUUIDBson
,
sequence
,
signersEntities
,
contractDocumentHash
,
signedHash
)
manager
:=
&
ArchivesManager
{
DB
:
dbManager
,
Archives
:
archives
,
}
arch
:=
entities
.
NewSignatureArchives
(
signatureUUIDBson
,
sequence
,
signersEntities
,
contractDocumentHash
,
signedHash
)
manager
.
InitializeArchives
(
promise
,
signatureUUIDBson
,
&
signersEntities
)
arch
.
Signers
=
manager
.
Archives
.
Signers
assert
.
Equal
(
t
,
manager
.
Archives
,
arch
)
ok
,
err
:=
collection
.
Insert
(
manager
.
Archives
)
assert
.
Equal
(
t
,
ok
,
true
)
assert
.
Equal
(
t
,
err
,
nil
)
manager
.
Archives
=
&
entities
.
SignatureArchives
{}
manager
.
InitializeArchives
(
promise
,
signatureUUIDBson
,
&
signersEntities
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
manager
.
Archives
,
arch
)
ok
,
err
=
collection
.
DeleteByID
(
*
manager
.
Archives
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
ok
,
true
)
}
func
TestContainsSignature
(
t
*
testing
.
T
)
{
archives
:=
entities
.
NewSignatureArchives
(
signatureUUIDBson
,
sequence
,
signersEntities
,
contractDocumentHash
,
signedHash
)
manager
:=
&
ArchivesManager
{
DB
:
dbManager
,
Archives
:
archives
,
}
b
,
arch
:=
manager
.
ContainsSignature
(
signatureUUIDBson
)
assert
.
Equal
(
t
,
b
,
false
)
assert
.
Equal
(
t
,
arch
,
&
entities
.
SignatureArchives
{})
ok
,
err
:=
collection
.
Insert
(
archives
)
assert
.
Equal
(
t
,
ok
,
true
)
assert
.
Equal
(
t
,
err
,
nil
)
b
,
arch
=
manager
.
ContainsSignature
(
signatureUUIDBson
)
assert
.
Equal
(
t
,
b
,
true
)
assert
.
Equal
(
t
,
arch
,
archives
)
ok
,
err
=
collection
.
DeleteByID
(
*
archives
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
ok
,
true
)
}
func
TestHasReceivedAbortToken
(
t
*
testing
.
T
)
{
archives
:=
entities
.
NewSignatureArchives
(
signatureUUIDBson
,
sequence
,
signersEntities
,
contractDocumentHash
,
signedHash
)
manager
:=
&
ArchivesManager
{
DB
:
dbManager
,
Archives
:
archives
,
}
signerIndex
:=
uint32
(
1
)
abortedSigner0
:=
entities
.
NewAbortedSigner
(
uint32
(
0
),
uint32
(
1
))
abortedSigner1
:=
entities
.
NewAbortedSigner
(
signerIndex
,
uint32
(
1
))
assert
.
Equal
(
t
,
len
(
archives
.
AbortedSigners
),
0
)
aborted
:=
manager
.
HasReceivedAbortToken
(
signerIndex
)
assert
.
Equal
(
t
,
aborted
,
false
)
archives
.
AbortedSigners
=
append
(
archives
.
AbortedSigners
,
*
abortedSigner0
)
aborted
=
manager
.
HasReceivedAbortToken
(
signerIndex
)
assert
.
Equal
(
t
,
aborted
,
false
)
archives
.
AbortedSigners
=
append
(
archives
.
AbortedSigners
,
*
abortedSigner1
)
aborted
=
manager
.
HasReceivedAbortToken
(
signerIndex
)
assert
.
Equal
(
t
,
aborted
,
true
)
}
func
TestWasContractSigned
(
t
*
testing
.
T
)
{
archives
:=
entities
.
NewSignatureArchives
(
signatureUUIDBson
,
sequence
,
signersEntities
,
contractDocumentHash
,
signedHash
)
manager
:=
&
ArchivesManager
{
DB
:
dbManager
,
Archives
:
archives
,
}
signed
,
contract
:=
manager
.
WasContractSigned
()
assert
.
Equal
(
t
,
signed
,
false
)
assert
.
Equal
(
t
,
len
(
contract
),
0
)
c
:=
[]
byte
{
0
}
archives
.
SignedContract
=
c
signed
,
contract
=
manager
.
WasContractSigned
()
assert
.
Equal
(
t
,
signed
,
true
)
assert
.
Equal
(
t
,
contract
,
c
)
}
func
TestHasSignerPromised
(
t
*
testing
.
T
)
{
archives
:=
entities
.
NewSignatureArchives
(
signatureUUIDBson
,
sequence
,
signersEntities
,
contractDocumentHash
,
signedHash
)
manager
:=
&
ArchivesManager
{
DB
:
dbManager
,
Archives
:
archives
,
}
ok
:=
manager
.
HasSignerPromised
(
1
)
assert
.
Equal
(
t
,
len
(
archives
.
ReceivedPromises
),
0
)
assert
.
Equal
(
t
,
ok
,
false
)
promise0
:=
&
entities
.
Promise
{
RecipientKeyIndex
:
1
,
SenderKeyIndex
:
0
,
}
archives
.
ReceivedPromises
=
append
(
archives
.
ReceivedPromises
,
*
promise0
)
assert
.
Equal
(
t
,
len
(
archives
.
ReceivedPromises
),
1
)
ok
=
manager
.
HasSignerPromised
(
1
)
assert
.
Equal
(
t
,
ok
,
false
)
promise1
:=
&
entities
.
Promise
{
RecipientKeyIndex
:
1
,
SenderKeyIndex
:
1
,
}
archives
.
ReceivedPromises
=
append
(
archives
.
ReceivedPromises
,
*
promise1
)
assert
.
Equal
(
t
,
len
(
archives
.
ReceivedPromises
),
2
)
ok
=
manager
.
HasSignerPromised
(
1
)
assert
.
Equal
(
t
,
ok
,
false
)
promise2
:=
&
entities
.
Promise
{
RecipientKeyIndex
:
0
,
SenderKeyIndex
:
1
,
}
archives
.
ReceivedPromises
=
append
(
archives
.
ReceivedPromises
,
*
promise2
)
assert
.
Equal
(
t
,
len
(
archives
.
ReceivedPromises
),
3
)
ok
=
manager
.
HasSignerPromised
(
1
)
assert
.
Equal
(
t
,
ok
,
true
)
}
// TO MODIFY WHEN SOURCE FUNCTION WILL BE UPDATED