Tres Seaver
2013-04-26 1d7c1956bf6a25448a58e6fdc531fde0703cbbf6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
import unittest
 
class _Base(unittest.TestCase):
 
    def failUnless(self, predicate, message=''):
        self.assertTrue(predicate, message) # Nannies go home!
 
    def failIf(self, predicate, message=''):
        self.assertFalse(predicate, message) # Nannies go home!
 
class TestWhoConfig(_Base):
 
    def _getTargetClass(self):
        from repoze.who.config import WhoConfig
        return WhoConfig
 
    def _makeOne(self, here='/', *args, **kw):
        return self._getTargetClass()(here, *args, **kw)
 
    def _getDummyPluginClass(self, iface):
        from zope.interface import classImplements
        if not iface.implementedBy(DummyPlugin):
            classImplements(DummyPlugin, iface)
        return DummyPlugin
 
    def test_defaults_before_parse(self):
        config = self._makeOne()
        self.assertEqual(config.request_classifier, None)
        self.assertEqual(config.challenge_decider, None)
        self.assertEqual(config.remote_user_key, 'REMOTE_USER')
        self.assertEqual(len(config.plugins), 0)
        self.assertEqual(len(config.identifiers), 0)
        self.assertEqual(len(config.authenticators), 0)
        self.assertEqual(len(config.challengers), 0)
        self.assertEqual(len(config.mdproviders), 0)
 
    def test_parse_empty_string(self):
        config = self._makeOne()
        config.parse('')
        self.assertEqual(config.request_classifier, None)
        self.assertEqual(config.challenge_decider, None)
        self.assertEqual(config.remote_user_key, 'REMOTE_USER')
        self.assertEqual(len(config.plugins), 0)
        self.assertEqual(len(config.identifiers), 0)
        self.assertEqual(len(config.authenticators), 0)
        self.assertEqual(len(config.challengers), 0)
        self.assertEqual(len(config.mdproviders), 0)
 
    def test_parse_empty_file(self):
        from repoze.who._compat import StringIO
        config = self._makeOne()
        config.parse(StringIO())
        self.assertEqual(config.request_classifier, None)
        self.assertEqual(config.challenge_decider, None)
        self.assertEqual(config.remote_user_key, 'REMOTE_USER')
        self.assertEqual(len(config.plugins), 0)
        self.assertEqual(len(config.identifiers), 0)
        self.assertEqual(len(config.authenticators), 0)
        self.assertEqual(len(config.challengers), 0)
        self.assertEqual(len(config.mdproviders), 0)
 
    def test_parse_plugins(self):
        config = self._makeOne()
        config.parse(PLUGINS_ONLY)
        self.assertEqual(len(config.plugins), 2)
        self.failUnless(isinstance(config.plugins['foo'],
                                   DummyPlugin))
        bar = config.plugins['bar']
        self.failUnless(isinstance(bar, DummyPlugin))
        self.assertEqual(bar.credentials, 'qux')
 
    def test_parse_general_empty(self):
        config = self._makeOne()
        config.parse('[general]')
        self.assertEqual(config.request_classifier, None)
        self.assertEqual(config.challenge_decider, None)
        self.assertEqual(config.remote_user_key, 'REMOTE_USER')
        self.assertEqual(len(config.plugins), 0)
 
    def test_parse_general_only(self):
        from repoze.who.interfaces import IRequestClassifier
        from repoze.who.interfaces import IChallengeDecider
        class IDummy(IRequestClassifier, IChallengeDecider):
            pass
        PLUGIN_CLASS = self._getDummyPluginClass(IDummy)
        config = self._makeOne()
        config.parse(GENERAL_ONLY)
        self.failUnless(isinstance(config.request_classifier, PLUGIN_CLASS))
        self.failUnless(isinstance(config.challenge_decider, PLUGIN_CLASS))
        self.assertEqual(config.remote_user_key, 'ANOTHER_REMOTE_USER')
        self.assertEqual(len(config.plugins), 0)
 
    def test_parse_general_with_plugins(self):
        from repoze.who.interfaces import IRequestClassifier
        from repoze.who.interfaces import IChallengeDecider
        class IDummy(IRequestClassifier, IChallengeDecider):
            pass
        PLUGIN_CLASS = self._getDummyPluginClass(IDummy)
        config = self._makeOne()
        config.parse(GENERAL_WITH_PLUGINS)
        self.failUnless(isinstance(config.request_classifier, PLUGIN_CLASS))
        self.failUnless(isinstance(config.challenge_decider, PLUGIN_CLASS))
 
    def test_parse_identifiers_only(self):
        from repoze.who.interfaces import IIdentifier
        PLUGIN_CLASS = self._getDummyPluginClass(IIdentifier)
        config = self._makeOne()
        config.parse(IDENTIFIERS_ONLY)
        identifiers = config.identifiers
        self.assertEqual(len(identifiers), 2)
        first, second = identifiers
        self.assertEqual(first[0], 'repoze.who.tests.test_config:DummyPlugin')
        self.failUnless(isinstance(first[1], PLUGIN_CLASS))
        self.assertEqual(len(first[1].classifications), 1)
        self.assertEqual(first[1].classifications[IIdentifier], 'klass1')
        self.assertEqual(second[0], 'repoze.who.tests.test_config:DummyPlugin')
        self.failUnless(isinstance(second[1], PLUGIN_CLASS))
 
    def test_parse_identifiers_with_plugins(self):
        from repoze.who.interfaces import IIdentifier
        PLUGIN_CLASS = self._getDummyPluginClass(IIdentifier)
        config = self._makeOne()
        config.parse(IDENTIFIERS_WITH_PLUGINS)
        identifiers = config.identifiers
        self.assertEqual(len(identifiers), 2)
        first, second = identifiers
        self.assertEqual(first[0], 'foo')
        self.failUnless(isinstance(first[1], PLUGIN_CLASS))
        self.assertEqual(len(first[1].classifications), 1)
        self.assertEqual(first[1].classifications[IIdentifier], 'klass1')
        self.assertEqual(second[0], 'bar')
        self.failUnless(isinstance(second[1], PLUGIN_CLASS))
 
    def test_parse_authenticators_only(self):
        from repoze.who.interfaces import IAuthenticator
        PLUGIN_CLASS = self._getDummyPluginClass(IAuthenticator)
        config = self._makeOne()
        config.parse(AUTHENTICATORS_ONLY)
        authenticators = config.authenticators
        self.assertEqual(len(authenticators), 2)
        first, second = authenticators
        self.assertEqual(first[0], 'repoze.who.tests.test_config:DummyPlugin')
        self.failUnless(isinstance(first[1], PLUGIN_CLASS))
        self.assertEqual(len(first[1].classifications), 1)
        self.assertEqual(first[1].classifications[IAuthenticator], 'klass1')
        self.assertEqual(second[0], 'repoze.who.tests.test_config:DummyPlugin')
        self.failUnless(isinstance(second[1], PLUGIN_CLASS))
 
    def test_parse_authenticators_with_plugins(self):
        from repoze.who.interfaces import IAuthenticator
        PLUGIN_CLASS = self._getDummyPluginClass(IAuthenticator)
        config = self._makeOne()
        config.parse(AUTHENTICATORS_WITH_PLUGINS)
        authenticators = config.authenticators
        self.assertEqual(len(authenticators), 2)
        first, second = authenticators
        self.assertEqual(first[0], 'foo')
        self.failUnless(isinstance(first[1], PLUGIN_CLASS))
        self.assertEqual(len(first[1].classifications), 1)
        self.assertEqual(first[1].classifications[IAuthenticator], 'klass1')
        self.assertEqual(second[0], 'bar')
        self.failUnless(isinstance(second[1], PLUGIN_CLASS))
 
    def test_parse_challengers_only(self):
        from repoze.who.interfaces import IChallenger
        PLUGIN_CLASS = self._getDummyPluginClass(IChallenger)
        config = self._makeOne()
        config.parse(CHALLENGERS_ONLY)
        challengers = config.challengers
        self.assertEqual(len(challengers), 2)
        first, second = challengers
        self.assertEqual(first[0], 'repoze.who.tests.test_config:DummyPlugin')
        self.failUnless(isinstance(first[1], PLUGIN_CLASS))
        self.assertEqual(len(first[1].classifications), 1)
        self.assertEqual(first[1].classifications[IChallenger], 'klass1')
        self.assertEqual(second[0], 'repoze.who.tests.test_config:DummyPlugin')
        self.failUnless(isinstance(second[1], PLUGIN_CLASS))
 
    def test_parse_challengers_with_plugins(self):
        from repoze.who.interfaces import IChallenger
        PLUGIN_CLASS = self._getDummyPluginClass(IChallenger)
        config = self._makeOne()
        config.parse(CHALLENGERS_WITH_PLUGINS)
        challengers = config.challengers
        self.assertEqual(len(challengers), 2)
        first, second = challengers
        self.assertEqual(first[0], 'foo')
        self.failUnless(isinstance(first[1], PLUGIN_CLASS))
        self.assertEqual(len(first[1].classifications), 1)
        self.assertEqual(first[1].classifications[IChallenger], 'klass1')
        self.assertEqual(second[0], 'bar')
        self.failUnless(isinstance(second[1], PLUGIN_CLASS))
 
    def test_parse_mdproviders_only(self):
        from repoze.who.interfaces import IMetadataProvider
        PLUGIN_CLASS = self._getDummyPluginClass(IMetadataProvider)
        config = self._makeOne()
        config.parse(MDPROVIDERS_ONLY)
        mdproviders = config.mdproviders
        self.assertEqual(len(mdproviders), 2)
        first, second = mdproviders
        self.assertEqual(first[0], 'repoze.who.tests.test_config:DummyPlugin')
        self.failUnless(isinstance(first[1], PLUGIN_CLASS))
        self.assertEqual(len(first[1].classifications), 1)
        self.assertEqual(first[1].classifications[IMetadataProvider], 'klass1')
        self.assertEqual(second[0], 'repoze.who.tests.test_config:DummyPlugin')
        self.failUnless(isinstance(second[1], PLUGIN_CLASS))
 
    def test_parse_mdproviders_with_plugins(self):
        from repoze.who.interfaces import IMetadataProvider
        PLUGIN_CLASS = self._getDummyPluginClass(IMetadataProvider)
        config = self._makeOne()
        config.parse(MDPROVIDERS_WITH_PLUGINS)
        mdproviders = config.mdproviders
        self.assertEqual(len(mdproviders), 2)
        first, second = mdproviders
        self.assertEqual(first[0], 'foo')
        self.failUnless(isinstance(first[1], PLUGIN_CLASS))
        self.assertEqual(len(first[1].classifications), 1)
        self.assertEqual(first[1].classifications[IMetadataProvider], 'klass1')
        self.assertEqual(second[0], 'bar')
        self.failUnless(isinstance(second[1], PLUGIN_CLASS))
 
    def test_parse_make_plugin_names(self):
        # see http://bugs.repoze.org/issue92
        config = self._makeOne()
        config.parse(MAKE_PLUGIN_ARG_NAMES)
        self.assertEqual(len(config.plugins), 1)
        foo = config.plugins['foo']
        self.failUnless(isinstance(foo, DummyPlugin))
        self.assertEqual(foo.iface, 'iface')
        self.assertEqual(foo.name, 'name')
        self.assertEqual(foo.template, '%(template)s')
        self.assertEqual(foo.template_with_eq,
                         'template_with_eq = %(template_with_eq)s')
 
