|
21 | 21 | from cryptography.hazmat.primitives import hashes, serialization |
22 | 22 | from cryptography.hazmat.primitives.asymmetric import ec |
23 | 23 | import pytest # type: ignore |
24 | | -import urllib3.util |
25 | 24 |
|
26 | 25 | from google.auth import environment_vars, exceptions |
27 | 26 | from google.auth.transport import _mtls_helper |
@@ -1889,80 +1888,3 @@ def test_remove_oserror_ignored( |
1889 | 1888 | mock_fh.flush.assert_called_once() |
1890 | 1889 | mock_fsync.assert_called_once() |
1891 | 1890 | mock_remove.assert_called_once_with("/path/to/secret") |
1892 | | - |
1893 | | - |
1894 | | -class TestIsMtlsEndpoint(object): |
1895 | | - @pytest.mark.parametrize( |
1896 | | - "url", |
1897 | | - [ |
1898 | | - "https://mtls.googleapis.com", |
1899 | | - "https://mtls.googleapis.com/", |
1900 | | - "https://mtls.googleapis.com/v1/projects", |
1901 | | - "https://mtls.sandbox.googleapis.com", |
1902 | | - "https://mtls.sandbox.googleapis.com/v1/projects", |
1903 | | - "https://pubsub.mtls.googleapis.com", |
1904 | | - "https://pubsub.mtls.googleapis.com/v1/projects/my-project", |
1905 | | - "https://storage.mtls.sandbox.googleapis.com/b/my-bucket", |
1906 | | - "https://my-service.us-east1.rep.mtls.googleapis.com/v1", |
1907 | | - "https://my-service.us-east1.rep.mtls.sandbox.googleapis.com/v1", |
1908 | | - "https://storage.p.googleapis.com/b/my-bucket", |
1909 | | - "https://my-custom-endpoint.p.googleapis.com/v1", |
1910 | | - "https://my-service.us-east1.p.googleapis.com/v1", |
1911 | | - "HTTP://PUBSUB.MTLS.GOOGLEAPIS.COM/V1", |
1912 | | - b"https://pubsub.mtls.googleapis.com", |
1913 | | - b"https://storage.p.googleapis.com/b/my-bucket", |
1914 | | - urllib3.util.parse_url("https://pubsub.mtls.googleapis.com/v1"), |
1915 | | - urllib3.util.parse_url("https://storage.p.googleapis.com/b/my-bucket"), |
1916 | | - "https://pubsub.mtls.googleapis.com.", |
1917 | | - "https://storage.p.googleapis.com./b/my-bucket", |
1918 | | - "https://mtls.googleapis.com.", |
1919 | | - "https://pubsub.mtls.googleapis.com:443/v1", |
1920 | | - "https://pubsub.mtls.googleapis.com:8443/v1", |
1921 | | - "https://storage.p.googleapis.com:443/b/my-bucket", |
1922 | | - "https://pubsub.mtls.googleapis.com/v1/projects?pageSize=10#frag", |
1923 | | - "https://pubsub.mtls.googleapis.com:443/v1/projects?pageSize=10&filter=foo#frag", |
1924 | | - "https://storage.p.googleapis.com:443/b/my-bucket?param=1#section", |
1925 | | - "https://mtls.googleapis.com:443/", |
1926 | | - "https://p.googleapis.com", |
1927 | | - "https://p.googleapis.com/", |
1928 | | - "https://p.googleapis.com:443/v1", |
1929 | | - "https://p.googleapis.com.", |
1930 | | - ], |
1931 | | - ) |
1932 | | - def test_is_mtls_endpoint_true(self, url): |
1933 | | - assert _mtls_helper.is_mtls_endpoint(url) is True |
1934 | | - |
1935 | | - @pytest.mark.parametrize( |
1936 | | - "url", |
1937 | | - [ |
1938 | | - "https://storage.googleapis.com", |
1939 | | - "https://storage.googleapis.com.", |
1940 | | - "https://storage.googleapis.com:443/b/my-bucket", |
1941 | | - "https://storage.googleapis.com:443/bucket/mtls.googleapis.com?pageSize=10#frag", |
1942 | | - "https://storage.googleapis.com/bucket/mtls.googleapis.com", |
1943 | | - "https://[2001:db8::1]:443/mtls.googleapis.com", |
1944 | | - "https://[::1]:8443/mtls.googleapis.com", |
1945 | | - "https://logging.googleapis.com/v2/entries?filter=mtls.googleapis.com", |
1946 | | - "https://logging.googleapis.com/v2/entries?filter=mtls.sandbox.googleapis.com", |
1947 | | - "https://logging.googleapis.com/v2/entries?filter=service.p.googleapis.com", |
1948 | | - "https://example.com/mtls.googleapis.com", |
1949 | | - "https://fake-mtls.googleapis.com.attacker.com/v1", |
1950 | | - "https://fake-p.googleapis.com.attacker.com/v1", |
1951 | | - "http://localhost:8080/", |
1952 | | - "http://localhost:8080/mtls.googleapis.com", |
1953 | | - b"https://storage.googleapis.com", |
1954 | | - b"https://storage.googleapis.com/bucket/mtls.googleapis.com", |
1955 | | - b"\xff\xfeinvalid", |
1956 | | - urllib3.util.parse_url("https://storage.googleapis.com/b/my-bucket"), |
1957 | | - urllib3.util.parse_url( |
1958 | | - "https://storage.googleapis.com/bucket/mtls.googleapis.com" |
1959 | | - ), |
1960 | | - "https://.", |
1961 | | - "", |
1962 | | - None, |
1963 | | - 123, |
1964 | | - "not a url", |
1965 | | - ], |
1966 | | - ) |
1967 | | - def test_is_mtls_endpoint_false(self, url): |
1968 | | - assert _mtls_helper.is_mtls_endpoint(url) is False |
0 commit comments