mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
98_HTTPMOD: added tests
git-svn-id: https://svn.fhem.de/fhem/trunk@22812 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
49fe92608a
commit
259ef6380f
5
fhem/t/FHEM/98_HTTPMOD/11_Cookies.cfg
Normal file
5
fhem/t/FHEM/98_HTTPMOD/11_Cookies.cfg
Normal file
@ -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
|
33
fhem/t/FHEM/98_HTTPMOD/11_Cookies.t
Normal file
33
fhem/t/FHEM/98_HTTPMOD/11_Cookies.t
Normal file
@ -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;
|
17
fhem/t/FHEM/98_HTTPMOD/11_Cookies1.testdata
Normal file
17
fhem/t/FHEM/98_HTTPMOD/11_Cookies1.testdata
Normal file
@ -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--
|
||||||
|
<html>
|
||||||
|
<head><title>Test</title></head>
|
||||||
|
<body>
|
||||||
|
<center><h1>Test</h1></center>
|
||||||
|
<hr><center>nginx</center>
|
||||||
|
</body>
|
||||||
|
</html>
|
16
fhem/t/FHEM/98_HTTPMOD/11_Cookies2.testdata
Normal file
16
fhem/t/FHEM/98_HTTPMOD/11_Cookies2.testdata
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
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: s=CgAD4ACBfTP9kM2Y5ZjQ1YmUxNzQwYTRjYzM0OTY5YzQzZmZmZmY2ZmRcvqYq; Domain=.test.url; Path=/; HttpOnly
|
||||||
|
Set-Cookie: ebay=%5Esbf%3D%23000000%5E; Domain=.test.url; Path=/
|
||||||
|
--end-of-http-header--
|
||||||
|
<html>
|
||||||
|
<head><title>Test</title></head>
|
||||||
|
<body>
|
||||||
|
<center><h1>Test</h1></center>
|
||||||
|
<hr><center>nginx</center>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,5 +1,5 @@
|
|||||||
define H2 HTTPMOD file://t/FHEM/98_HTTPMOD/Charset.testdata 0
|
define H2 HTTPMOD file://t/FHEM/98_HTTPMOD/Charset.testdata 0
|
||||||
attr H2 verbose 3
|
attr H2 verbose 5
|
||||||
attr H2 fileHeaderSplit --end-of-http-header--
|
attr H2 fileHeaderSplit --end-of-http-header--
|
||||||
attr H2 memReading 1
|
attr H2 memReading 1
|
||||||
attr H2 minSendDelay 0
|
attr H2 minSendDelay 0
|
||||||
|
@ -17,6 +17,7 @@ if ($major && $major >= 4) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fhem('attr H2 bodyDecode none');
|
fhem('attr H2 bodyDecode none');
|
||||||
|
fhem('attr H2 readingEncode none');
|
||||||
fhem('set H2 reread');
|
fhem('set H2 reread');
|
||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
@ -27,9 +28,10 @@ SKIP: {
|
|||||||
is(FhemTestUtils_gotEvent("H2:TestReading1: \x8e\x6e"), 1, "TestReading without bodyDecode");
|
is(FhemTestUtils_gotEvent("H2:TestReading1: \x8e\x6e"), 1, "TestReading without bodyDecode");
|
||||||
|
|
||||||
fhem('attr H2 bodyDecode auto');
|
fhem('attr H2 bodyDecode auto');
|
||||||
|
fhem('attr H2 readingEncode utf8');
|
||||||
fhem('set H2 reread');
|
fhem('set H2 reread');
|
||||||
|
|
||||||
is(FhemTestUtils_gotEvent("H2:TestReading1: \xc4\x6e"), 1, "TestReading with body decode");
|
is(FhemTestUtils_gotEvent("H2:TestReading1: \xc3\x84\x6e"), 1, "TestReading with body decode");
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
exit(0);
|
exit(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user