test(groupware): add testcontainers based jmap test

* adds pkg/jmap/jmap_integration_test.go

 * uses ghcr.io/stalwartlabs/stalwart:v0.13.2-alpine

 * can be disabled by setting one of the following environment
   variables, in the same fashion as ca0493b28
   - CI=woodpecker
   - CI_SYSTEM_NAME=woodpecker
   - USE_TESTCONTAINERS=false

 * dependencies:
   - bump github.com/go-test/deep from 1.1.0 to 1.1.1
   - add github.com/cention-sany/utf7
   - add github.com/dustinkirkland/golang-petname
   - add github.com/emersion/go-imap/v2
   - add github.com/emersion/go-message
   - add github.com/emersion/go-sasl
   - add github.com/go-crypt/crypt
   - add github.com/go-crypt/x
   - add github.com/gogs/chardet
   - add github.com/inbucket/html2text
   - add github.com/jhilleryerd/enmime/v2
   - add github.com/ssor/bom
   - add gopkg.in/loremipsum.v1
This commit is contained in:
Pascal Bleser
2025-09-04 22:48:05 +02:00
parent f0ba3ee4f8
commit e75216e898
205 changed files with 24541 additions and 12 deletions

View File

@@ -0,0 +1,14 @@
package encoding
import (
"encoding/base64"
)
const (
encodeBase64Adapted = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./"
)
var (
// Base64RawAdaptedEncoding is the adapted encoding for crypt purposes without padding.
Base64RawAdaptedEncoding = base64.NewEncoding(encodeBase64Adapted).WithPadding(base64.NoPadding)
)

View File

@@ -0,0 +1,9 @@
package encoding
const (
// Delimiter rune for all encodings.
Delimiter = rune('$')
// DelimiterStr is the string variation of Delimiter.
DelimiterStr = string(Delimiter)
)

View File

@@ -0,0 +1,10 @@
package encoding
import (
"strings"
)
// Split an encoded digest by the encoding.Delimiter.
func Split(encodedDigest string, n int) (parts []string) {
return strings.SplitN(encodedDigest, DelimiterStr, n)
}

View File

@@ -0,0 +1,2 @@
// Package encoding is an internal encoding helper package.
package encoding

View File

@@ -0,0 +1,54 @@
package encoding
import (
"fmt"
"strconv"
"strings"
)
// Parameter is a key value pair.
type Parameter struct {
Key string
Value string
}
// Int converts the Value to an int using strconv.Atoi.
func (p Parameter) Int() (int, error) {
return strconv.Atoi(p.Value)
}
const (
// ParameterDefaultItemSeparator is the default item separator.
ParameterDefaultItemSeparator = ","
// ParameterDefaultKeyValueSeparator is the default key value separator.
ParameterDefaultKeyValueSeparator = "="
)
// DecodeParameterStr is an alias for DecodeParameterStrAdvanced using item separator and key value separator
// of ',' and '=' respectively.
func DecodeParameterStr(input string) (opts []Parameter, err error) {
return DecodeParameterStrAdvanced(input, ParameterDefaultItemSeparator, ParameterDefaultKeyValueSeparator)
}
// DecodeParameterStrAdvanced decodes parameter strings into a []Parameter where sepItem separates each parameter, and sepKV separates the key and value.
func DecodeParameterStrAdvanced(input string, sepItem, sepKV string) (opts []Parameter, err error) {
if input == "" {
return nil, fmt.Errorf("empty strings can't be decoded to parameters")
}
o := strings.Split(input, sepItem)
opts = make([]Parameter, len(o))
for i, joined := range o {
kv := strings.SplitN(joined, sepKV, 2)
if len(kv) != 2 {
return nil, fmt.Errorf("parameter pair '%s' is not properly encoded: does not contain kv separator '%s'", joined, sepKV)
}
opts[i] = Parameter{Key: kv[0], Value: kv[1]}
}
return opts, nil
}