Exemplo n.º 1
0
        def do_test(headers, status, err_msg):
            req = Request.blank('/v1/a/c/o', method='PUT', headers=headers)
            with self.assertRaises(swob.HTTPException) as cm:
                symlink._check_symlink_header(req)

            self.assertEqual(cm.exception.status, status)
            self.assertEqual(cm.exception.body, err_msg)
Exemplo n.º 2
0
        def do_test(headers, status, err_msg):
            req = Request.blank('/v1/a/c/o', method='PUT',
                                headers=headers)
            with self.assertRaises(swob.HTTPException) as cm:
                symlink._check_symlink_header(req)

            self.assertEqual(cm.exception.status, status)
            self.assertEqual(cm.exception.body, err_msg)
Exemplo n.º 3
0
    def test_check_symlink_header_points_to_itself(self):
        req = Request.blank('/v1/a/c/o',
                            method='PUT',
                            headers={'X-Symlink-Target': 'c/o'})
        with self.assertRaises(swob.HTTPException) as cm:
            symlink._check_symlink_header(req)
        self.assertEqual(cm.exception.status, '400 Bad Request')
        self.assertEqual(cm.exception.body, 'Symlink cannot target itself')

        # Even if set account to itself, it will fail as well
        req = Request.blank('/v1/a/c/o',
                            method='PUT',
                            headers={
                                'X-Symlink-Target': 'c/o',
                                'X-Symlink-Target-Account': 'a'
                            })
        with self.assertRaises(swob.HTTPException) as cm:
            symlink._check_symlink_header(req)
        self.assertEqual(cm.exception.status, '400 Bad Request')
        self.assertEqual(cm.exception.body, 'Symlink cannot target itself')

        # sanity, the case to another account is safe
        req = Request.blank('/v1/a/c/o',
                            method='PUT',
                            headers={
                                'X-Symlink-Target': 'c/o',
                                'X-Symlink-Target-Account': 'a1'
                            })
        symlink._check_symlink_header(req)
Exemplo n.º 4
0
    def test_check_symlink_header_points_to_itself(self):
        req = Request.blank('/v1/a/c/o', method='PUT',
                            headers={'X-Symlink-Target': 'c/o'})
        with self.assertRaises(swob.HTTPException) as cm:
            symlink._check_symlink_header(req)
        self.assertEqual(cm.exception.status, '400 Bad Request')
        self.assertEqual(cm.exception.body, 'Symlink cannot target itself')

        # Even if set account to itself, it will fail as well
        req = Request.blank('/v1/a/c/o', method='PUT',
                            headers={'X-Symlink-Target': 'c/o',
                                     'X-Symlink-Target-Account': 'a'})
        with self.assertRaises(swob.HTTPException) as cm:
            symlink._check_symlink_header(req)
        self.assertEqual(cm.exception.status, '400 Bad Request')
        self.assertEqual(cm.exception.body, 'Symlink cannot target itself')

        # sanity, the case to another account is safe
        req = Request.blank('/v1/a/c/o', method='PUT',
                            headers={'X-Symlink-Target': 'c/o',
                                     'X-Symlink-Target-Account': 'a1'})
        symlink._check_symlink_header(req)
Exemplo n.º 5
0
 def do_test(headers):
     req = Request.blank('/v1/a/c/o', method='PUT', headers=headers)
     symlink._check_symlink_header(req)
Exemplo n.º 6
0
 def do_test(headers):
     req = Request.blank('/v1/a/c/o', method='PUT',
                         headers=headers)
     symlink._check_symlink_header(req)