'Test case in which several policies are specified using only 1 CSP
header but with 7 differents directives.'

def test_retrieve_csp_policies_with_policies_case02(self):

    header_value = "default-src    'self';    img-src    *;    object-src    media1.example.com    media2.example.com    *.cdn.example.com;    script-src    trustedscripts.example.com;    form-action    /ctxroot/action1    /ctxroot/action2;    plugin-types    application/pdf    application/x-java-applet;    reflected-xss    block"
    hrds = {CSP_HEADER_W3C: header_value}.items()
    csp_headers = Headers(hrds)
    http_response = HTTPResponse(200, '', csp_headers, self.url, self.url)
    policies = retrieve_csp_policies(http_response)
    self.assertEqual(len(policies), 7)
    self.assertEqual(len(policies[CSP_DIRECTIVE_DEFAULT]), 1)
    self.assertEqual(policies[CSP_DIRECTIVE_DEFAULT][0], 'self')
    self.assertEqual(len(policies[CSP_DIRECTIVE_IMAGE]), 1)
    self.assertEqual(policies[CSP_DIRECTIVE_IMAGE][0], '*')
    self.assertEqual(len(policies[CSP_DIRECTIVE_SCRIPT]), 1)
    self.assertEqual(policies[CSP_DIRECTIVE_SCRIPT][0], 'trustedscripts.example.com')
    self.assertEqual(len(policies[CSP_DIRECTIVE_OBJECT]), 3)
    self.assertTrue(('media1.example.com' in policies[CSP_DIRECTIVE_OBJECT]))
    self.assertTrue(('media2.example.com' in policies[CSP_DIRECTIVE_OBJECT]))
    self.assertTrue(('*.cdn.example.com' in policies[CSP_DIRECTIVE_OBJECT]))
    self.assertEqual(len(policies[CSP_DIRECTIVE_FORM]), 2)
    self.assertTrue(('/ctxroot/action1' in policies[CSP_DIRECTIVE_FORM]))
    self.assertTrue(('/ctxroot/action2' in policies[CSP_DIRECTIVE_FORM]))
    self.assertEqual(len(policies[CSP_DIRECTIVE_PLUGIN_TYPES]), 2)
    self.assertTrue(('application/pdf' in policies[CSP_DIRECTIVE_PLUGIN_TYPES]))
    self.assertTrue(('application/x-java-applet' in policies[CSP_DIRECTIVE_PLUGIN_TYPES]))
    self.assertEqual(len(policies[CSP_DIRECTIVE_XSS]), 1)
    self.assertTrue(('block' in policies[CSP_DIRECTIVE_XSS]))
