'If the X-Frame-Options header is already set then the middleware does
not attempt to override it.'

def test_dont_set_if_set(self):

    with override_settings(X_FRAME_OPTIONS='DENY'):
        response = HttpResponse()
        response['X-Frame-Options'] = 'SAMEORIGIN'
        r = XFrameOptionsMiddleware().process_response(HttpRequest(), response)
        self.assertEqual(r['X-Frame-Options'], 'SAMEORIGIN')
    with override_settings(X_FRAME_OPTIONS='SAMEORIGIN'):
        response = HttpResponse()
        response['X-Frame-Options'] = 'DENY'
        r = XFrameOptionsMiddleware().process_response(HttpRequest(), response)
        self.assertEqual(r['X-Frame-Options'], 'DENY')
