01tonythomas has uploaded a new change for review.
https://gerrit.wikimedia.org/r/151867
Change subject: Added PHPunit tests for BounceHandler extesnsion
......................................................................
Added PHPunit tests for BounceHandler extesnsion
Test to check the IP whitelisting while a bouncehandler API request.
Change-Id: Ib3f7f5cf4ba0e04f8563d09cddc425dfd06e982e
---
A tests/ApiBounceHandlerTest.php
1 file changed, 36 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BounceHandler
refs/changes/67/151867/1
diff --git a/tests/ApiBounceHandlerTest.php b/tests/ApiBounceHandlerTest.php
new file mode 100644
index 0000000..a81ae77
--- /dev/null
+++ b/tests/ApiBounceHandlerTest.php
@@ -0,0 +1,36 @@
+<?php
+
+class ApiBounceHandlerTest extends ApiTestCase {
+
+ static $bounceEmail = "This is a test email";
+
+ function setUp() {
+ parent::setUp();
+ }
+
+ /**
+ * Tests API request from an allowed IP
+ */
+ function testBounceHandlerWithGoodIPPasses() {
+ $this->setMwGlobals( 'wgBounceHandlerInternalIPs', array(
'127.0.0.1' ) );
+ $apiResult = $this->doApiRequestWithToken( array(
+ 'action' => 'bouncehandler',
+ 'email' => self::$bounceEmail
+ ) );
+
+ $this->assertEquals( 'job',
$apiResult['bouncehandler']['submitted'] );
+ }
+
+ /**
+ * Tests API request from an unknown IP
+ */
+ function testBounceHandlerWithBadIPPasses() {
+ $this->setExpectedException( 'invalid-ip', 'This API module is
for internal use only.' );
+ $this->setMwGlobals( 'wgBounceHandlerInternalIPs', array(
'111.111.111.111' ) );
+ $apiResult = $this->doApiRequestWithToken( array(
+ 'action' => 'bouncehandler',
+ 'email' => self::$bounceEmail
+ ));
+ }
+
+}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/151867
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib3f7f5cf4ba0e04f8563d09cddc425dfd06e982e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BounceHandler
Gerrit-Branch: master
Gerrit-Owner: 01tonythomas <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits