REGTESTS: healthcheckmail: Update the test to be functionnal again

This reg-test is broken since a while. It was simplified to be
functionnal. Now, it only test email alerts.

(cherry picked from commit 52912579eea3680952c7dd9e80c8ea5c298eeca3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 6ad2f99a7f03652fc86837c37e3dce81b822b162)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 00fc0b6f9db548bb9121dccd3a29a6a48875f12f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/reg-tests/mailers/healthcheckmail.lua b/reg-tests/mailers/healthcheckmail.lua
index 50b561c..4cb0e9d 100644
--- a/reg-tests/mailers/healthcheckmail.lua
+++ b/reg-tests/mailers/healthcheckmail.lua
@@ -4,46 +4,6 @@
 local mailconnectionsmade = 0
 local healthcheckcounter = 0
 
-core.register_action("bug", { "http-res" }, function(txn)
-	data = txn:get_priv()
-	if not data then
-		data = 0
-	end
-	data = data + 1
-	print(string.format("set to %d", data))
-	txn.http:res_set_status(200 + data)
-	txn:set_priv(data)
-end)
-
-core.register_service("luahttpservice", "http", function(applet)
-	local response = "?"
-	local responsestatus = 200
-       if applet.path == "/setport" then
-		vtc_port1 = applet.headers["vtcport1"][0]
-		response = "OK"
-	end
-	if applet.path == "/svr_healthcheck" then
-		healthcheckcounter = healthcheckcounter + 1
-		if healthcheckcounter < 2 or healthcheckcounter > 6 then
-			responsestatus = 403
-		end
-	end
-
-	applet:set_status(responsestatus)
-       if applet.path == "/checkMailCounters" then
-		response = "MailCounters"
-		applet:add_header("mailsreceived", mailsreceived)
-		applet:add_header("mailconnectionsmade", mailconnectionsmade)
-	end
-	applet:start_response()
-	applet:send(response)
-end)
-
-core.register_service("fakeserv", "http", function(applet)
-	applet:set_status(200)
-	applet:start_response()
-end)
-
 function RecieveAndCheck(applet, expect)
 	data = applet:getline()
 	if data:sub(1,expect:len()) ~= expect then
@@ -60,20 +20,24 @@
 	applet:send("220 Welcome\r\n")
 	local data
 
-	if RecieveAndCheck(applet, "EHLO") == false then
-		return
+	if RecieveAndCheck(applet, "HELO") == false then
+	   applet:set_var("txn.result", "ERROR (step: HELO)")
+	   return
 	end
 	applet:send("250 OK\r\n")
 	if RecieveAndCheck(applet, "MAIL FROM:") == false then
-		return
+	   applet:set_var("txn.result", "ERROR (step: MAIL FROM)")
+	   return
 	end
 	applet:send("250 OK\r\n")
 	if RecieveAndCheck(applet, "RCPT TO:") == false then
-		return
+	   applet:set_var("txn.result", "ERROR (step: RCPT TO)")
+	   return
 	end
 	applet:send("250 OK\r\n")
 	if RecieveAndCheck(applet, "DATA") == false then
-		return
+	   applet:set_var("txn.result", "ERROR (step: DATA)")
+	   return
 	end
 	applet:send("354 OK\r\n")
 	core.Info("#### Send your mailbody")
@@ -83,7 +47,7 @@
 		data = applet:getline() -- BODY CONTENT
 		--core.Info(data)
 		if data:sub(1, 9) == "Subject: " then
-			subject = data
+		   subject = data
 		end
 		if (data == "\r\n") then
 			data = applet:getline() -- BODY CONTENT
@@ -97,9 +61,10 @@
 	applet:send("250 OK\r\n")
 
 	if RecieveAndCheck(applet, "QUIT") == false then
-		return
+	   applet:set_var("txn.result", "ERROR (step: QUIT)")
+	   return
 	end
 	applet:send("221 Mail queued for delivery to /dev/null \r\n")
 	core.Info("Mail queued for delivery to /dev/null subject: "..subject)
-	mailsreceived = mailsreceived + 1
+	applet:set_var("txn.result", "SUCCESS")
 end)