diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2021-09-13 19:53:17 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2021-09-13 19:53:17 +0200 |
commit | 26b786d9857db21fdf110eaf9cb6d1d6e4e68ef9 (patch) | |
tree | 92606f47a91ebcc9e3cb4258af7a9472fc6f2e07 /pkg/instance | |
parent | f34351da0731a11316e2266d2aadd62554a5b867 (diff) |
updated (co)signed tree head structuresv0.2.0
- Added key_hash in tree head, see motivation in api.md
- Added separate types for (co)signed tree heads
- Refactored tree head HTTP APIs to be current, see api.md
Diffstat (limited to 'pkg/instance')
-rw-r--r-- | pkg/instance/endpoint.go | 4 | ||||
-rw-r--r-- | pkg/instance/endpoint_test.go | 18 |
2 files changed, 13 insertions, 9 deletions
diff --git a/pkg/instance/endpoint.go b/pkg/instance/endpoint.go index ec87303..2387263 100644 --- a/pkg/instance/endpoint.go +++ b/pkg/instance/endpoint.go @@ -58,11 +58,11 @@ func getTreeHeadToSign(ctx context.Context, i *Instance, w http.ResponseWriter, func getTreeHeadCosigned(ctx context.Context, i *Instance, w http.ResponseWriter, _ *http.Request) (int, error) { glog.V(3).Info("handling get-tree-head-cosigned request") - sth, err := i.Stateman.Cosigned(ctx) + cth, err := i.Stateman.Cosigned(ctx) if err != nil { return http.StatusInternalServerError, err } - if err := sth.MarshalASCII(w); err != nil { + if err := cth.MarshalASCII(w); err != nil { return http.StatusInternalServerError, err } return http.StatusOK, nil diff --git a/pkg/instance/endpoint_test.go b/pkg/instance/endpoint_test.go index 51ec0f4..95b71d3 100644 --- a/pkg/instance/endpoint_test.go +++ b/pkg/instance/endpoint_test.go @@ -34,10 +34,14 @@ var ( TreeSize: 0, RootHash: types.Hash(nil), }, + Signature: &[types.SignatureSize]byte{}, + } + testCTH = &types.CosignedTreeHead{ + SignedTreeHead: *testSTH, SigIdent: []*types.SigIdent{ &types.SigIdent{ - Signature: &[types.SignatureSize]byte{}, KeyHash: &[types.HashSize]byte{}, + Signature: &[types.SignatureSize]byte{}, }, }, } @@ -137,7 +141,7 @@ func TestAddCosignature(t *testing.T) { buf := func() io.Reader { return bytes.NewBufferString(fmt.Sprintf( "%s%s%x%s"+"%s%s%x%s", - types.Signature, types.Delim, make([]byte, types.SignatureSize), types.EOL, + types.Cosignature, types.Delim, make([]byte, types.SignatureSize), types.EOL, types.KeyHash, types.Delim, *types.Hash(testWitVK[:]), types.EOL, )) } @@ -311,10 +315,10 @@ func TestGetTreeToSign(t *testing.T) { func TestGetTreeCosigned(t *testing.T) { for _, table := range []struct { description string - expect bool // set if a mock answer is expected - rsp *types.SignedTreeHead // signed tree head from Trillian client - err error // error from Trillian client - wantCode int // HTTP status ok + expect bool // set if a mock answer is expected + rsp *types.CosignedTreeHead // cosigned tree head from Trillian client + err error // error from Trillian client + wantCode int // HTTP status ok }{ { description: "invalid: backend failure", @@ -325,7 +329,7 @@ func TestGetTreeCosigned(t *testing.T) { { description: "valid", expect: true, - rsp: testSTH, + rsp: testCTH, wantCode: http.StatusOK, }, } { |