Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1430252
HSTSPreloadLookupTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
HSTSPreloadLookupTest.php
View Options
<?php
/**
* Copyright (C) 2018 Kunal Mehta <legoktm@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace
MediaWiki\SecureLinkFixer\Test
;
use
MediaWiki\SecureLinkFixer\HSTSPreloadLookup
;
use
MediaWikiIntegrationTestCase
;
use
Wikimedia\TestingAccessWrapper
;
/**
* @covers \MediaWiki\SecureLinkFixer\HSTSPreloadLookup
*/
class
HSTSPreloadLookupTest
extends
MediaWikiIntegrationTestCase
{
/**
* @dataProvider provideIsPreloaded
*/
public
function
testIsPreloaded
(
$host
,
$expected
)
{
$lookup
=
new
HSTSPreloadLookup
(
'dummy'
);
TestingAccessWrapper
::
newFromObject
(
$lookup
)->
domains
=
[
// TLD
'foobar'
=>
1
,
'secure-example.org'
=>
1
,
// includeSubdomains=false
'insecure-subdomains-example.org'
=>
0
,
// Subdomain is secure, root domain isn't
'secure.insecure-example.org'
=>
1
,
];
$this
->
assertSame
(
$expected
,
$lookup
->
isPreloaded
(
$host
)
);
}
public
static
function
provideIsPreloaded
()
{
return
[
[
'example.foobar'
,
true
],
[
'secure-example.org'
,
true
],
[
'subdomain.secure-example.org'
,
true
],
[
'insecure-subdomains-example.org'
,
true
],
[
'subdomain.insecure-subdomains-example.org'
,
false
],
[
'secure.insecure-example.org'
,
true
],
[
'insecure-example.org'
,
false
],
[
'not-preloaded.org'
,
false
],
[
'pathological.case.that.is.not.preloaded.org'
,
false
],
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 18:33 (5 h, 53 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6b/e5/98d008164c0aa5caff0b48db85ce
Default Alt Text
HSTSPreloadLookupTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment