@@ -28,23 +28,22 @@ import (
2828)
2929
3030func TestPutEncryptDocument (t * testing.T ) {
31-
3231 name := "4pages.pdf"
3332 file , err := os .Open (GetBaseTest ().localTestDataFolder + "/" + name )
3433 if err != nil {
3534 t .Error (err )
3635 }
37-
3836 args := map [string ]interface {}{
3937 "file" : file ,
4038 }
41-
4239 outPath := GetBaseTest ().remoteFolder + "/" + name
4340 userPassword := "user $^Password!&"
4441 ownerPassword := "owner\\ //? $12^Password!&"
45-
46- response , httpResponse , err := GetBaseTest ().PdfAPI .PutEncryptDocument (outPath , toBase64 (userPassword ), toBase64 (ownerPassword ),
47- string (CryptoAlgorithmAESx128 ), args )
42+ response , httpResponse , err := GetBaseTest ().PdfAPI .PutEncryptDocument (outPath ,
43+ base64 .StdEncoding .EncodeToString ([]byte (userPassword )),
44+ base64 .StdEncoding .EncodeToString ([]byte (ownerPassword )),
45+ string (CryptoAlgorithmAESx128 ),
46+ args )
4847 if err != nil {
4948 t .Error (err )
5049 } else if httpResponse .StatusCode < 200 || httpResponse .StatusCode > 299 {
@@ -55,22 +54,20 @@ func TestPutEncryptDocument(t *testing.T) {
5554}
5655
5756func TestPostEncryptDocumentInStorage (t * testing.T ) {
58-
5957 name := "4pages.pdf"
60-
6158 if err := GetBaseTest ().UploadFile (name ); err != nil {
6259 t .Error (err )
6360 }
64-
6561 args := map [string ]interface {}{
6662 "folder" : GetBaseTest ().remoteFolder ,
6763 }
68-
6964 userPassword := "user $^Password!&"
7065 ownerPassword := "owner\\ //? $12^Password!&"
71-
72- response , httpResponse , err := GetBaseTest ().PdfAPI .PostEncryptDocumentInStorage (name , toBase64 (userPassword ), toBase64 (ownerPassword ),
73- string (CryptoAlgorithmAESx128 ), args )
66+ response , httpResponse , err := GetBaseTest ().PdfAPI .PostEncryptDocumentInStorage (name ,
67+ base64 .StdEncoding .EncodeToString ([]byte (userPassword )),
68+ base64 .StdEncoding .EncodeToString ([]byte (ownerPassword )),
69+ string (CryptoAlgorithmAESx128 ),
70+ args )
7471 if err != nil {
7572 t .Error (err )
7673 } else if httpResponse .StatusCode < 200 || httpResponse .StatusCode > 299 {
@@ -81,21 +78,19 @@ func TestPostEncryptDocumentInStorage(t *testing.T) {
8178}
8279
8380func TestPutDecryptDocument (t * testing.T ) {
84-
8581 name := "4pagesEncrypted.pdf"
8682 file , err := os .Open (GetBaseTest ().localTestDataFolder + "/" + name )
8783 if err != nil {
8884 t .Error (err )
8985 }
90-
9186 args := map [string ]interface {}{
9287 "file" : file ,
9388 }
94-
9589 outPath := GetBaseTest ().remoteFolder + "/" + name
9690 userPassword := "user $^Password!&"
97-
98- response , httpResponse , err := GetBaseTest ().PdfAPI .PutDecryptDocument (outPath , toBase64 (userPassword ), args )
91+ response , httpResponse , err := GetBaseTest ().PdfAPI .PutDecryptDocument (outPath ,
92+ base64 .StdEncoding .EncodeToString ([]byte (userPassword )),
93+ args )
9994 if err != nil {
10095 t .Error (err )
10196 } else if httpResponse .StatusCode < 200 || httpResponse .StatusCode > 299 {
@@ -106,20 +101,17 @@ func TestPutDecryptDocument(t *testing.T) {
106101}
107102
108103func TestPostDecryptDocumentInStorage (t * testing.T ) {
109-
110104 name := "4pagesEncrypted.pdf"
111-
112105 if err := GetBaseTest ().UploadFile (name ); err != nil {
113106 t .Error (err )
114107 }
115-
116108 args := map [string ]interface {}{
117109 "folder" : GetBaseTest ().remoteFolder ,
118110 }
119-
120111 userPassword := "user $^Password!&"
121-
122- response , httpResponse , err := GetBaseTest ().PdfAPI .PostDecryptDocumentInStorage (name , toBase64 (userPassword ), args )
112+ response , httpResponse , err := GetBaseTest ().PdfAPI .PostDecryptDocumentInStorage (name ,
113+ base64 .StdEncoding .EncodeToString ([]byte (userPassword )),
114+ args )
123115 if err != nil {
124116 t .Error (err )
125117 } else if httpResponse .StatusCode < 200 || httpResponse .StatusCode > 299 {
@@ -136,18 +128,18 @@ func TestPutChangePasswordDocument(t *testing.T) {
136128 if err != nil {
137129 t .Error (err )
138130 }
139-
140131 args := map [string ]interface {}{
141132 "file" : file ,
142133 }
143-
144134 outPath := GetBaseTest ().remoteFolder + "/" + name
145135 ownerPassword := "owner\\ //? $12^Password!&"
146136 newUserPassword := "user new\\ //? $12^Password!&"
147137 newOwnerPassword := "owner new\\ //? $12^Password!&"
148-
149- response , httpResponse , err := GetBaseTest ().PdfAPI .PutChangePasswordDocument (outPath , toBase64 (ownerPassword ),
150- toBase64 (newUserPassword ), toBase64 (newOwnerPassword ), args )
138+ response , httpResponse , err := GetBaseTest ().PdfAPI .PutChangePasswordDocument (outPath ,
139+ base64 .StdEncoding .EncodeToString ([]byte (ownerPassword )),
140+ base64 .StdEncoding .EncodeToString ([]byte (newUserPassword )),
141+ base64 .StdEncoding .EncodeToString ([]byte (newOwnerPassword )),
142+ args )
151143 if err != nil {
152144 t .Error (err )
153145 } else if httpResponse .StatusCode < 200 || httpResponse .StatusCode > 299 {
@@ -158,23 +150,21 @@ func TestPutChangePasswordDocument(t *testing.T) {
158150}
159151
160152func TestPostChangePasswordDocumentInStorage (t * testing.T ) {
161-
162153 name := "4pagesEncrypted.pdf"
163-
164154 if err := GetBaseTest ().UploadFile (name ); err != nil {
165155 t .Error (err )
166156 }
167-
168157 args := map [string ]interface {}{
169158 "folder" : GetBaseTest ().remoteFolder ,
170159 }
171-
172160 ownerPassword := "owner\\ //? $12^Password!&"
173161 newUserPassword := "user new\\ //? $12^Password!&"
174162 newOwnerPassword := "owner new\\ //? $12^Password!&"
175-
176- response , httpResponse , err := GetBaseTest ().PdfAPI .PostChangePasswordDocumentInStorage (name , toBase64 (ownerPassword ),
177- toBase64 (newUserPassword ), toBase64 (newOwnerPassword ), args )
163+ response , httpResponse , err := GetBaseTest ().PdfAPI .PostChangePasswordDocumentInStorage (name ,
164+ base64 .StdEncoding .EncodeToString ([]byte (ownerPassword )),
165+ base64 .StdEncoding .EncodeToString ([]byte (newUserPassword )),
166+ base64 .StdEncoding .EncodeToString ([]byte (newOwnerPassword )),
167+ args )
178168 if err != nil {
179169 t .Error (err )
180170 } else if httpResponse .StatusCode < 200 || httpResponse .StatusCode > 299 {
@@ -183,7 +173,3 @@ func TestPostChangePasswordDocumentInStorage(t *testing.T) {
183173 fmt .Printf ("%d\t PostChangePasswordDocumentInStorage - %d\n " , GetBaseTest ().GetTestNumber (), response .Code )
184174 }
185175}
186-
187- func toBase64 (str string ) string {
188- return base64 .StdEncoding .EncodeToString ([]byte (str ))
189- }
0 commit comments