Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 123852 | Differences between
and this patch

Collapse All | Expand All

(-)test/httpdconf.py (-1 / +18 lines)
Lines 37-44 Link Here
37
class Container:
37
class Container:
38
    
38
    
39
    def __init__(self, *args):
39
    def __init__(self, *args):
40
        self.args = args
40
        self.args = list(args)
41
        self.indent = 0
41
        self.indent = 0
42
    
43
    def append(self, value):
44
        self.args.append(value)
42
45
43
    def __str__(self):
46
    def __str__(self):
44
47
Lines 80-85 Link Here
80
    def __init__(self, val):
83
    def __init__(self, val):
81
        Directive.__init__(self, self.__class__.__name__, val)
84
        Directive.__init__(self, self.__class__.__name__, val)
82
85
86
class AuthBasicAuthoritative(Directive):
87
    # New in Apache 2.2
88
    def __init__(self, val):
89
        Directive.__init__(self, self.__class__.__name__, val)
90
91
class AuthBasicProvider(Directive):
92
    # New in Apache 2.2
93
    def __init__(self, val):
94
        Directive.__init__(self, self.__class__.__name__, val)
95
83
class AuthType(Directive):
96
class AuthType(Directive):
84
    def __init__(self, val):
97
    def __init__(self, val):
85
        Directive.__init__(self, self.__class__.__name__, val)
98
        Directive.__init__(self, self.__class__.__name__, val)
Lines 112-117 Link Here
112
    def __init__(self, dir, *args):
125
    def __init__(self, dir, *args):
113
        ContainerTag.__init__(self, self.__class__.__name__, dir, args)
126
        ContainerTag.__init__(self, self.__class__.__name__, dir, args)
114
127
128
class KeepAliveTimeout(Directive):
129
    def __init__(self, val):
130
        Directive.__init__(self, self.__class__.__name__, val)
131
115
class Listen(Directive):
132
class Listen(Directive):
116
    def __init__(self, val):
133
    def __init__(self, val):
117
        Directive.__init__(self, self.__class__.__name__, val)
134
        Directive.__init__(self, self.__class__.__name__, val)
(-)test/test.py (-4 / +62 lines)
Lines 220-225 Link Here
220
        s = '"%s"' % s
220
        s = '"%s"' % s
221
    return s
221
    return s
222
222
223
def get_apache_version():
224
225
    print "Checking Apache version...."
226
    httpd = quoteIfSpace(HTTPD)
227
    cmd = '%s -v' % (httpd)
228
    (stdin,stdout) = os.popen2(cmd)
229
230
    version_str = None
231
    for line in stdout:
232
        if line.startswith('Server version'):
233
             version_str = line.strip()
234
             break
235
236
    if version_str:
237
        version_str = version_str.split('/')[1]
238
        major,minor,patch = version_str.split('.',3)
239
        version = '%s.%s' % (major,minor)
240
    else:
241
        
242
        print "Can't determine Apache version. Assuming 2.0"
243
        version = '2.0'
244
    print version
245
    return version
246
247
APACHE_VERSION = get_apache_version()
248
223
class HttpdCtrl:
249
class HttpdCtrl:
224
    # a mixin providing ways to control httpd
250
    # a mixin providing ways to control httpd
225
251
Lines 289-302 Link Here
289
            Listen(PORT),
315
            Listen(PORT),
290
            PythonOption('PythonOptionTest sample_value'),
316
            PythonOption('PythonOptionTest sample_value'),
291
            DocumentRoot(DOCUMENT_ROOT),
317
            DocumentRoot(DOCUMENT_ROOT),
292
            LoadModule("python_module %s" % quoteIfSpace(MOD_PYTHON_SO)),
318
            LoadModule("python_module %s" % quoteIfSpace(MOD_PYTHON_SO)))
293
            IfModule("!mod_auth.c",
319
320
        if APACHE_VERSION == '2.2':
321
            # mod_auth has been split into mod_auth_basic and some other modules
322
            s.append(IfModule("!mod_auth_basic.c",
323
                     LoadModule("auth_basic_module %s" %
324
                                quoteIfSpace(os.path.join(modpath, "mod_auth_basic.so")))))
325
326
            # Default KeepAliveTimeout is 5 for apache 2.2, but 15 in apache 2.0
327
            # Explicitly set the value so it's the same as 2.0
328
            s.append(KeepAliveTimeout("15"))
329
        else:
330
            s.append(IfModule("!mod_auth.c",
294
                     LoadModule("auth_module %s" %
331
                     LoadModule("auth_module %s" %
295
                                quoteIfSpace(os.path.join(modpath, "mod_auth.so")))))
332
                                quoteIfSpace(os.path.join(modpath, "mod_auth.so")))))
296
333
334
        s.append("\n# --APPENDED-- \n\n"+append)
335
297
        f = open(CONFIG, "w")
336
        f = open(CONFIG, "w")
298
        f.write(str(s))
337
        f.write(str(s))
299
        f.write("\n# --APPENDED-- \n\n"+append)
300
        f.close()
338
        f.close()
301
339
302
    def startHttpd(self,extra=''):
340
    def startHttpd(self,extra=''):
Lines 595-601 Link Here
595
633
596
    def test_req_requires_conf(self):
634
    def test_req_requires_conf(self):
597
635
598
        c = VirtualHost("*",
636
        if APACHE_VERSION == '2.2':
637
            # Apache 2.2 needs AuthBasicAuthoritative Off 
638
            # This is necessary when combining mod_auth_basic with third-party
639
            # modules that are not configured with the AuthBasicProvider  
640
            # directive. 
641
            c = VirtualHost("*",
599
                        ServerName("test_req_requires"),
642
                        ServerName("test_req_requires"),
600
                        DocumentRoot(DOCUMENT_ROOT),
643
                        DocumentRoot(DOCUMENT_ROOT),
601
                        Directory(DOCUMENT_ROOT,
644
                        Directory(DOCUMENT_ROOT,
Lines 603-610 Link Here
603
                                  AuthName("blah"),
646
                                  AuthName("blah"),
604
                                  AuthType("basic"),
647
                                  AuthType("basic"),
605
                                  Require("valid-user"),
648
                                  Require("valid-user"),
649
                                  AuthBasicAuthoritative("Off"),
606
                                  PythonAuthenHandler("tests::req_requires"),
650
                                  PythonAuthenHandler("tests::req_requires"),
607
                                  PythonDebug("On")))
651
                                  PythonDebug("On")))
652
653
        else:
654
            # This configuration is suitable for Apache 2.0
655
            c = VirtualHost("*",
656
                        ServerName("test_req_requires"),
657
                        DocumentRoot(DOCUMENT_ROOT),
658
                        Directory(DOCUMENT_ROOT,
659
                                  SetHandler("mod_python"),
660
                                  AuthName("blah"),
661
                                  AuthType("basic"),
662
                                  Require("valid-user"),
663
                                  PythonAuthenHandler("tests::req_requires"),
664
                                  PythonDebug("On")))
665
608
        return str(c)
666
        return str(c)
609
667
610
    def test_req_requires(self):
668
    def test_req_requires(self):

Return to bug 123852