class_docstr: Tests for `SecurityValidatorMiddleware`.
class_docstr_tok: ["Tests","for","`","SecurityValidatorMiddleware","`","."]
code: def test_validate_csp_text_html(self):
      self.make_request_and_assert_no_warn(
          create_headers(
              content_type="text/html; charset=UTF-8",
              content_security_policy=(
                  "DEFAult-src 'self';script-src https://google.com;"
                  "style-src  'self'   https://example; object-src   "
              ),
          ),
      )
  
      self.make_request_and_maybe_assert_warn(
          create_headers(
              content_type="text/html; charset=UTF-8",
              content_security_policy="",
          ),
          "Requires default-src for Content-Security-Policy",
      )
  
      self.make_request_and_maybe_assert_warn(
          create_headers(
              content_type="text/html; charset=UTF-8",
              content_security_policy="default-src *",
          ),
          "Illegal Content-Security-Policy for default-src: *",
      )
  
      self.make_request_and_maybe_assert_warn(
          create_headers(
              content_type="text/html; charset=UTF-8",
              content_security_policy="default-src 'self';script-src *",
          ),
          "Illegal Content-Security-Policy for script-src: *",
      )
  
      self.make_request_and_maybe_assert_warn(
          create_headers(
              content_type="text/html; charset=UTF-8",
              content_security_policy=(
                  "script-src * 'sha256-foo' 'nonce-bar';"
                  "style-src http://google.com;object-src *;"
                  "img-src 'unsafe-inline';default-src 'self';"
                  "script-src *       'strict-dynamic'"
              ),
          ),
          "\n".join(
              [
                  "Illegal Content-Security-Policy for script-src: *",
                  "Illegal Content-Security-Policy for script-src: 'nonce-bar'",
                  "Illegal Content-Security-Policy for style-src: http://google.com",
                  "Illegal Content-Security-Policy for object-src: *",
                  "Illegal Content-Security-Policy for img-src: 'unsafe-inline'",
                  "Illegal Content-Security-Policy for script-src: *",
                  "Illegal Content-Security-Policy for script-src: 'strict-dynamic'",
              ]
          ),
      )
  
file_path: tensorboard/tensorboard/backend/security_validator_test.py
imports: from unittest import mock
  import werkzeug
  from werkzeug import test
  from werkzeug.datastructures import Headers
  from werkzeug.wrappers import Response
  from tensorboard import test
  from tensorboard.backend import security_validator
  from tensorboard.util import tb_logging
label_desc: Use image node_id 5 for calling the SecurityValidatorMiddlewareTest obj's underlying member method code with example usage: obj.test_validate_csp_text_html() without return types