snp: don't print warning if no ASK is present (#3048)

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>
This commit is contained in:
Moritz Sanft 2024-04-29 14:38:34 +02:00 committed by GitHub
parent c1740b17d9
commit 002c6fa5a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 6 deletions

View file

@ -9,6 +9,7 @@ package snp
import (
"crypto/x509"
"encoding/hex"
"errors"
"fmt"
"regexp"
"strings"
@ -34,16 +35,13 @@ func TestParseCertChain(t *testing.T) {
wantAsk bool
wantArk bool
wantErr bool
errTarget error
}{
"success": {
certChain: defaultCertChain,
wantAsk: true,
wantArk: true,
},
"empty cert chain": {
certChain: []byte{},
wantErr: true,
},
"more than two certificates": {
certChain: append(defaultCertChain, defaultCertChain...),
wantErr: true,
@ -52,6 +50,11 @@ func TestParseCertChain(t *testing.T) {
certChain: []byte("invalid"),
wantErr: true,
},
"empty cert chain": {
certChain: []byte{},
wantErr: true,
errTarget: errNoPemBlocks,
},
"ark missing": {
certChain: []byte(askOnly),
wantAsk: true,
@ -73,6 +76,9 @@ func TestParseCertChain(t *testing.T) {
ask, ark, err := instanceInfo.ParseCertChain()
if tc.wantErr {
assert.Error(err)
if tc.errTarget != nil {
assert.True(errors.Is(err, tc.errTarget))
}
} else {
assert.NoError(err)
assert.Equal(tc.wantAsk, ask != nil)