diff options
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://' + ); + } +} |