Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/commands/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

const listTemplateSrc = `{{range . -}}
Public Key Hash: {{.Hash}}
Public Key: {{pubKey .KeyReference}}
Reference: {{keyRef .KeyReference}}
Vault: {{.Vault.Name}}
Active: {{.Active}}
Expand All @@ -24,6 +25,9 @@ Allow Proof of Possession: {{.AllowProofOfPossession}}

var (
listTpl = template.Must(template.New("list").Funcs(template.FuncMap{
"pubKey": func(ref vault.KeyReference) string {
return ref.PublicKey().String()
},
"keyRef": func(ref vault.KeyReference) string {
if withID, ok := ref.(vault.WithID); ok {
return withID.ID()
Expand Down
26 changes: 25 additions & 1 deletion integration_test/tests/cli/cli_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"regexp"
"testing"

integrationtest "github.com/ecadlabs/signatory/integration_test/tests"
Expand All @@ -11,9 +12,32 @@ import (
func TestCliList(t *testing.T) {
out, err := integrationtest.SignatoryCli("list")
assert.Nil(t, err)

pkhPattern := regexp.MustCompile(`Public Key Hash: +(tz\w+)`)
pkhMatches := pkhPattern.FindAllStringSubmatch(string(out), -1)
require.NotEmpty(t, pkhMatches, "output should contain 'Public Key Hash:' entries")

extractedPKHs := make(map[string]bool)
for _, match := range pkhMatches {
extractedPKHs[match[1]] = true
}
for _, pkh := range integrationtest.GetAllTestPKHs() {
require.Contains(t, string(out), pkh)
require.True(t, extractedPKHs[pkh], "expected PKH %s not found in output", pkh)
}

pkPattern := regexp.MustCompile(`Public Key: +(\w+)`)
pkMatches := pkPattern.FindAllStringSubmatch(string(out), -1)
require.NotEmpty(t, pkMatches, "output should contain 'Public Key:' entries")

extractedPKs := make(map[string]bool)
for _, match := range pkMatches {
extractedPKs[match[1]] = true
}
for _, pk := range integrationtest.GetAllTestPKs() {
require.True(t, extractedPKs[pk], "expected PK %s not found in output", pk)
}

require.Equal(t, len(pkhMatches), len(pkMatches), "number of PKH entries should match PK entries")
}

func TestCliUsage(t *testing.T) {
Expand Down
17 changes: 16 additions & 1 deletion integration_test/tests/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
// Address type test accounts public keys
Tz1AliasPK = "edpkvGfYw3LyB1UcCahKQk4rF2tvbMUk8GFiTuMjL75uGXrpvKXhjn"
Tz2AliasPK = "sppk7cvVVMRRtYTdriTB6KQqpXZt9TUwSTcpMWq4FwpvG2eVZ56UuHP"
Tz3AliasPK = "p2pk67wmwXhknDMAtjFJCh1Z65wCemXchB3KYQfDFp2HvDT1S2Z" // Placeholder - needs actual value
Tz3AliasPK = "p2pk65pxFqFj1N66zRRQtdbEJWHMH5hRv4WsRkaGWQJtZ5bv8nVx6Dg"
Tz4AliasPK = "BLpk1nRV5SBB2QCxsiem5Neoywcizr3mkdp167HL1iKFgFvzPhKo4RSy7J8JBh2BgGgVYjNsRGwU"

Tz4PopPK = "BLpk1w7hcraa8qBo8f7sNBteUVoSejrS779YUra1deGqZgWSw8xUVYrNSMkxWrDAAwTtFtJxvMbK"
Expand Down Expand Up @@ -262,6 +262,21 @@ func GetAllTestPKHs() []string {
}
}

// GetAllTestPKs returns all public keys used in tests
func GetAllTestPKs() []string {
return []string{
AlicePK,
BobPK,
OpstestPK,
Opstest1PK,
Tz1AliasPK,
Tz2AliasPK,
Tz3AliasPK,
Tz4AliasPK,
Tz4PopPK,
}
}

// GetAllTestAliases returns all account aliases used in tests
func GetAllTestAliases() []string {
return []string{
Expand Down
Loading