summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohannes Ernst <jernst@indiecomputing.com>2016-07-06 23:38:30 +0000
committerJohannes Ernst <jernst@indiecomputing.com>2016-07-06 23:38:30 +0000
commit2b4ceae620261a5433aa12acf5e2b385aef40ab8 (patch)
tree11660ff500f63788e58573efc0c3f8b5bce9b2fc /tests
parent3516b58be656f9f8a131ce68c5c1d0dd806f679c (diff)
downloadnextcloud-server-2b4ceae620261a5433aa12acf5e2b385aef40ab8.tar.gz
nextcloud-server-2b4ceae620261a5433aa12acf5e2b385aef40ab8.zip
Trusted domain wildcard checking made shorter, supporting multiple *
Added test cases
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Security/TrustedDomainHelperTest.php27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/lib/Security/TrustedDomainHelperTest.php b/tests/lib/Security/TrustedDomainHelperTest.php
index dfd51167cca..6c254dcaa79 100644
--- a/tests/lib/Security/TrustedDomainHelperTest.php
+++ b/tests/lib/Security/TrustedDomainHelperTest.php
@@ -49,6 +49,11 @@ class TrustedDomainHelperTest extends \Test\TestCase {
'host.two.test',
'[1fff:0:a88:85a3::ac1f]',
'host.three.test:443',
+ '*.leading.host',
+ 'trailing.host*',
+ 'cen*ter',
+ '*.leadingwith.port:123',
+ 'trailingwith.port*:456',
];
return [
// empty defaults to false with 8.1
@@ -76,7 +81,27 @@ class TrustedDomainHelperTest extends \Test\TestCase {
[$trustedHostTestList, 'localhost: evil.host', false],
// do not trust casting
[[1], '1', false],
+ // leading *
+ [$trustedHostTestList, 'abc.leading.host', true],
+ [$trustedHostTestList, 'abc.def.leading.host', true],
+ [$trustedHostTestList, 'abc.def.leading.host.another', false],
+ [$trustedHostTestList, 'abc.def.leading.host:123', true],
+ [$trustedHostTestList, 'leading.host', false],
+ // trailing *
+ [$trustedHostTestList, 'trailing.host', true],
+ [$trustedHostTestList, 'trailing.host.abc', true],
+ [$trustedHostTestList, 'trailing.host.abc.def', true],
+ [$trustedHostTestList, 'trailing.host.abc:123', true],
+ [$trustedHostTestList, 'another.trailing.host', false],
+ // center *
+ [$trustedHostTestList, 'center', true],
+ [$trustedHostTestList, 'cenxxxter', true],
+ [$trustedHostTestList, 'cen.x.y.ter', true],
+ // with port
+ [$trustedHostTestList, 'abc.leadingwith.port:123', true],
+ [$trustedHostTestList, 'abc.leadingwith.port:1234', false],
+ [$trustedHostTestList, 'trailingwith.port.abc:456', true],
+ [$trustedHostTestList, 'trailingwith.port.abc:123', false],
];
}
-
}