pkcs7: test clean

This commit is contained in:
Sun Yimin 2023-03-15 17:50:27 +08:00 committed by GitHub
parent a93f7fd94d
commit c1289f7224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 10 deletions

View File

@ -8,7 +8,6 @@ import (
"fmt"
"io/ioutil"
"log"
"math/big"
"os"
"os/exec"
"testing"
@ -151,7 +150,7 @@ func TestUnmarshalSignedAttribute(t *testing.T) {
oidTest := asn1.ObjectIdentifier{2, 3, 4, 5, 6, 7}
testValue := "TestValue"
if err := toBeSigned.AddSigner(cert.Certificate, *cert.PrivateKey, SignerInfoConfig{
ExtraSignedAttributes: []Attribute{Attribute{Type: oidTest, Value: testValue}},
ExtraSignedAttributes: []Attribute{{Type: oidTest, Value: testValue}},
}); err != nil {
t.Fatalf("Cannot add signer: %s", err)
}
@ -257,12 +256,4 @@ func testOpenSSLParse(t *testing.T, certBytes []byte) {
if err := tmpCertFile.Close(); err != nil {
t.Fatal(err)
}
}
func fromHex(s string) *big.Int {
result, ok := new(big.Int).SetString(s, 16)
if !ok {
panic(s)
}
return result
}

View File

@ -254,12 +254,16 @@ func TestVerifyFirefoxAddon(t *testing.T) {
t.Errorf("Verify failed with error: %v", err)
}
// fake content
p7.Content = []byte("bad content")
if err = p7.VerifyWithChain(certPool); err == nil {
t.Errorf("Verify with incorrect content did not error")
}
p7.Content = FirefoxAddonContent
if p7.GetOnlySigner() == nil {
t.Errorf("no only signer")
}
// The chain has validity:
//
// EE: 2016-08-17 20:04:58 +0000 UTC 2021-08-16 20:04:58 +0000 UTC