tests: add mqtts support for testing

This commit is contained in:
Daniel Stenberg 2025-12-15 13:18:35 +01:00
parent 6288fdc688
commit 686a301209
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 38 additions and 4 deletions

View file

@ -125,7 +125,7 @@ sub servername_str {
$proto = uc($proto) if($proto);
die "unsupported protocol: '$proto'" unless($proto &&
($proto =~ /^(((DNS|FTP|HTTP|HTTP\/2|HTTP\/3|IMAP|POP3|GOPHER|SMTP|HTTPS-MTLS)S?)|(TFTP|SFTP|SOCKS|SSH|RTSP|HTTPTLS|DICT|SMB|SMBS|TELNET|MQTT))$/));
($proto =~ /^(((DNS|FTP|HTTP|HTTP\/2|HTTP\/3|IMAP|POP3|GOPHER|SMTP|HTTPS-MTLS)S?)|(TFTP|SFTP|SOCKS|SSH|RTSP|HTTPTLS|DICT|SMB|SMBS|TELNET|MQTT|MQTTS))$/));
$ipver = (not $ipver) ? 'ipv4' : lc($ipver);
die "unsupported IP version: '$ipver'" unless($ipver &&

View file

@ -237,8 +237,8 @@ sub init_serverpidfile_hash {
}
}
for my $proto (('tftp', 'sftp', 'socks', 'ssh', 'rtsp', 'httptls',
'dict', 'smb', 'smbs', 'telnet', 'mqtt', 'https-mtls',
'dns')) {
'dict', 'smb', 'smbs', 'telnet', 'mqtt', 'mqtts',
'https-mtls', 'dns')) {
for my $ipvnum ((4, 6)) {
for my $idnum ((1, 2)) {
my $serv = servername_id($proto, $ipvnum, $idnum);
@ -1030,6 +1030,7 @@ my %protofunc = ('http' => \&verifyhttp,
'pop3s' => \&verifyftp,
'imaps' => \&verifyftp,
'mqtt' => \&verifypid,
'mqtts' => \&verifypid,
'smtps' => \&verifyftp,
'tftp' => \&verifyftp,
'ssh' => \&verifyssh,
@ -1329,6 +1330,9 @@ sub runhttpsserver {
if($proto eq "gophers") {
$flags .= "--connect " . protoport("gopher");
}
elsif($proto eq "mqtts") {
$flags .= "--connect " . protoport("mqtt");
}
elsif(!$proxy) {
$flags .= "--connect " . protoport("http");
}
@ -2955,6 +2959,36 @@ sub startservers {
$run{'mqtt'}="$pid $pid2";
}
}
elsif($what eq "mqtts" ) {
if(!$stunnel) {
# we cannot run mqtts tests without stunnel
return ("no stunnel", 4);
}
if($run{'mqtt'} &&
!responsive_mqtt_server("mqtt", "", $verbose)) {
if(stopserver('mqtt')) {
return ("failed stopping unresponsive MQTT server", 3);
}
}
if(!$run{'mqtt'}) {
($serr, $pid, $pid2, $PORT{"mqtt"}) = runmqttserver("", $verbose);
if($pid <= 0) {
return ("failed starting mqtt server", $serr);
}
logmsg sprintf("* pid mqtt => %d %d\n", $pid, $pid2) if($verbose);
$run{'mqtt'}="$pid $pid2";
}
if(!$run{$what}) {
($serr, $pid, $pid2, $PORT{$what}) =
runhttpsserver($verbose, $what, "", $certfile);
if($pid <= 0) {
return ("failed starting MQTTS server (stunnel)", $serr);
}
logmsg sprintf("* pid $what => %d %d\n", $pid, $pid2)
if($verbose);
$run{$what}="$pid $pid2";
}
}
elsif($what eq "http-unix") {
if($run{'http-unix'} &&
!responsive_http_server("http", $verbose, "unix", $HTTPUNIXPATH)) {
@ -3094,7 +3128,7 @@ sub subvariables {
'HTTP2', 'HTTP2TLS',
'HTTP3',
'IMAP', 'IMAP6', 'IMAPS',
'MQTT',
'MQTT', 'MQTTS',
'NOLISTEN',
'POP3', 'POP36', 'POP3S',
'RTSP', 'RTSP6',