feeds_push.test 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * @file
  4. * Contains FeedsPushTest.
  5. */
  6. /**
  7. * Tests for PubSubHubbub support in feeds.
  8. */
  9. class FeedsPushTest extends FeedsWebTestCase {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'PubSubHubbub',
  13. 'description' => 'Tests for PubSubHubbub support.',
  14. 'group' => 'Feeds',
  15. );
  16. }
  17. /**
  18. * Tests that PubSubHubbub challenge is escaped.
  19. */
  20. public function test() {
  21. $this->createImporterConfiguration('Push', 'push');
  22. $subscription = new PuSHSubscription('push', 0, 'http://example.com', 'http://example.com/feed', 'secret', 'unsubscribe', array());
  23. $subscription->save();
  24. $challenge = '<script>alert();</script>';
  25. $options = array(
  26. 'query' => array(
  27. 'hub.mode' => 'unsubscribe',
  28. 'hub.challenge' => $challenge,
  29. 'hub.topic' => 'http://example.com/feed',
  30. ),
  31. );
  32. $this->drupalGet("feeds/importer/push/0", $options);
  33. $this->assertResponse(200);
  34. $this->assertRaw(check_plain($challenge), 'Challenge was escaped.');
  35. $this->assertNoRaw($challenge, 'Raw challenge not found.');
  36. }
  37. }