|
From: Claude P. <cl...@2x...> - 2008-09-23 19:03:14
|
Hi,
I'm probably missing something very obvious, but I can't figure it out.
I'm testing a Web form with SimpleTest (the form currently works well on
the Web), and when I do a $this->clickSubmit('Envoyer');, I'm getting a
"403 Forbidden" error (You don't have permission to
access /folder/file.php on this server).
That's strange, because if I do a simple get() with the same destination
as the form action URL, I'm getting the page (with an error in the page
content because there is no form data, of course).
I'm suspecting the problem is with the interpretation of the root (/) on
the server. Is it possible to tell SimpleTest to prefix all URLs with
the absolute path, including the domain name?
Claude
|
|
From: Marcus B. <ma...@wo...> - 2008-09-24 12:03:21
|
Hi... Claude Paroz wrote: > I'm suspecting the problem is with the interpretation of the root (/) on > the server. Is it possible to tell SimpleTest to prefix all URLs with > the absolute path, including the domain name? It should already be doing this. Can you post the full test method? Of course you could also set the base URL in the page, but that would involve modifying the page to get the test to work - which is a no-no :(. > > Claude yours, Marcus |
|
From: Claude P. <cl...@2x...> - 2008-09-24 19:45:19
|
Le mercredi 24 septembre 2008 à 11:33 +0100, Marcus Baker a écrit :
> Hi...
>
> Claude Paroz wrote:
> > I'm suspecting the problem is with the interpretation of the root (/) on
> > the server. Is it possible to tell SimpleTest to prefix all URLs with
> > the absolute path, including the domain name?
>
> It should already be doing this. Can you post the full test method?
class testDemandes extends WebTestCase {
function setUp() {
$this->get('http://www.bibles.ch/bibles/52_suisse.htm');
}
function testDemandeSuisse() {
$this->assertPattern('/Notre association offre gratuitement une
Bible/');
# Fill in form
$this->setField('Reactions', 'Test demande');
$this->setField('Prenom', 'Test prénom');
$this->setField('Nom', 'Test nom');
$this->setField('Adresse', 'Test adresse');
$this->setField('Codepostal', 'Test CP');
$this->setField('Ville', 'Test ville');
$this->setField('email', 'te...@em...');
$this->clickSubmit('Envoyer');
/* Debugging purpose */
/*$this->showRequest();
$this->showHeaders(); */
$this->assertPattern('/Votre demande a bien été enregistrée,
merci/');
}
function testDemandeSansFormulaire() {
$this->get('http://www.bibles.ch/bibles/demande.php');
$this->assertPattern('/Erreur: pas de données de formulaire/');
}
}
>
> Of course you could also set the base URL in the page, but that
> would involve modifying the page to get the test to work - which is
> a no-no :(.
I already tried to set an absolute URL in the action form property, with
no luck.
Claude
|
|
From: Claude P. <cl...@2x...> - 2008-09-26 16:18:27
|
Le vendredi 26 septembre 2008 à 17:03 +0100, Marcus Baker a écrit :
> Hi...
>
> Claude Paroz wrote:
> > class testDemandes extends WebTestCase {
>
> I get this page...
>
> --------
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
> <HTML><HEAD>
> <TITLE>403 Forbidden</TITLE>
> </HEAD><BODY>
> <H1>Forbidden</H1>
> You don't have permission to access /bibles/demande.php
> on this server.<P>
> </BODY></HTML>
> --------
Yes, that's also what I'm getting.
> That is, your own page is saying it's a request to
> "/bibles/demande.php", so it's not a URL parsing problem.
>
> Here is the request:
>
> --------
> POST /bibles/demande.php HTTP/1.0
> Host: www.bibles.ch
> Connection: close
> Content-Length: 194
> Content-Type: application/x-www-form-urlencoded
>
> bibleform=suisse&Reactions=Test+demande&Bible=OUI&Prenom=Test+pr%C3%A9nom&Nom=Test+nom&Adresse=Test+adresse&Codepostal=Test+CP&Ville=Test+ville&Pays=Suisse&email=test%40email.com&Envoyer=Envoyer
> --------
>
> Is this post request correct? What do you get if you use wireshark
> with a successful browser request?
Here is a valid request captured through Firefox Live HTTP headers :
POST /bibles/demande.php HTTP/1.1
Host: www.bibles.ch
User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.3)
Gecko/2008092510 Ubuntu/8.04 (hardy) Firefox/3.0.3 Ubuntu
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr-ch,fr-fr;q=0.8,en-us;q=0.6,en;q=0.4,de-ch;q=0.2
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.bibles.ch/bibles/52_suisse.htm
Content-Type: application/x-www-form-urlencoded
Content-Length: 154
bibleform=suisse&Reactions=Test&Bible=OUI&Prenom=Claude&Nom=Paroz&Adresse=test&Codepostal=1234&Ville=Test&Pays=Suisse&email=test%40test.ch&Envoyer=Envoyer
> Does your host accept HTTP 1.0
> requests for example?
I don't know. I have very few control on the host environment. Is
SimpleTest able to send HTTP 1.1 requests?
Claude
|
|
From: Claude P. <cl...@2x...> - 2008-09-27 12:47:49
|
Le vendredi 26 septembre 2008 à 19:41 +0100, Marcus Baker a écrit :
> Hi...
>
> Claude Paroz wrote:
> > I don't know. I have very few control on the host environment. Is
> > SimpleTest able to send HTTP 1.1 requests?
>
> You might be able to configure it in the browser.
>
> In the meantime try using addHeader() in SimpleTest to replicate the
> request exactly, especially referrer and accept headers.
Thanks, that did the trick! The "Referer" header was mandatory (at least
for this server). Adding a this->addHeader('Referer: <page.html>');
solved my problem.
It might by something to add by default in all submit requests in
SimpleTest.
Many thanks for the support.
Claude
|
|
From: Marcus B. <ma...@wo...> - 2008-09-27 15:08:45
|
Hi... Claude Paroz wrote: > It might by something to add by default in all submit requests in > SimpleTest. It absolutely should be. It's been a long standing omission. Once we get past a current run of drudge getting the 1.1 version ship shape, we can get back to ading features. > > Many thanks for the support. No problem. > > Claude yours, Marcus -- Marcus Baker ma...@la... |
|
From: Marcus B. <ma...@wo...> - 2008-09-26 15:58:29
|
Hi...
Claude Paroz wrote:
> class testDemandes extends WebTestCase {
I get this page...
--------
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>403 Forbidden</TITLE>
</HEAD><BODY>
<H1>Forbidden</H1>
You don't have permission to access /bibles/demande.php
on this server.<P>
</BODY></HTML>
--------
That is, your own page is saying it's a request to
"/bibles/demande.php", so it's not a URL parsing problem.
Here is the request:
--------
POST /bibles/demande.php HTTP/1.0
Host: www.bibles.ch
Connection: close
Content-Length: 194
Content-Type: application/x-www-form-urlencoded
bibleform=suisse&Reactions=Test+demande&Bible=OUI&Prenom=Test+pr%C3%A9nom&Nom=Test+nom&Adresse=Test+adresse&Codepostal=Test+CP&Ville=Test+ville&Pays=Suisse&email=test%40email.com&Envoyer=Envoyer
--------
Is this post request correct? What do you get if you use wireshark
with a successful browser request? Does your host accept HTTP 1.0
requests for example?
>
> Claude
yours, Marcus
|
|
From: Marcus B. <ma...@wo...> - 2008-09-26 18:36:27
|
Hi... Claude Paroz wrote: > I don't know. I have very few control on the host environment. Is > SimpleTest able to send HTTP 1.1 requests? You might be able to configure it in the browser. In the meantime try using addHeader() in SimpleTest to replicate the request exactly, especially referrer and accept headers. > > Claude yours, Marcus |