aboutsummaryrefslogtreecommitdiff
path: root/pkg/types/types_test.go
blob: d823ea28906f2a77de0926a7bcc01a20d1cc3263 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package types

import (
	"testing"
)

func TestEndpointPath(t *testing.T) {
	base, prefix, proto := "example.com", "log", "sigsum/v0"
	for _, table := range []struct {
		endpoint Endpoint
		want     string
	}{
		{
			endpoint: EndpointAddLeaf,
			want:     "example.com/log/sigsum/v0/add-leaf",
		},
		{
			endpoint: EndpointAddCosignature,
			want:     "example.com/log/sigsum/v0/add-cosignature",
		},
		{
			endpoint: EndpointGetTreeHeadLatest,
			want:     "example.com/log/sigsum/v0/get-tree-head-latest",
		},
		{
			endpoint: EndpointGetTreeHeadToSign,
			want:     "example.com/log/sigsum/v0/get-tree-head-to-sign",
		},
		{
			endpoint: EndpointGetTreeHeadCosigned,
			want:     "example.com/log/sigsum/v0/get-tree-head-cosigned",
		},
		{
			endpoint: EndpointGetConsistencyProof,
			want:     "example.com/log/sigsum/v0/get-consistency-proof",
		},
		{
			endpoint: EndpointGetInclusionProof,
			want:     "example.com/log/sigsum/v0/get-inclusion-proof",
		},
		{
			endpoint: EndpointGetLeaves,
			want:     "example.com/log/sigsum/v0/get-leaves",
		},
	} {
		if got, want := table.endpoint.Path(base+"/"+prefix+"/"+proto), table.want; got != want {
			t.Errorf("got endpoint\n%s\n\tbut wanted\n%s\n\twith one component", got, want)
		}
		if got, want := table.endpoint.Path(base, prefix, proto), table.want; got != want {
			t.Errorf("got endpoint\n%s\n\tbut wanted\n%s\n\tmultiple components", got, want)
		}
	}
}

func TestTreeHeadSign(t *testing.T)           {}
func TestTreeHeadVerify(t *testing.T)         {}
func TestInclusionProofVerify(t *testing.T)   {}
func TestConsistencyProofVerify(t *testing.T) {}