aboutsummaryrefslogtreecommitdiff
path: root/internal/slackware_com/crypto_test.go
blob: 614c0375d3a1669347882d2082d7961b599b26ee (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
package slackware_com

import (
	"io"
	"os"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestGnuPGVerifier(t *testing.T) {
	f, err := os.Open("testdata/CHECKSUMS.md5.asc")
	require.NoError(t, err)
	defer f.Close()

	buf, err := io.ReadAll(f)
	require.NoError(t, err)
	signature := string(buf)

	checksumFile, err := os.Open("testdata/CHECKSUMS.md5")
	require.NoError(t, err)
	defer f.Close()

	verifier := RunSignatureVerifier(signature)
	io.Copy(verifier, checksumFile)

	ok, err := verifier.IsValid()
	require.NoError(t, err)
	require.True(t, ok)
}