class DummyPlugin:
    def __init__(self, **kw):
        self.__dict__.update(kw)
 
PLUGINS_ONLY = """\
[plugin:foo]
use = repoze.who.tests.test_config:DummyPlugin
 
[plugin:bar]
use = repoze.who.tests.test_config:DummyPlugin
credentials = qux
"""
 
GENERAL_ONLY = """\
[general]
request_classifier = repoze.who.tests.test_config:DummyPlugin
challenge_decider = repoze.who.tests.test_config:DummyPlugin
remote_user_key = ANOTHER_REMOTE_USER
"""
 
GENERAL_WITH_PLUGINS = """\
[general]
request_classifier = classifier
challenge_decider = decider
 
[plugin:classifier]
use = repoze.who.tests.test_config:DummyPlugin
 
[plugin:decider]
use = repoze.who.tests.test_config:DummyPlugin
"""
 
IDENTIFIERS_ONLY = """\
[identifiers]
plugins =
    repoze.who.tests.test_config:DummyPlugin;klass1
    repoze.who.tests.test_config:DummyPlugin
"""
 
IDENTIFIERS_WITH_PLUGINS = """\
[identifiers]
plugins =
    foo;klass1
    bar
 
[plugin:foo]
use = repoze.who.tests.test_config:DummyPlugin
 
[plugin:bar]
use = repoze.who.tests.test_config:DummyPlugin
"""
 
