"""SSRF URL validation for remote browser."""

import pytest

from server.utils.browser_url_safe import validate_navigation_url


def test_accepts_https_public():
    url, err = validate_navigation_url("https://example.com/path")
    assert err is None
    assert url is not None
    assert url.startswith("https://example.com")


def test_rejects_javascript():
    url, err = validate_navigation_url("javascript:alert(1)")
    assert url is None
    assert err is not None


def test_rejects_localhost():
    url, err = validate_navigation_url("http://127.0.0.1")
    assert url is None
    assert err is not None


def test_rejects_private_ip_literal():
    url, err = validate_navigation_url("http://10.0.0.1")
    assert url is None
    assert err is not None
