Exemple #1
0
 def test_no_cache(self):
     url = URL('http://www.w3af.org')
     request = HTTPRequest(url, cache=False)
     
     cache = CacheHandler()
     self.assertEqual(cache.default_open(request), None)
     
     response = FakeHttplibHTTPResponse(200, 'OK', 'spameggs', Headers(),
                                        url.url_string)
     cache.http_response(request, response)
     self.assertEqual(cache.default_open(request), None)
Exemple #2
0
 def test_basic(self):
     url = URL('http://www.w3af.org')
     request = HTTPRequest(url, cache=True)
     
     cache = CacheHandler()
     self.assertEqual(cache.default_open(request), None)
     
     response = FakeHttplibHTTPResponse(200, 'OK', 'spameggs', Headers(),
                                        url.url_string)
     cache.http_response(request, response)
     
     cached_response = cache.default_open(request)
     
     self.assertIsInstance(cached_response, SQLCachedResponse)
     
     self.assertEqual(cached_response.code, response.code)
     self.assertEqual(cached_response.msg, response.msg)
     self.assertEqual(cached_response.read(), response.read())
     self.assertEqual(Headers(cached_response.info().items()), response.info())
     self.assertEqual(cached_response.geturl(), response.geturl())
Exemple #3
0
    def test_no_cache(self):
        url = URL('http://www.w3af.org')
        request = HTTPRequest(url, cache=False)

        cache = CacheHandler()
        self.assertEqual(cache.default_open(request), None)

        response = FakeHttplibHTTPResponse(200, 'OK', 'spameggs', Headers(),
                                           url.url_string)
        cache.http_response(request, response)
        self.assertEqual(cache.default_open(request), None)
Exemple #4
0
    def test_basic(self):
        url = URL('http://www.w3af.org')
        request = HTTPRequest(url, cache=True)

        cache = CacheHandler()
        self.assertEqual(cache.default_open(request), None)

        response = FakeHttplibHTTPResponse(200, 'OK', 'spameggs', Headers(),
                                           url.url_string)
        cache.http_response(request, response)

        cached_response = cache.default_open(request)

        self.assertIsInstance(cached_response, SQLCachedResponse)

        self.assertEqual(cached_response.code, response.code)
        self.assertEqual(cached_response.msg, response.msg)
        self.assertEqual(cached_response.read(), response.read())
        self.assertEqual(Headers(cached_response.info().items()),
                         response.info())
        self.assertEqual(cached_response.geturl(), response.geturl())
Exemple #5
0
 def tearDown(self):
     CacheHandler().clear()