forked from thecodingmachine/gotenberg-go-client
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathencrypt_test.go
More file actions
40 lines (31 loc) 路 923 Bytes
/
Copy pathencrypt_test.go
File metadata and controls
40 lines (31 loc) 路 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package gotenberg
import (
"context"
"fmt"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/starwalkn/gotenberg-go-client/v8/document"
"github.com/starwalkn/gotenberg-go-client/v8/test"
)
func TestEncrypt(t *testing.T) {
c, err := NewClient("http://localhost:3000", http.DefaultClient)
require.NoError(t, err)
doc, err := document.FromPath("gotenberg1.pdf", test.PDFTestFilePath(t, "gotenberg.pdf"))
require.NoError(t, err)
const (
userPassword = "abc"
ownerPassword = "def"
)
r := NewEncryptRequest(userPassword, ownerPassword, doc)
r.Trace("testEncrypt")
r.UseBasicAuth("foo", "bar")
dest := fmt.Sprintf("%s/foo.pdf", t.TempDir())
err = c.Store(context.Background(), r, dest)
require.NoError(t, err)
assert.FileExists(t, dest)
hasPassword, err := test.HasPassword(dest)
require.NoError(t, err)
assert.True(t, hasPassword)
}