diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/tests/phpunit/includes/externalstore/ExternalStoreTest.php |
first commit
Diffstat (limited to 'www/wiki/tests/phpunit/includes/externalstore/ExternalStoreTest.php')
-rw-r--r-- | www/wiki/tests/phpunit/includes/externalstore/ExternalStoreTest.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/www/wiki/tests/phpunit/includes/externalstore/ExternalStoreTest.php b/www/wiki/tests/phpunit/includes/externalstore/ExternalStoreTest.php new file mode 100644 index 00000000..7ca38749 --- /dev/null +++ b/www/wiki/tests/phpunit/includes/externalstore/ExternalStoreTest.php @@ -0,0 +1,53 @@ +<?php + +class ExternalStoreTest extends MediaWikiTestCase { + + /** + * @covers ExternalStore::fetchFromURL + */ + public function testExternalFetchFromURL_noExternalStores() { + $this->setService( + 'ExternalStoreFactory', + new ExternalStoreFactory( [] ) + ); + + $this->assertFalse( + ExternalStore::fetchFromURL( 'ForTesting://cluster1/200' ), + 'Deny if wgExternalStores is not set to a non-empty array' + ); + } + + /** + * @covers ExternalStore::fetchFromURL + */ + public function testExternalFetchFromURL_someExternalStore() { + $this->setService( + 'ExternalStoreFactory', + new ExternalStoreFactory( [ 'ForTesting' ] ) + ); + + $this->assertEquals( + 'Hello', + ExternalStore::fetchFromURL( 'ForTesting://cluster1/200' ), + 'Allow FOO://cluster1/200' + ); + $this->assertEquals( + 'Hello', + ExternalStore::fetchFromURL( 'ForTesting://cluster1/300/0' ), + 'Allow FOO://cluster1/300/0' + ); + # Assertions for r68900 + $this->assertFalse( + ExternalStore::fetchFromURL( 'ftp.example.org' ), + 'Deny domain ftp.example.org' + ); + $this->assertFalse( + ExternalStore::fetchFromURL( '/example.txt' ), + 'Deny path /example.txt' + ); + $this->assertFalse( + ExternalStore::fetchFromURL( 'http://' ), + 'Deny protocol http://' + ); + } +} |