Add verification to tests

This commit is contained in:
tigp
2018-05-01 15:53:44 +02:00
parent bd88015c4c
commit 9458dd650e
2 changed files with 23 additions and 5 deletions

3
.gitignore vendored
View File

@@ -2,5 +2,6 @@
*.pdf *.pdf
*.pdf.* *.pdf.*
!testfile*.pdf !testfile*.pdf
testfiles/*_signed.pdf
pdfsign pdfsign
certs/* certs/*

View File

@@ -6,6 +6,7 @@ import (
"encoding/pem" "encoding/pem"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@@ -13,6 +14,7 @@ import (
"bitbucket.org/digitorus/pdf" "bitbucket.org/digitorus/pdf"
"bitbucket.org/digitorus/pdfsign/revocation" "bitbucket.org/digitorus/pdfsign/revocation"
"bitbucket.org/digitorus/pdfsign/verify"
"github.com/mattetti/filebuffer" "github.com/mattetti/filebuffer"
) )
@@ -178,12 +180,18 @@ func TestSignPDF(t *testing.T) {
RevocationFunction: DefaultEmbedRevocationStatusFunction, RevocationFunction: DefaultEmbedRevocationStatusFunction,
}) })
input_file.Close()
if err != nil { if err != nil {
input_file.Close()
t.Errorf("%s: %s", f.Name(), err.Error()) t.Errorf("%s: %s", f.Name(), err.Error())
return return
} }
resp, err := verify.Verify(input_file)
log.Println(resp)
input_file.Close()
if err != nil {
t.Errorf("%s: %s", f.Name(), err.Error())
}
} }
} }
@@ -234,12 +242,21 @@ func TestSignPDFFile(t *testing.T) {
RevocationData: revocation.InfoArchival{}, RevocationData: revocation.InfoArchival{},
}) })
os.Remove(tmpfile.Name())
if err != nil { if err != nil {
os.Remove(tmpfile.Name())
t.Errorf("%s: %s", "testfile20.pdf", err.Error()) t.Errorf("%s: %s", "testfile20.pdf", err.Error())
return return
} }
resp, err := verify.Verify(tmpfile)
log.Println(resp)
os.Remove(tmpfile.Name())
if err != nil {
t.Errorf("%s: %s", tmpfile.Name(), err.Error())
}
} }
func BenchmarkSignPDF(b *testing.B) { func BenchmarkSignPDF(b *testing.B) {