예제 #1
0
 def test_deis_version_header_good(self):
     """
     Test that when the version header is sent, the request is accepted.
     """
     response = self.client.get(
         '/v2/apps',
         HTTP_DEIS_VERSION=__version__.rsplit('.', 2)[0]
     )
     self.assertEqual(response.status_code, 200, response.data)
     self.assertEqual(response.has_header('DEIS_API_VERSION'), True)
     self.assertEqual(response['DEIS_API_VERSION'], __version__.rsplit('.', 1)[0])
예제 #2
0
 def test_deis_version_header_good(self):
     """
     Test that when the version header is sent, the request is accepted.
     """
     response = self.client.get(
         '/v2/apps',
         HTTP_DEIS_VERSION=__version__.rsplit('.', 2)[0],
         HTTP_AUTHORIZATION='token {}'.format(self.token),
     )
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.has_header('DEIS_API_VERSION'), True)
     self.assertEqual(response['DEIS_API_VERSION'], __version__.rsplit('.', 1)[0])
예제 #3
0
 def test_x_deis_version_header_good(self):
     """
     Test that when the version header is sent, the request is accepted.
     """
     response = self.client.get(
         '/v1/apps',
         HTTP_X_DEIS_VERSION=__version__.rsplit('.', 2)[0],
         HTTP_AUTHORIZATION='token {}'.format(self.token),
     )
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.has_header('X_DEIS_API_VERSION'), True)
     self.assertEqual(response['X_DEIS_API_VERSION'], __version__.rsplit('.', 1)[0])
예제 #4
0
 def process_response(self, request, response):
     """
     Include the controller's REST API major and minor version in
     a response header.
     """
     # clients shouldn't care about the patch release
     response['DEIS_API_VERSION'] = __version__.rsplit('.', 1)[0]
     return response
예제 #5
0
 def process_response(self, request, response):
     """
     Include the controller's REST API major and minor version in
     a response header.
     """
     # clients shouldn't care about the patch release
     response['DEIS_API_VERSION'] = __version__.rsplit('.', 1)[0]
     return response
 def test_deis_version_header_good(self):
     """
     Test that when the version header is sent.
     """
     response = self.client.get('/v2/apps')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.has_header('DEIS_API_VERSION'), True)
     self.assertEqual(response['DEIS_API_VERSION'], __version__.rsplit('.', 1)[0])
예제 #7
0
 def test_deis_version_header_good(self):
     """
     Test that when the version header is sent.
     """
     response = self.client.get('/v2/apps')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.has_header('DEIS_API_VERSION'), True)
     self.assertEqual(response['DEIS_API_VERSION'],
                      __version__.rsplit('.', 1)[0])
예제 #8
0
 def __call__(self, request):
     """
     Include the controller's REST API major and minor version in
     a response header.
     """
     response = self.get_response(request)
     # clients shouldn't care about the patch release
     version = __version__.rsplit('.', 1)[0]
     response['DEIS_API_VERSION'] = version
     response['DEIS_PLATFORM_VERSION'] = __version__
     return response
예제 #9
0
 def __call__(self, request):
     """
     Include the controller's REST API major and minor version in
     a response header.
     """
     response = self.get_response(request)
     # clients shouldn't care about the patch release
     version = __version__.rsplit('.', 1)[0]
     response['DEIS_API_VERSION'] = version
     response['DEIS_PLATFORM_VERSION'] = __version__
     return response
예제 #10
0
 def process_request(self, request):
     try:
         # server and client version must match the major release point
         client_version = request.META['HTTP_X_DEIS_VERSION']
         server_version = __version__.rsplit('.', 2)[0]
         if client_version != server_version:
             message = {
                 'error':
                 'Client and server versions do not match. ' +
                 'Client version: {} '.format(client_version) +
                 'Server version: {}'.format(server_version)
             }
             return HttpResponse(json.dumps(message),
                                 content_type='application/json',
                                 status=status.HTTP_405_METHOD_NOT_ALLOWED)
     except KeyError:
         pass
예제 #11
0
파일: middleware.py 프로젝트: 2008chny/deis
 def process_request(self, request):
     try:
         # server and client version must match the major release point
         client_version = request.META['HTTP_X_DEIS_VERSION']
         server_version = __version__.rsplit('.', 2)[0]
         if client_version != server_version:
             message = {
                 'error': 'Client and server versions do not match. ' +
                 'Client version: {} '.format(client_version) +
                 'Server version: {}'.format(server_version)
             }
             return HttpResponse(
                 json.dumps(message),
                 content_type='application/json',
                 status=status.HTTP_405_METHOD_NOT_ALLOWED
             )
     except KeyError:
         pass
예제 #12
0
 def process_request(self, request):
     """
     Return a 405 "Not Allowed" if the request's client major version
     doesn't match this controller's REST API major version (currently "1").
     """
     try:
         client_version = request.META['HTTP_DEIS_VERSION']
         server_version = __version__.rsplit('.', 2)[0]
         if client_version != server_version:
             message = {
                 'error':
                 'Client and server versions do not match. ' +
                 'Client version: {} '.format(client_version) +
                 'Server version: {}'.format(server_version)
             }
             return HttpResponse(json.dumps(message),
                                 content_type='application/json',
                                 status=status.HTTP_405_METHOD_NOT_ALLOWED)
     except KeyError:
         pass
예제 #13
0
 def process_request(self, request):
     """
     Return a 405 "Not Allowed" if the request's client major version
     doesn't match this controller's REST API major version (currently "1").
     """
     try:
         client_version = request.META['HTTP_DEIS_VERSION']
         server_version = __version__.rsplit('.', 2)[0]
         if client_version != server_version:
             message = {
                 'error': 'Client and server versions do not match. ' +
                          'Client version: {} '.format(client_version) +
                          'Server version: {}'.format(server_version)
             }
             return HttpResponse(
                 json.dumps(message),
                 content_type='application/json',
                 status=status.HTTP_405_METHOD_NOT_ALLOWED
             )
     except KeyError:
         pass
예제 #14
0
파일: middleware.py 프로젝트: 2008chny/deis
 def process_response(self, request, response):
     # clients shouldn't care about the patch release
     response['X_DEIS_API_VERSION'] = __version__.rsplit('.', 1)[0]
     return response
예제 #15
0
 def process_response(self, request, response):
     # clients shouldn't care about the patch release
     response['X_DEIS_API_VERSION'] = __version__.rsplit('.', 1)[0]
     return response