/usr/share/pyshared/repoze/who/tests/test_classifiers.py is in python-repoze.who 1.0.18-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | import unittest
class TestDefaultRequestClassifier(unittest.TestCase):
def _getFUT(self):
from repoze.who.classifiers import default_request_classifier
return default_request_classifier
def _makeEnviron(self, kw=None):
environ = {}
environ['wsgi.version'] = (1,0)
if kw is not None:
environ.update(kw)
return environ
def test_classify_dav_method(self):
classifier = self._getFUT()
environ = self._makeEnviron({'REQUEST_METHOD':'COPY'})
result = classifier(environ)
self.assertEqual(result, 'dav')
def test_classify_dav_useragent(self):
classifier = self._getFUT()
environ = self._makeEnviron({'HTTP_USER_AGENT':'WebDrive'})
result = classifier(environ)
self.assertEqual(result, 'dav')
def test_classify_xmlpost(self):
classifier = self._getFUT()
environ = self._makeEnviron({'CONTENT_TYPE':'text/xml',
'REQUEST_METHOD':'POST'})
result = classifier(environ)
self.assertEqual(result, 'xmlpost')
def test_classify_browser(self):
classifier = self._getFUT()
environ = self._makeEnviron({'CONTENT_TYPE':'text/xml',
'REQUEST_METHOD':'GET'})
result = classifier(environ)
self.assertEqual(result, 'browser')
class TestDefaultChallengeDecider(unittest.TestCase):
def _getFUT(self):
from repoze.who.classifiers import default_challenge_decider
return default_challenge_decider
def _makeEnviron(self, kw=None):
environ = {}
environ['wsgi.version'] = (1,0)
if kw is not None:
environ.update(kw)
return environ
def test_challenges_on_401(self):
decider = self._getFUT()
self.failUnless(decider({}, '401 Unauthorized', []))
def test_doesnt_challenges_on_non_401(self):
decider = self._getFUT()
self.failIf(decider({}, '200 Ok', []))
class TestPassthroughChallengeDecider(unittest.TestCase):
def _getFUT(self):
from repoze.who.classifiers import passthrough_challenge_decider
return passthrough_challenge_decider
def _makeEnviron(self, kw=None):
environ = {}
environ['wsgi.version'] = (1,0)
if kw is not None:
environ.update(kw)
return environ
def test_challenges_on_bare_401(self):
decider = self._getFUT()
self.failUnless(decider({}, '401 Unauthorized', []))
def test_doesnt_challenges_on_non_401(self):
decider = self._getFUT()
self.failIf(decider({}, '200 Ok', []))
def test_doesnt_challenges_on_401_with_WWW_Authenticate(self):
decider = self._getFUT()
self.failIf(decider({}, '401 Ok', [('WWW-Authenticate', 'xxx')]))
def test_doesnt_challenges_on_401_with_text_html(self):
decider = self._getFUT()
self.failIf(decider({}, '401 Ok', [('Content-Type', 'text/html')]))
|