Improve test
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package sign
|
package sign
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
@@ -166,7 +167,7 @@ func TestSignPDF(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
outputFile, err := ioutil.TempFile("", "pdfsign_test")
|
outputFile, err := ioutil.TempFile("", "pdfsign_test_"+f.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%s", err.Error())
|
t.Errorf("%s", err.Error())
|
||||||
return
|
return
|
||||||
@@ -241,8 +242,6 @@ func TestSignPDFFile(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
certificate_chains := make([][]*x509.Certificate, 0)
|
|
||||||
|
|
||||||
tmpfile, err := ioutil.TempFile("", "pdfsign_test")
|
tmpfile, err := ioutil.TempFile("", "pdfsign_test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%s", err.Error())
|
t.Errorf("%s", err.Error())
|
||||||
@@ -261,10 +260,9 @@ func TestSignPDFFile(t *testing.T) {
|
|||||||
CertType: CertificationSignature,
|
CertType: CertificationSignature,
|
||||||
DocMDPPerm: AllowFillingExistingFormFieldsAndSignaturesPerms,
|
DocMDPPerm: AllowFillingExistingFormFieldsAndSignaturesPerms,
|
||||||
},
|
},
|
||||||
Signer: pkey,
|
DigestAlgorithm: crypto.SHA512,
|
||||||
Certificate: cert,
|
Signer: pkey,
|
||||||
CertificateChains: certificate_chains,
|
Certificate: cert,
|
||||||
RevocationData: revocation.InfoArchival{},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -274,12 +272,16 @@ func TestSignPDFFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, err = verify.File(tmpfile)
|
_, err = verify.File(tmpfile)
|
||||||
os.Remove(tmpfile.Name())
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%s: %s", tmpfile.Name(), err.Error())
|
t.Errorf("%s: %s", tmpfile.Name(), err.Error())
|
||||||
}
|
|
||||||
|
|
||||||
|
err2 := os.Rename(tmpfile.Name(), "../testfiles/failed/testfile20.pdf")
|
||||||
|
if err2 != nil {
|
||||||
|
t.Error(err2)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
os.Remove(tmpfile.Name())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkSignPDF(b *testing.B) {
|
func BenchmarkSignPDF(b *testing.B) {
|
||||||
|
Reference in New Issue
Block a user