Ejemplo n.º 1
0
    def test_container_info_without_req(self):
        base = Controller(self.app)
        base.account_name = 'a'
        base.container_name = 'c'

        container_info = \
            base.container_info(base.account_name,
                                base.container_name)
        self.assertEqual(container_info['status'], 0)
Ejemplo n.º 2
0
    def test_container_info_without_req(self):
        base = Controller(self.app)
        base.account_name = 'a'
        base.container_name = 'c'

        container_info = \
            base.container_info(base.account_name,
                                base.container_name)
        self.assertEqual(container_info['status'], 0)
Ejemplo n.º 3
0
    def test_options_unauthorized(self):
        base = Controller(self.app)
        base.account_name = 'a'
        base.container_name = 'c'
        self.app.cors_allow_origin = ['http://NOT_IT']
        req = Request.blank('/v1/a/c/o',
                            environ={'swift.cache': FakeCache()},
                            headers={'Origin': 'http://m.com',
                                     'Access-Control-Request-Method': 'GET'})

        with mock.patch('swift.proxy.controllers.base.'
                        'http_connect', fake_http_connect(200)):
            resp = base.OPTIONS(req)
        self.assertEqual(resp.status_int, 401)
Ejemplo n.º 4
0
    def test_options_unauthorized(self):
        base = Controller(self.app)
        base.account_name = 'a'
        base.container_name = 'c'
        self.app.cors_allow_origin = ['http://NOT_IT']
        req = Request.blank('/v1/a/c/o',
                            environ={'swift.cache': FakeCache()},
                            headers={'Origin': 'http://m.com',
                                     'Access-Control-Request-Method': 'GET'})

        with mock.patch('swift.proxy.controllers.base.'
                        'http_connect', fake_http_connect(200)):
            resp = base.OPTIONS(req)
        self.assertEqual(resp.status_int, 401)
Ejemplo n.º 5
0
    def test_options_unauthorized(self):
        base = Controller(self.app)
        base.account_name = "a"
        base.container_name = "c"
        self.app.cors_allow_origin = ["http://NOT_IT"]
        req = Request.blank(
            "/v1/a/c/o",
            environ={"swift.cache": FakeCache()},
            headers={"Origin": "http://m.com", "Access-Control-Request-Method": "GET"},
        )

        with patch("swift.proxy.controllers.base." "http_connect", fake_http_connect(200)):
            resp = base.OPTIONS(req)
        self.assertEqual(resp.status_int, 401)
Ejemplo n.º 6
0
    def test_options_with_null_allow_origin(self):
        base = Controller(self.app)
        base.account_name = 'a'
        base.container_name = 'c'

        def my_container_info(*args):
            return {
                'cors': {
                    'allow_origin': '*',
                }
            }
        base.container_info = my_container_info
        req = Request.blank('/v1/a/c/o',
                            environ={'swift.cache': FakeCache()},
                            headers={'Origin': '*',
                                     'Access-Control-Request-Method': 'GET'})

        with mock.patch('swift.proxy.controllers.base.'
                        'http_connect', fake_http_connect(200)):
            resp = base.OPTIONS(req)
        self.assertEqual(resp.status_int, 200)
Ejemplo n.º 7
0
    def test_options_with_null_allow_origin(self):
        base = Controller(self.app)
        base.account_name = 'a'
        base.container_name = 'c'

        def my_container_info(*args):
            return {
                'cors': {
                    'allow_origin': '*',
                }
            }
        base.container_info = my_container_info
        req = Request.blank('/v1/a/c/o',
                            environ={'swift.cache': FakeCache()},
                            headers={'Origin': '*',
                                     'Access-Control-Request-Method': 'GET'})

        with mock.patch('swift.proxy.controllers.base.'
                        'http_connect', fake_http_connect(200)):
            resp = base.OPTIONS(req)
        self.assertEqual(resp.status_int, 200)