mirror of
https://github.com/containers/skopeo.git
synced 2026-01-30 05:49:52 +00:00
integration/signing_test: move findFingerprint to utils_test.go
Prep for another test which will also use this. Signed-off-by: Jonathan Lebon <jonathan@jlebon.com>
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -29,16 +26,6 @@ type signingSuite struct {
|
||||
|
||||
var _ = suite.SetupAllSuite(&signingSuite{})
|
||||
|
||||
func findFingerprint(lineBytes []byte) (string, error) {
|
||||
for line := range bytes.SplitSeq(lineBytes, []byte{'\n'}) {
|
||||
fields := strings.Split(string(line), ":")
|
||||
if len(fields) >= 10 && fields[0] == "fpr" {
|
||||
return fields[9], nil
|
||||
}
|
||||
}
|
||||
return "", errors.New("No fingerprint found")
|
||||
}
|
||||
|
||||
func (s *signingSuite) SetupSuite() {
|
||||
t := s.T()
|
||||
_, err := exec.LookPath(skopeoBinary)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"net/netip"
|
||||
@@ -29,6 +30,17 @@ var skopeoBinary = func() string {
|
||||
return "skopeo"
|
||||
}()
|
||||
|
||||
// findFingerprint extracts the GPG key fingerprint from gpg --with-colons output.
|
||||
func findFingerprint(lineBytes []byte) (string, error) {
|
||||
for line := range bytes.SplitSeq(lineBytes, []byte{'\n'}) {
|
||||
fields := strings.Split(string(line), ":")
|
||||
if len(fields) >= 10 && fields[0] == "fpr" {
|
||||
return fields[9], nil
|
||||
}
|
||||
}
|
||||
return "", errors.New("No fingerprint found")
|
||||
}
|
||||
|
||||
const (
|
||||
testFQIN = "docker://quay.io/libpod/busybox" // tag left off on purpose, some tests need to add a special one
|
||||
testFQIN64 = "docker://quay.io/libpod/busybox:amd64"
|
||||
|
||||
Reference in New Issue
Block a user