feat(oo): native document conversion (docs pdf/presigned)
- lib: PresignedURI, SignJWT (HS256, stdlib), ConvertDocument (DocumentServer /converter; legacy /ConvertService.ashx), DownloadURLTo - oo docs pdf FILE_ID|PATH...: OO file ids or local files (temp upload to --folder, convert, download, cleanup) -> PDF/other - oo docs presigned FILE_ID - docs base from $ONLYOFFICE_DOCS_URL else $ONLYOFFICE_URL/ds-vpath; JWT secret from $ONLYOFFICE_DS_SECRET (DocumentServer CoAuthoring secret) - test: SignJWT
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package onlyoffice
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSignJWT(t *testing.T) {
|
||||
payload := map[string]any{"url": "u", "outputtype": "pdf"}
|
||||
tok, err := SignJWT("secret", payload)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if n := len(strings.Split(tok, ".")); n != 3 {
|
||||
t.Fatalf("JWT must have 3 parts, got %d", n)
|
||||
}
|
||||
tok2, _ := SignJWT("secret", payload)
|
||||
if tok != tok2 {
|
||||
t.Fatal("SignJWT must be deterministic for identical input")
|
||||
}
|
||||
if _, err := SignJWT("", payload); err == nil {
|
||||
t.Fatal("expected error for empty secret")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user