Test that the CDN script tag includes an integrity attribute with SHA256 hash
(fig1)
| 36 | |
| 37 | |
| 38 | def test_cdn_includes_integrity_attribute(fig1): |
| 39 | """Test that the CDN script tag includes an integrity attribute with SHA256 hash""" |
| 40 | html_output = pio.to_html(fig1, include_plotlyjs="cdn") |
| 41 | |
| 42 | # Check that the script tag includes integrity attribute |
| 43 | assert 'integrity="sha256-' in html_output |
| 44 | assert 'crossorigin="anonymous"' in html_output |
| 45 | |
| 46 | # Verify it's in the correct script tag |
| 47 | cdn_pattern = re.compile( |
| 48 | r'<script[^>]*src="' |
| 49 | + re.escape(plotly_cdn_url()) |
| 50 | + r'"[^>]*integrity="sha256-[A-Za-z0-9+/=]+"[^>]*>' |
| 51 | ) |
| 52 | match = cdn_pattern.search(html_output) |
| 53 | assert match is not None, "CDN script tag with integrity attribute not found" |
| 54 | |
| 55 | |
| 56 | def test_outer_wrapper_carries_requested_dimensions(fig1): |
nothing calls this directly
no test coverage detected