diff --git a/t/FHEM/98_HTTPMOD/11_Cookies.cfg b/t/FHEM/98_HTTPMOD/11_Cookies.cfg new file mode 100644 index 000000000..286ea63d3 --- /dev/null +++ b/t/FHEM/98_HTTPMOD/11_Cookies.cfg @@ -0,0 +1,5 @@ +define H1 HTTPMOD file://t/FHEM/98_HTTPMOD/11_Cookies1.testdata 0 +attr H1 verbose 4 +attr H1 fileHeaderSplit --end-of-http-header-- +attr H1 queueDelay 0 +attr H1 minSendDelay 0 diff --git a/t/FHEM/98_HTTPMOD/11_Cookies.t b/t/FHEM/98_HTTPMOD/11_Cookies.t new file mode 100644 index 000000000..3d36357a6 --- /dev/null +++ b/t/FHEM/98_HTTPMOD/11_Cookies.t @@ -0,0 +1,33 @@ +############################################## +# test cookies +############################################## +use strict; +use warnings; +use Test::More; +#use Data::Dumper; + +my $hash = $defs{'H1'}; +my $modVersion = $hash->{ModuleVersion}; +$modVersion =~ /^([0-9]+)\./; +my $major = $1; + +if ($major && $major >= 4) { + plan tests => 3; +} else { + plan skip_all => "This test only works for HTTPMOD version 4 or later, installed is $modVersion"; +} + +fhem('set H1 reread'); + +#print Dumper($defs{H1}); + +fhem('set H1 reread'); + +is(FhemTestUtils_gotLog(qr/sends update with .*header.*DE630e14e5/s), 1, "Match cookie 1 in second request"); +is(FhemTestUtils_gotLog(qr/sends update with .*header.*CgAD4ACBfTP9kM2Y5ZjQ1YmUxNzQwYTRjYzM0OTY5YzQzZmZmZmY2Z/s), 1, "Match cookie 2 in second request"); +is(FhemTestUtils_gotLog(qr/sends update with .*header.*23000000/s), 1, "Match cookie 3 in second request"); + +done_testing; +exit(0); + +1; diff --git a/t/FHEM/98_HTTPMOD/11_Cookies1.testdata b/t/FHEM/98_HTTPMOD/11_Cookies1.testdata new file mode 100644 index 000000000..27f8b9f3e --- /dev/null +++ b/t/FHEM/98_HTTPMOD/11_Cookies1.testdata @@ -0,0 +1,17 @@ +HTTP/1.1 200 OK +Content-Type: text/html +Content-Length: 162 +Connection: close +Location: http://test.url/ +Set-Cookie: dp1=bbl/DE630e14e5^; Domain=.test.url; Path=/; Expires=Tue, 30 Aug 2022 13:47:17 GMT +Set-Cookie: nonsession=BAQAAAXQoEGjGAAaAADMABWEs4WU3NDA3OADKACBjDhTlM2Y5ZjQ1YmUxNzQwYTRjYzM0OTY5YzQzZmZmZmY2ZmQAywABX0u07TLAaYu0UeO4rce7q1K5pFM1stQGag**; Domain=.test.url; Path=/; Expires=Tue, 30 Aug 2022 13:47:17 GMT +Set-Cookie: s=CgAD4ACBfTP9kM2Y5ZjQ1YmUxNzQwYTRjYzM0OTY5YzQzZmZmZmY2ZmRcvqYq; Domain=.test.url; Path=/; HttpOnly +Set-Cookie: ebay=%5Esbf%3D%23000000%5E; Domain=.test.url; Path=/ +--end-of-http-header-- + +