TestingParty08: drupal_http_request redirects need a test

chx - August 17, 2008 - 08:10
Project:Drupal
Version:7.x-dev
Component:tests
Category:bug report
Priority:critical
Assigned:domas
Status:closed
Description

Assert that if you drupal_http_request a page and that issues a 301, 302, 307 response code then it's redirected properly if and only if when the appropriate parameter is passed to drupal_http_request /

#1

flobruit - August 28, 2008 - 08:50

#296307: TestingParty08: drupal_http_request basic auth needs a test already sets up a dummy module for drupal_http_request. That patch can probably be used as a starting point for the current issue.

#2

domas - August 30, 2008 - 07:29
Priority:critical» normal
Status:active» needs review

This is the patch adding the tests (I started working during the testing party, but didn't finish it on time). I have included the above mentioned patch.

If there are any comments regarding the code quality (or anything else for that matter), please let me know.

AttachmentSizeStatusTest resultOperations
drupal_request.patch5.62 KBIgnoredNoneNone

#3

boombatower - August 30, 2008 - 23:51
Status:needs review» reviewed & tested by the community

Few very minor things:

  • Missing $Id$ at top of module file.
  • Added comment: Implementation of setUp(). to added setUp() method.
  • Core now uses uses spaces on both sides of dot.
  • Removed trailing white-space and on blank lines.
  • Parameters to function usually not split up on separate lines when they are small.

Test looks good, ran test and it passes.

AttachmentSizeStatusTest resultOperations
drupal_request.patch5.28 KBIgnoredNoneNone

#4

boombatower - August 30, 2008 - 23:59

This patch includes the test by flobruit and nickske from: #296307: TestingParty08: drupal_http_request basic auth needs a test which I have marked as a duplicate.

#5

dmitrig01 - August 31, 2008 - 03:10

the .module should be:

<?php
// $Id$

/**
* Implementation of hook_menu().
*/
function drupal_http_request_test_menu() {
 
$items = array();

 
$items['drupal_http_request_test'] = array(
   
'page callback' => 'drupal_http_request_test_basic_auth_page',
   
'access callback' => TRUE,
   
'type' => MENU_CALLBACK,
  );

 
$items['drupal_http_request_test/%'] = array(
   
'title' => t('Redirect'),
   
'page callback' => 'drupal_http_request_test',
   
'access arguments' => array('access content'),
   
'type' => MENU_CALLBACK,
  );

  return
$items;
}

function
drupal_http_request_test_basic_auth_page() {
 
$output = t('$_SERVER[\'PHP_AUTH_USER\'] is @username.', array('@username' => $_SERVER['PHP_AUTH_USER']));
 
$output .= t('$_SERVER[\'PHP_AUTH_PW\'] is @password.', array('@password' => $_SERVER['PHP_AUTH_PW']));
  return
$output;
}

function
drupal_http_request_test($code) {
  if (
$code != 200) {
   
header("Location: " . url('drupal_http_request_test/200', array('absolute' => TRUE)), TRUE, $code);
    exit;
  }
  return
'';
}
?>

#6

boombatower - August 31, 2008 - 03:51

Sure, that is cleaner. Missing 'page arguments', but otherwise it works.

AttachmentSizeStatusTest resultOperations
drupal_request.patch4.35 KBIgnoredNoneNone

#7

Dries - August 31, 2008 - 08:22
Status:reviewed & tested by the community» needs work

* I'm not sure we should create a dedicated module for this test. It feels like it would be better to create a more generic system_test.module or something along these lines.

* We don't use underscores in URLs. Use dashes instead, and consider to shorten the URLs.

#8

domas - August 31, 2008 - 12:40
Assigned to:Anonymous» domas

I'm on it - will fix this soon.

#9

domas - August 31, 2008 - 13:46
Status:needs work» needs review

Ok, I've created a system_test module, that does all the support work. The patch includes the changes made in #296299: TestingParty08: drupal_get_destination with a query needs a test and #296307: TestingParty08: drupal_http_request basic auth needs a test.

Looking forward to any replies regarding the code quality. (or anything else for that matter)

AttachmentSizeStatusTest resultOperations
system_test.patch4.97 KBIgnoredNoneNone

#10

mustafau - August 31, 2008 - 22:38

Extended tests with parameter "$retry" set to "0".

Added redirect to invalid URL tests.

AttachmentSizeStatusTest resultOperations
system_test.patch7.99 KBIgnoredNoneNone

#11

boombatower - September 1, 2008 - 22:53
Status:needs review» reviewed & tested by the community

Tests look thorough, pass, and now use a standard system_test.module.

Looks like good work.

Test results:

19 passes, 0 fails, 0 exceptions

#12

Dries - September 2, 2008 - 17:01
Status:reviewed & tested by the community» fixed

Excellent. Thanks for incorporating my feedback so quickly. Committed to CVS HEAD. Thanks ...

#13

webchick - September 4, 2008 - 02:37
Priority:normal» critical
Status:fixed» active

I get unresponsive script errors whenever I run this test in FF3 on OSX. Didn't get a chance to look more closely at it yet.

#14

webchick - September 4, 2008 - 03:04

I looked in the simpletest table in the database. This is the last row to get inserted before it times out:

"The query passed to the page is correctly represented by drupal_get_detination()."

It's very strange, because that's the last assertion in common.test. I tried commenting its parent function, testDrupalGetDestination(), out but no dice.

#15

domas - September 5, 2008 - 08:14

Really strange. The tests work fine for me (FF3 under linux). Can anybody else reproduce this problem? Coudl it be not due to the test itself? Do any other tests cause this?

#16

boombatower - September 5, 2008 - 17:28

Runs fine FF3 SUSE 11.0 (linux).

#17

boombatower - September 5, 2008 - 17:28
Status:active» postponed (maintainer needs more info)

#18

webchick - September 5, 2008 - 18:04

I'll try digging in and debugging this tonight. Good to know Linux is unaffected. I'll see if I can scrounge up some Mac users to test.

#19

boombatower - September 5, 2008 - 18:09

#20

Damien Tournoud - September 6, 2008 - 14:14
Status:postponed (maintainer needs more info)» needs review

Oh, god, that test was *silly*.

<?php
  $this
->assertEqual($redirect_301->redirect_code, 200, t('drupal_http_request follows the 301 redirect.'));
?>

Come on! That's a "if there is a bug, print that there is none".

@webchick: what you were experiencing are notices in drupal_http_request that broke the batch API somehow.

This patch fixes both drupal_http_request and the test.

AttachmentSizeStatusTest resultOperations
296310-what-about-reading-tests.patch3.14 KBIgnoredNoneNone

#21

webchick - September 6, 2008 - 15:06
Status:needs review» fixed

Committed. Love it when tests find bugs. Yay! :)

#22

domas - September 6, 2008 - 19:34

Sorry, my bad. For some reason I thought redirect_code is supposed to return the code of the final response, which should be 200 (response of the page we redirected to).

#23

boombatower - September 6, 2008 - 21:27

Sweet!

#24

mustafau - September 7, 2008 - 14:25
Status:fixed» needs work

This fix was wrong and should be reverted. The real fix to the bug is here: http://drupal.org/node/293529#comment-960905

#25

Damien Tournoud - September 7, 2008 - 15:22
Status:needs work» fixed

Let's this issue die peacefully. I'll answer in the other one.

#26

Anonymous (not verified) - September 21, 2008 - 15:22
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.