AUTHENTICATORS_ONLY = """\
[authenticators]
plugins =
    repoze.who.tests.test_config:DummyPlugin;klass1
    repoze.who.tests.test_config:DummyPlugin
"""
 
AUTHENTICATORS_WITH_PLUGINS = """\
[authenticators]
plugins =
    foo;klass1
    bar
 
[plugin:foo]
use = repoze.who.tests.test_config:DummyPlugin
 
[plugin:bar]
use = repoze.who.tests.test_config:DummyPlugin
"""
 
CHALLENGERS_ONLY = """\
[challengers]
plugins =
    repoze.who.tests.test_config:DummyPlugin;klass1
    repoze.who.tests.test_config:DummyPlugin
"""
 
CHALLENGERS_WITH_PLUGINS = """\
[challengers]
plugins =
    foo;klass1
    bar
 
[plugin:foo]
use = repoze.who.tests.test_config:DummyPlugin
 
[plugin:bar]
use = repoze.who.tests.test_config:DummyPlugin
"""
 
MDPROVIDERS_ONLY = """\
[mdproviders]
plugins =
    repoze.who.tests.test_config:DummyPlugin;klass1
    repoze.who.tests.test_config:DummyPlugin
"""
 
MDPROVIDERS_WITH_PLUGINS = """\
[mdproviders]
plugins =
    foo;klass1
    bar
 
[plugin:foo]
use = repoze.who.tests.test_config:DummyPlugin
 
[plugin:bar]
use = repoze.who.tests.test_config:DummyPlugin
"""
 
