From 69273a27132bbd2e21ff21f4cacb1660a3223b6c Mon Sep 17 00:00:00 2001
From: Will McCutchen <will@mccutch.org>
Date: Wed, 3 Jul 2019 14:13:13 -0700
Subject: [PATCH] Test base64 corner cases

---
 httpbin/handlers_test.go | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/httpbin/handlers_test.go b/httpbin/handlers_test.go
index 3e26061..e554695 100644
--- a/httpbin/handlers_test.go
+++ b/httpbin/handlers_test.go
@@ -54,7 +54,7 @@ func assertContentType(t *testing.T, w *httptest.ResponseRecorder, contentType s
 
 func assertBodyContains(t *testing.T, w *httptest.ResponseRecorder, needle string) {
 	if !strings.Contains(w.Body.String(), needle) {
-		t.Fatalf("expected string %v in body", needle)
+		t.Fatalf("expected string %q in body %q", needle, w.Body.String())
 	}
 }
 
@@ -2254,6 +2254,22 @@ func TestBase64(t *testing.T) {
 			"/base64/decode/" + randStringBytes(Base64MaxLen+1),
 			"Cannot handle input",
 		},
+		{
+			"/base64/",
+			"No input data",
+		},
+		{
+			"/base64/decode/",
+			"No input data",
+		},
+		{
+			"/base64/decode/dmFsaWRfYmFzZTY0X2VuY29kZWRfc3RyaW5n/extra",
+			"Invalid URL",
+		},
+		{
+			"/base64/unknown/dmFsaWRfYmFzZTY0X2VuY29kZWRfc3RyaW5n",
+			"Invalid operation: unknown",
+		},
 	}
 
 	for _, test := range errorTests {
-- 
GitLab