You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by Jim Gallacher <jp...@jgassociates.ca> on 2006/02/18 23:35:29 UTC

duplicate method in request_methods[]

I just noticed that "write" is declared twice in request_methods[] . 
What's up with that??

src/requestobject.c
--------------------

static PyMethodDef request_methods[] = {
...
... line 1075
     {"write", (PyCFunction) req_write,  METH_VARARGS},

...
... line 1087
     {"write",  (PyCFunction) req_write,  METH_VARARGS},
...


Jim

Re: What is test_req_get_basic_auth_pw meant to test.

Posted by Graham Dumpleton <gr...@dscpl.com.au>.
I already fixed the test and checked it in. :-)

On 20/02/2006, at 5:15 AM, Jim Gallacher wrote:

> Yes, this test seems to be broken. I'll create a JIRA issue for it.
>
> We need unit tests for the unit tests. :)
>
> Jim
>
>> For my WTF moment, have a look at test_req_get_basic_auth_pw in the
>> test suite. I guess it is supposed to be test  
>> req.get_basic_auth_pw (), but
>> that function isn't even mentioned anywhere. Plus the  
>> authenhandler  phase
>> will not even be run since there is no Require directive in the   
>> configuration.
>> Even if you add the Require directive, it seems to be testing the   
>> mod_auth
>> module and not the ability to call req.get_basic_auth_pw().
>> Would it perhaps be better as:
>>     def test_req_get_basic_auth_pw_conf(self):
>>         c = VirtualHost("*",
>>                         ServerName("test_req_get_basic_auth_pw"),
>>                         DocumentRoot(DOCUMENT_ROOT),
>>                         Directory(DOCUMENT_ROOT,
>>                                   SetHandler("mod_python"),
>>                                   AuthName("blah"),
>>                                   AuthType("basic"),
>>                                   #PythonAuthenHandler  
>> ("tests::req_get_basic_auth_pw"),
>>                                   PythonHandler  
>> ("tests::req_get_basic_auth_pw"),
>>                                   PythonDebug("On")))
>>         return str(c)
>> def req_get_basic_auth_pw(req):
>>     req.get_basic_auth_pw()
>>     if req.user != "spam":
>>         req.write("test failed")
>>     else:
>>         req.write("test ok")
>>     return apache.OK
>> Graham


Re: What is test_req_get_basic_auth_pw meant to test.

Posted by Jim Gallacher <jp...@jgassociates.ca>.
Yes, this test seems to be broken. I'll create a JIRA issue for it.

We need unit tests for the unit tests. :)

Jim

> For my WTF moment, have a look at test_req_get_basic_auth_pw in the
> test suite. I guess it is supposed to be test req.get_basic_auth_pw (), but
> that function isn't even mentioned anywhere. Plus the authenhandler  phase
> will not even be run since there is no Require directive in the  
> configuration.
> Even if you add the Require directive, it seems to be testing the  mod_auth
> module and not the ability to call req.get_basic_auth_pw().
> 
> Would it perhaps be better as:
> 
>     def test_req_get_basic_auth_pw_conf(self):
>         c = VirtualHost("*",
>                         ServerName("test_req_get_basic_auth_pw"),
>                         DocumentRoot(DOCUMENT_ROOT),
>                         Directory(DOCUMENT_ROOT,
>                                   SetHandler("mod_python"),
>                                   AuthName("blah"),
>                                   AuthType("basic"),
>                                   #PythonAuthenHandler 
> ("tests::req_get_basic_auth_pw"),
>                                   PythonHandler 
> ("tests::req_get_basic_auth_pw"),
>                                   PythonDebug("On")))
>         return str(c)
> 
> 
> def req_get_basic_auth_pw(req):
> 
>     req.get_basic_auth_pw()
>     if req.user != "spam":
>         req.write("test failed")
>     else:
>         req.write("test ok")
> 
>     return apache.OK
> 
> Graham
> 
> 


What is test_req_get_basic_auth_pw meant to test.

Posted by Graham Dumpleton <gr...@dscpl.com.au>.
On 19/02/2006, at 9:35 AM, Jim Gallacher wrote:

> I just noticed that "write" is declared twice in request_methods 
> [] . What's up with that??
>
> src/requestobject.c
> --------------------
>
> static PyMethodDef request_methods[] = {
> ...
> ... line 1075
>     {"write", (PyCFunction) req_write,  METH_VARARGS},
>
> ...
> ... line 1087
>     {"write",  (PyCFunction) req_write,  METH_VARARGS},
> ...

For my WTF moment, have a look at test_req_get_basic_auth_pw in the
test suite. I guess it is supposed to be test req.get_basic_auth_pw 
(), but
that function isn't even mentioned anywhere. Plus the authenhandler  
phase
will not even be run since there is no Require directive in the  
configuration.
Even if you add the Require directive, it seems to be testing the  
mod_auth
module and not the ability to call req.get_basic_auth_pw().

Would it perhaps be better as:

     def test_req_get_basic_auth_pw_conf(self):
         c = VirtualHost("*",
                         ServerName("test_req_get_basic_auth_pw"),
                         DocumentRoot(DOCUMENT_ROOT),
                         Directory(DOCUMENT_ROOT,
                                   SetHandler("mod_python"),
                                   AuthName("blah"),
                                   AuthType("basic"),
                                   #PythonAuthenHandler 
("tests::req_get_basic_auth_pw"),
                                   PythonHandler 
("tests::req_get_basic_auth_pw"),
                                   PythonDebug("On")))
         return str(c)


def req_get_basic_auth_pw(req):

     req.get_basic_auth_pw()
     if req.user != "spam":
         req.write("test failed")
     else:
         req.write("test ok")

     return apache.OK

Graham