MAKE_PLUGIN_ARG_NAMES = """\
[plugin:foo]
use = repoze.who.tests.test_config:DummyPlugin
name = name
iface = iface
template = %%(template)s
template_with_eq = template_with_eq = %%(template_with_eq)s
"""
 
class TestConfigMiddleware(_Base):
    _tempdir = None
 
    def setUp(self):
        pass
 
    def tearDown(self):
        if self._tempdir is not None:
            import shutil
            shutil.rmtree(self._tempdir)
 
    def _getFactory(self):
        from repoze.who.config import make_middleware_with_config
        return make_middleware_with_config
 
    def _getTempfile(self, text):
        import os
        import tempfile
        tempdir = self._tempdir = tempfile.mkdtemp()
        path = os.path.join(tempdir, 'who.ini')
        config = open(path, 'w')
        config.write(text)
        config.flush()
        config.close()
        return path
 
    def test_sample_config(self):
        import logging
        app = DummyApp()
        factory = self._getFactory()
        path = self._getTempfile(SAMPLE_CONFIG)
        global_conf = {'here': '/'}
        middleware = factory(app, global_conf, config_file=path,
                             log_file='STDOUT', log_level='debug')
        api_factory = middleware.api_factory
        self.assertEqual(len(api_factory.identifiers), 2)
        self.assertEqual(len(api_factory.authenticators), 1)
        self.assertEqual(len(api_factory.challengers), 2)
        self.assertEqual(len(api_factory.mdproviders), 0)
        self.failUnless(middleware.logger, middleware.logger)
        self.assertEqual(middleware.logger.getEffectiveLevel(), logging.DEBUG)
 
    def test_sample_config_no_log_level(self):
        import logging
        app = DummyApp()
        factory = self._getFactory()
        path = self._getTempfile(SAMPLE_CONFIG)
        global_conf = {'here': '/'}
        middleware = factory(app, global_conf, config_file=path,
                             log_file='STDOUT')
        self.assertEqual(middleware.logger.getEffectiveLevel(), logging.INFO)
 
    def test_sample_config_w_log_file(self):
        import logging
        import os
        app = DummyApp()
        factory = self._getFactory()
        path = self._getTempfile(SAMPLE_CONFIG)
        logfile = os.path.join(self._tempdir, 'who.log')
        global_conf = {'here': '/'}
        middleware = factory(app, global_conf, config_file=path,
                             log_file=logfile, log_level=logging.WARN)
        self.assertEqual(middleware.logger.getEffectiveLevel(), logging.WARN)
        handlers = middleware.logger.handlers
        self.assertEqual(len(handlers), 1)
        self.failUnless(isinstance(handlers[0], logging.StreamHandler))
        self.assertEqual(handlers[0].stream.name, logfile)
        logging.shutdown()
        handlers[0].stream.close()
 
    def test_sample_config_wo_log_file(self):
        import logging
        from repoze.who.config import NullHandler
        app = DummyApp()
        factory = self._getFactory()
        path = self._getTempfile(SAMPLE_CONFIG)
        global_conf = {'here': '/'}
        middleware = factory(app, global_conf, config_file=path)
        self.assertEqual(middleware.logger.getEffectiveLevel(), logging.INFO)
        handlers = middleware.logger.handlers
        self.assertEqual(len(handlers), 1)
        self.failUnless(isinstance(handlers[0], NullHandler))
        logging.shutdown()
 
