Ejemplo n.º 1
0
 def test_generate_request_headers(self):
     base = Controller(self.app)
     src_headers = {"x-remove-base-meta-owner": "x", "x-base-meta-size": "151M", "new-owner": "Kun"}
     req = Request.blank("/v1/a/c/o", headers=src_headers)
     dst_headers = base.generate_request_headers(req, transfer=True)
     expected_headers = {"x-base-meta-owner": "", "x-base-meta-size": "151M", "connection": "close"}
     for k, v in expected_headers.iteritems():
         self.assertTrue(k in dst_headers)
         self.assertEqual(v, dst_headers[k])
     self.assertFalse("new-owner" in dst_headers)
Ejemplo n.º 2
0
 def test_generate_request_headers_with_no_orig_req(self):
     base = Controller(self.app)
     src_headers = {'x-remove-base-meta-owner': 'x',
                    'x-base-meta-size': '151M',
                    'new-owner': 'Kun'}
     dst_headers = base.generate_request_headers(None,
                                                 additional=src_headers)
     expected_headers = {'x-base-meta-size': '151M',
                         'connection': 'close'}
     for k, v in expected_headers.items():
         self.assertDictContainsSubset(expected_headers, dst_headers)
     self.assertEqual('', dst_headers['Referer'])
Ejemplo n.º 3
0
 def test_generate_request_headers_with_no_orig_req(self):
     base = Controller(self.app)
     src_headers = {'x-remove-base-meta-owner': 'x',
                    'x-base-meta-size': '151M',
                    'new-owner': 'Kun'}
     dst_headers = base.generate_request_headers(None,
                                                 additional=src_headers)
     expected_headers = {'x-base-meta-size': '151M',
                         'connection': 'close'}
     for k, v in expected_headers.items():
         self.assertDictContainsSubset(expected_headers, dst_headers)
     self.assertEqual('', dst_headers['Referer'])
Ejemplo n.º 4
0
 def test_generate_request_headers(self):
     base = Controller(self.app)
     src_headers = {'x-remove-base-meta-owner': 'x',
                    'x-base-meta-size': '151M',
                    'new-owner': 'Kun'}
     req = Request.blank('/v1/a/c/o', headers=src_headers)
     dst_headers = base.generate_request_headers(req, transfer=True)
     expected_headers = {'x-base-meta-owner': '',
                         'x-base-meta-size': '151M'}
     for k, v in expected_headers.iteritems():
         self.assertTrue(k in dst_headers)
         self.assertEqual(v, dst_headers[k])
     self.assertFalse('new-owner' in dst_headers)
Ejemplo n.º 5
0
 def test_generate_request_headers_with_sysmeta(self):
     base = Controller(self.app)
     good_hdrs = {"x-base-sysmeta-foo": "ok", "X-Base-sysmeta-Bar": "also ok"}
     bad_hdrs = {"x-base-sysmeta-": "too short"}
     hdrs = dict(good_hdrs)
     hdrs.update(bad_hdrs)
     req = Request.blank("/v1/a/c/o", headers=hdrs)
     dst_headers = base.generate_request_headers(req, transfer=True)
     for k, v in good_hdrs.iteritems():
         self.assertTrue(k.lower() in dst_headers)
         self.assertEqual(v, dst_headers[k.lower()])
     for k, v in bad_hdrs.iteritems():
         self.assertFalse(k.lower() in dst_headers)
Ejemplo n.º 6
0
 def test_generate_request_headers_with_sysmeta(self):
     base = Controller(self.app)
     good_hdrs = {'x-base-sysmeta-foo': 'ok',
                  'X-Base-sysmeta-Bar': 'also ok'}
     bad_hdrs = {'x-base-sysmeta-': 'too short'}
     hdrs = dict(good_hdrs)
     hdrs.update(bad_hdrs)
     req = Request.blank('/v1/a/c/o', headers=hdrs)
     dst_headers = base.generate_request_headers(req, transfer=True)
     for k, v in good_hdrs.items():
         self.assertIn(k.lower(), dst_headers)
         self.assertEqual(v, dst_headers[k.lower()])
     for k, v in bad_hdrs.items():
         self.assertNotIn(k.lower(), dst_headers)
Ejemplo n.º 7
0
 def test_generate_request_headers_with_sysmeta(self):
     base = Controller(self.app)
     good_hdrs = {'x-base-sysmeta-foo': 'ok',
                  'X-Base-sysmeta-Bar': 'also ok'}
     bad_hdrs = {'x-base-sysmeta-': 'too short'}
     hdrs = dict(good_hdrs)
     hdrs.update(bad_hdrs)
     req = Request.blank('/v1/a/c/o', headers=hdrs)
     dst_headers = base.generate_request_headers(req, transfer=True)
     for k, v in good_hdrs.iteritems():
         self.assertTrue(k.lower() in dst_headers)
         self.assertEqual(v, dst_headers[k.lower()])
     for k, v in bad_hdrs.iteritems():
         self.assertFalse(k.lower() in dst_headers)
Ejemplo n.º 8
0
 def test_generate_request_headers(self):
     base = Controller(self.app)
     src_headers = {'x-remove-base-meta-owner': 'x',
                    'x-base-meta-size': '151M',
                    'new-owner': 'Kun'}
     req = Request.blank('/v1/a/c/o', headers=src_headers)
     dst_headers = base.generate_request_headers(req, transfer=True)
     expected_headers = {'x-base-meta-owner': '',
                         'x-base-meta-size': '151M',
                         'connection': 'close'}
     for k, v in expected_headers.iteritems():
         self.assertTrue(k in dst_headers)
         self.assertEqual(v, dst_headers[k])
     self.assertFalse('new-owner' in dst_headers)