From c1289f72248f04981973d4c4bffa4f0a4a427c03 Mon Sep 17 00:00:00 2001 From: Sun Yimin Date: Wed, 15 Mar 2023 17:50:27 +0800 Subject: [PATCH] pkcs7: test clean --- pkcs7/sign_test.go | 11 +---------- pkcs7/verify_test.go | 4 ++++ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/pkcs7/sign_test.go b/pkcs7/sign_test.go index 2b5cba7..908b871 100644 --- a/pkcs7/sign_test.go +++ b/pkcs7/sign_test.go @@ -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 } diff --git a/pkcs7/verify_test.go b/pkcs7/verify_test.go index c913fff..af71c3f 100644 --- a/pkcs7/verify_test.go +++ b/pkcs7/verify_test.go @@ -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