class NullHandlerTests(_Base):
 
    def _getTargetClass(self):
        from repoze.who.config import NullHandler
        return NullHandler
 
    def _makeOne(self):
        return self._getTargetClass()()
 
    def test_inheritance(self):
        import logging
        handler = self._makeOne()
        self.failUnless(isinstance(handler, logging.Handler))
 
    def test_emit_doesnt_raise_NotImplementedError(self):
        handler = self._makeOne()
        handler.emit(object())
 
class Test_make_api_factory_with_config(_Base):
    _tempdir = None
    _warning_filters = None
 
    def setUp(self):
        pass
 
    def tearDown(self):
        if self._tempdir is not None:
            import shutil
            shutil.rmtree(self._tempdir)
        if self._warning_filters is not None:
            import warnings
            warnings.filters[:] = self._warning_filters
 
    def _getFactory(self):
        from repoze.who.config import make_api_factory_with_config
        return make_api_factory_with_config
 
    def _getTempfile(self, text):
        import os
        import tempfile
        tempdir = self._tempdir = tempfile.mkdtemp()
        path = os.path.join(tempdir, 'who.ini')
        config = open(path, 'w')
        config.write(text)
        config.flush()
        config.close()
        return path
 
    def test_bad_config_filename(self):
        import warnings
        with warnings.catch_warnings(record=True) as warned:
            factory = self._getFactory()
            path = '/nonesuch/file/should/exist'
            global_conf = {'here': '/'}
            api_factory = factory(global_conf, config_file=path)
            self.assertEqual(len(api_factory.identifiers), 0)
            self.assertEqual(len(api_factory.authenticators), 0)
            self.assertEqual(len(api_factory.challengers), 0)
            self.assertEqual(len(api_factory.mdproviders), 0)
            self.assertEqual(api_factory.remote_user_key, 'REMOTE_USER')
            self.failUnless(api_factory.logger is None)
            self.failUnless(warned)
 
    def test_bad_config_content(self):
        import warnings
        with warnings.catch_warnings(record=True) as warned:
            factory = self._getFactory()
            path = self._getTempfile('this is not an INI file')
            global_conf = {'here': '/'}
            api_factory = factory(global_conf, config_file=path)
            self.assertEqual(len(api_factory.identifiers), 0)
            self.assertEqual(len(api_factory.authenticators), 0)
            self.assertEqual(len(api_factory.challengers), 0)
            self.assertEqual(len(api_factory.mdproviders), 0)
            self.assertEqual(api_factory.remote_user_key, 'REMOTE_USER')
            self.failUnless(api_factory.logger is None)
            self.failUnless(warned)
 
    def test_sample_config_no_logger(self):
        factory = self._getFactory()
        path = self._getTempfile(SAMPLE_CONFIG)
        global_conf = {'here': '/'}
        api_factory = factory(global_conf, config_file=path)
        self.assertEqual(len(api_factory.identifiers), 2)
        self.assertEqual(len(api_factory.authenticators), 1)
        self.assertEqual(len(api_factory.challengers), 2)
        self.assertEqual(len(api_factory.mdproviders), 0)
        self.assertEqual(api_factory.remote_user_key, 'REMOTE_USER')
        self.failUnless(api_factory.logger is None)
 
    def test_sample_config_w_remote_user_key(self):
        factory = self._getFactory()
        path = self._getTempfile(SAMPLE_CONFIG)
        global_conf = {'here': '/'}
        api_factory = factory(global_conf, config_file=path,
                              remote_user_key = 'X-OTHER-USER')
        self.assertEqual(len(api_factory.identifiers), 2)
        self.assertEqual(len(api_factory.authenticators), 1)
        self.assertEqual(len(api_factory.challengers), 2)
        self.assertEqual(len(api_factory.mdproviders), 0)
        self.assertEqual(api_factory.remote_user_key, 'X-OTHER-USER')
 
    def test_sample_config_w_logger(self):
        factory = self._getFactory()
        path = self._getTempfile(SAMPLE_CONFIG)
        global_conf = {'here': '/'}
        logger = object()
        api_factory = factory(global_conf, config_file=path, logger=logger)
        self.assertEqual(len(api_factory.identifiers), 2)
        self.assertEqual(len(api_factory.authenticators), 1)
        self.assertEqual(len(api_factory.challengers), 2)
        self.assertEqual(len(api_factory.mdproviders), 0)
        self.failUnless(api_factory.logger is logger)
 
SAMPLE_CONFIG = """\
[plugin:redirector]
use = repoze.who.plugins.redirector:make_plugin
login_url = /login.html
 
[plugin:auth_tkt]
use = repoze.who.plugins.auth_tkt:make_plugin
secret = s33kr1t
cookie_name = oatmeal
secure = False
include_ip = True
 
[plugin:basicauth]
use = repoze.who.plugins.basicauth:make_plugin
realm = 'sample'
 
[plugin:htpasswd]
use = repoze.who.plugins.htpasswd:make_plugin
filename = %(here)s/etc/passwd
check_fn = repoze.who.plugins.htpasswd:crypt_check
 
[general]
request_classifier = repoze.who.classifiers:default_request_classifier
challenge_decider = repoze.who.classifiers:default_challenge_decider
 
[identifiers]
plugins =
    auth_tkt
    basicauth
 
[authenticators]
plugins = htpasswd
 
[challengers]
plugins =
    redirector;browser
    basicauth
 
[mdproviders]
plugins =
 
"""
 
class DummyApp:
    environ = None
    def __call__(self, environ, start_response):
        self.environ = environ
        return []