1
0
mirror of https://github.com/ceph/ceph synced 2025-03-25 11:48:05 +00:00
ceph/qa/tasks/mgr/dashboard/test_requests.py
Avan Thakkar 88a8732215 mgr/dashboard: make modified API endpoints backward compatible
Fixes: https://tracker.ceph.com/issues/52480
Signed-off-by: Avan Thakkar <athakkar@redhat.com>

Introducing APIVersion class to handle versioning for API-endpints and making
them backward compatible.
2021-09-24 18:48:35 +05:30

35 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
from __future__ import absolute_import
from . import DEFAULT_API_VERSION
from .helper import DashboardTestCase
class RequestsTest(DashboardTestCase):
def test_gzip(self):
self._get('/api/summary')
self.assertHeaders({
'Content-Encoding': 'gzip',
'Content-Type': 'application/vnd.ceph.api.v{}+json'.format(DEFAULT_API_VERSION)
})
def test_force_no_gzip(self):
self._get('/api/summary', params=dict(
headers={'Accept-Encoding': 'identity'}
))
self.assertNotIn('Content-Encoding', self._resp.headers)
self.assertHeaders({
'Content-Type': 'application/json'
})
def test_server(self):
self._get('/api/summary')
self.assertHeaders({
'server': 'Ceph-Dashboard',
'Content-Type': 'application/vnd.ceph.api.v{}+json'.format(DEFAULT_API_VERSION),
'Content-Security-Policy': "frame-ancestors 'self';",
'X-Content-Type-Options': 'nosniff',
'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload'
})