From 7b37141e070bb1ad340af075d21a973885caf2a5 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Fri, 31 Dec 2021 16:12:53 +0100 Subject: [PATCH] Increase message size limit to 4096 --- server/config.go | 2 +- server/server_test.go | 5 +- server/smtp_server_test.go | 110 +++++++++++++++++++++++++++++++++++-- 3 files changed, 109 insertions(+), 8 deletions(-) diff --git a/server/config.go b/server/config.go index b5422baa..867a0f9c 100644 --- a/server/config.go +++ b/server/config.go @@ -13,7 +13,7 @@ const ( DefaultAtSenderInterval = 10 * time.Second DefaultMinDelay = 10 * time.Second DefaultMaxDelay = 3 * 24 * time.Hour - DefaultMessageLimit = 512 + DefaultMessageLimit = 4096 DefaultFirebaseKeepaliveInterval = time.Hour ) diff --git a/server/server_test.go b/server/server_test.go index 589b982c..e713e604 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -164,12 +164,13 @@ func TestServer_StaticSites(t *testing.T) { func TestServer_PublishLargeMessage(t *testing.T) { s := newTestServer(t, newTestConfig(t)) - body := strings.Repeat("this is a large message", 1000) - truncated := body[0:512] + body := strings.Repeat("this is a large message", 5000) + truncated := body[0:4096] response := request(t, s, "PUT", "/mytopic", body, nil) msg := toMessage(t, response.Body.String()) require.NotEmpty(t, msg.ID) require.Equal(t, truncated, msg.Message) + require.Equal(t, 4096, len(msg.Message)) response = request(t, s, "GET", "/mytopic/json?poll=1", "", nil) messages := toMessages(t, response.Body.String()) diff --git a/server/smtp_server_test.go b/server/smtp_server_test.go index 0ad1cf42..c954d124 100644 --- a/server/smtp_server_test.go +++ b/server/smtp_server_test.go @@ -124,14 +124,63 @@ Content-Type: text/plain; charset="UTF-8" you know this is a string. it's a long string. it's supposed to be longer than the max message length -which is 512 bytes, -which some people say is too short +which is 4096 bytes, +it used to be 512 bytes, but I increased that for the UnifiedPush support +the 512 bytes was a little short, some people said but it kinda makes sense when you look at what it looks like one a phone heck this wasn't even half of it so far. so i'm gonna fill the rest of this with AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... and with BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB @@ -141,15 +190,66 @@ that should do it expected := `you know this is a string. it's a long string. it's supposed to be longer than the max message length -which is 512 bytes, -which some people say is too short +which is 4096 bytes, +it used to be 512 bytes, but I increased that for the UnifiedPush support +the 512 bytes was a little short, some people said but it kinda makes sense when you look at what it looks like one a phone heck this wasn't even half of it so far. so i'm gonna fill the rest of this with AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -and with ` +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +...................................................................... +and with BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB +BBBBBBBBBBBBBBBBBBBBBBBB` + require.Equal(t, 4096, len(expected)) // Sanity check require.Equal(t, expected, m.Message) return nil })