@@ -434,22 +434,6 @@ def run_all():
434434 assert 'Test value' in output
435435
436436
437- def test_test_url_preflight_check_with_frontdoor (monkeypatch , suppress_console ):
438- """Test URL preflight check when Front Door is available."""
439- monkeypatch .setattr (az , 'get_frontdoor_url' , lambda x , y : 'https://test.azurefd.net' )
440-
441- result = utils .test_url_preflight_check (INFRASTRUCTURE .AFD_APIM_PE , 'test-rg' , 'https://apim.com' )
442- assert result == 'https://test.azurefd.net'
443-
444-
445- def test_test_url_preflight_check_no_frontdoor (monkeypatch , suppress_console ):
446- """Test URL preflight check when Front Door is not available."""
447- monkeypatch .setattr (az , 'get_frontdoor_url' , lambda x , y : None )
448-
449- result = utils .test_url_preflight_check (INFRASTRUCTURE .SIMPLE_APIM , 'test-rg' , 'https://apim.com' )
450- assert result == 'https://apim.com'
451-
452-
453437def test_determine_policy_path_filename_mode (monkeypatch ):
454438 """Test determine_policy_path with filename mode."""
455439
@@ -1838,38 +1822,9 @@ def test_notebookhelper_clean_up_jwt_failure(monkeypatch, caplog):
18381822
18391823
18401824# ------------------------------
1841- # get_endpoints TESTS
18421825# ------------------------------
1843-
1844-
1845- def test_get_endpoints_comprehensive (monkeypatch , suppress_console ):
1846- """Test get_endpoints function."""
1847- monkeypatch .setattr (az , 'get_frontdoor_url' , lambda x , y : 'https://test-afd.azurefd.net' )
1848- monkeypatch .setattr (az , 'get_apim_url' , lambda x : 'https://test-apim.azure-api.net' )
1849- monkeypatch .setattr (az , 'get_appgw_endpoint' , lambda x : ('appgw.contoso.com' , '1.2.3.4' ))
1850-
1851- endpoints = utils .get_endpoints (INFRASTRUCTURE .AFD_APIM_PE , 'test-rg' )
1852-
1853- assert endpoints .afd_endpoint_url == 'https://test-afd.azurefd.net'
1854- assert endpoints .apim_endpoint_url == 'https://test-apim.azure-api.net'
1855- assert endpoints .appgw_hostname == 'appgw.contoso.com'
1856- assert endpoints .appgw_public_ip == '1.2.3.4'
1857-
1858-
1859- def test_get_endpoints_no_frontdoor (monkeypatch , suppress_console ):
1860- """Test get_endpoints when Front Door is not available."""
1861- monkeypatch .setattr (az , 'get_frontdoor_url' , lambda x , y : None )
1862- monkeypatch .setattr (az , 'get_apim_url' , lambda x : 'https://test-apim.azure-api.net' )
1863- monkeypatch .setattr (az , 'get_appgw_endpoint' , lambda x : (None , None ))
1864-
1865- endpoints = utils .get_endpoints (INFRASTRUCTURE .SIMPLE_APIM , 'test-rg' )
1866-
1867- assert endpoints .afd_endpoint_url is None
1868- assert endpoints .apim_endpoint_url == 'https://test-apim.azure-api.net'
1869-
1870-
1826+ # get_endpoint
18711827# ------------------------------
1872- # get_json TESTS
18731828# ------------------------------
18741829
18751830
@@ -2053,20 +2008,6 @@ def test_does_infrastructure_exist_with_prompt_multiple_retries(monkeypatch, sup
20532008 assert result is True # Block deployment
20542009
20552010
2056- def test_get_endpoints_with_none_values (monkeypatch , suppress_console ):
2057- """Test get_endpoints when some endpoints are None."""
2058- monkeypatch .setattr (az , 'get_frontdoor_url' , lambda x , y : None )
2059- monkeypatch .setattr (az , 'get_apim_url' , lambda x : 'https://test-apim.azure-api.net' )
2060- monkeypatch .setattr (az , 'get_appgw_endpoint' , lambda x : (None , None ))
2061-
2062- endpoints = utils .get_endpoints (INFRASTRUCTURE .SIMPLE_APIM , 'test-rg' )
2063-
2064- assert endpoints .afd_endpoint_url is None
2065- assert endpoints .apim_endpoint_url == 'https://test-apim.azure-api.net'
2066- assert endpoints .appgw_hostname is None
2067- assert endpoints .appgw_public_ip is None
2068-
2069-
20702011# ------------------------------
20712012# get_endpoint
20722013# ------------------------------
@@ -2080,7 +2021,7 @@ def test_get_endpoint_with_appgw_both_values(monkeypatch, suppress_console):
20802021 mock_endpoints .appgw_hostname = 'api.contoso.com'
20812022 mock_endpoints .appgw_public_ip = '1.2.3.4'
20822023
2083- monkeypatch .setattr (utils , 'get_endpoints' , lambda d , r : mock_endpoints )
2024+ monkeypatch .setattr (az , 'get_endpoints' , lambda d , r : mock_endpoints )
20842025
20852026 endpoint_url , request_headers , allow_insecure_tls = utils .get_endpoint (INFRASTRUCTURE .APPGW_APIM , 'test-rg' , 'https://apim.azure-api.net' )
20862027
@@ -2098,8 +2039,7 @@ def test_get_endpoint_with_appgw_hostname_only(monkeypatch, suppress_console):
20982039 mock_endpoints .appgw_hostname = 'api.contoso.com'
20992040 mock_endpoints .appgw_public_ip = None
21002041
2101- monkeypatch .setattr (utils , 'get_endpoints' , lambda d , r : mock_endpoints )
2102- monkeypatch .setattr (utils , 'test_url_preflight_check' , lambda d , r , a : 'https://afd.azurefd.net' )
2042+ monkeypatch .setattr (az , 'get_endpoints' , lambda d , r : mock_endpoints )
21032043
21042044 endpoint_url , request_headers , allow_insecure_tls = utils .get_endpoint (INFRASTRUCTURE .APPGW_APIM , 'test-rg' , 'https://apim.azure-api.net' )
21052045
@@ -2116,8 +2056,7 @@ def test_get_endpoint_with_appgw_ip_only(monkeypatch, suppress_console):
21162056 mock_endpoints .appgw_hostname = None
21172057 mock_endpoints .appgw_public_ip = '1.2.3.4'
21182058
2119- monkeypatch .setattr (utils , 'get_endpoints' , lambda d , r : mock_endpoints )
2120- monkeypatch .setattr (utils , 'test_url_preflight_check' , lambda d , r , a : 'https://afd.azurefd.net' )
2059+ monkeypatch .setattr (az , 'get_endpoints' , lambda d , r : mock_endpoints )
21212060
21222061 endpoint_url , request_headers , allow_insecure_tls = utils .get_endpoint (INFRASTRUCTURE .APPGW_APIM , 'test-rg' , 'https://apim.azure-api.net' )
21232062
@@ -2126,16 +2065,15 @@ def test_get_endpoint_with_appgw_ip_only(monkeypatch, suppress_console):
21262065 assert allow_insecure_tls is False
21272066
21282067
2129- def test_get_endpoint_with_no_appgw_uses_preflight (monkeypatch , suppress_console ):
2130- """Test get_endpoint when no appgw values present, uses preflight check ."""
2068+ def test_get_endpoint_with_no_appgw_falls_back_to_apim (monkeypatch , suppress_console ):
2069+ """Test get_endpoint when no appgw values and no AFD, falls back to APIM gateway URL ."""
21312070 mock_endpoints = Endpoints (INFRASTRUCTURE .SIMPLE_APIM )
21322071 mock_endpoints .afd_endpoint_url = None
21332072 mock_endpoints .apim_endpoint_url = 'https://apim.azure-api.net'
21342073 mock_endpoints .appgw_hostname = None
21352074 mock_endpoints .appgw_public_ip = None
21362075
2137- monkeypatch .setattr (utils , 'get_endpoints' , lambda d , r : mock_endpoints )
2138- monkeypatch .setattr (utils , 'test_url_preflight_check' , lambda d , r , a : 'https://apim.azure-api.net' )
2076+ monkeypatch .setattr (az , 'get_endpoints' , lambda d , r : mock_endpoints )
21392077
21402078 endpoint_url , request_headers , allow_insecure_tls = utils .get_endpoint (INFRASTRUCTURE .SIMPLE_APIM , 'test-rg' , 'https://apim.azure-api.net' )
21412079
@@ -2144,16 +2082,15 @@ def test_get_endpoint_with_no_appgw_uses_preflight(monkeypatch, suppress_console
21442082 assert allow_insecure_tls is False
21452083
21462084
2147- def test_get_endpoint_with_afd_via_preflight (monkeypatch , suppress_console ):
2148- """Test get_endpoint returns AFD URL via preflight check ."""
2085+ def test_get_endpoint_with_afd_url (monkeypatch , suppress_console ):
2086+ """Test get_endpoint returns AFD URL when afd_endpoint_url is set ."""
21492087 mock_endpoints = Endpoints (INFRASTRUCTURE .AFD_APIM_PE )
21502088 mock_endpoints .afd_endpoint_url = 'https://myapp.azurefd.net'
21512089 mock_endpoints .apim_endpoint_url = None
21522090 mock_endpoints .appgw_hostname = None
21532091 mock_endpoints .appgw_public_ip = None
21542092
2155- monkeypatch .setattr (utils , 'get_endpoints' , lambda d , r : mock_endpoints )
2156- monkeypatch .setattr (utils , 'test_url_preflight_check' , lambda d , r , a : 'https://myapp.azurefd.net' )
2093+ monkeypatch .setattr (az , 'get_endpoints' , lambda d , r : mock_endpoints )
21572094
21582095 endpoint_url , request_headers , allow_insecure_tls = utils .get_endpoint (
21592096 INFRASTRUCTURE .AFD_APIM_PE , 'test-rg' , 'https://apim-internal.azure-api.net'
@@ -2172,8 +2109,7 @@ def test_get_endpoint_appgw_with_empty_strings(monkeypatch, suppress_console):
21722109 mock_endpoints .appgw_hostname = ''
21732110 mock_endpoints .appgw_public_ip = ''
21742111
2175- monkeypatch .setattr (utils , 'get_endpoints' , lambda d , r : mock_endpoints )
2176- monkeypatch .setattr (utils , 'test_url_preflight_check' , lambda d , r , a : 'https://apim.azure-api.net' )
2112+ monkeypatch .setattr (az , 'get_endpoints' , lambda d , r : mock_endpoints )
21772113
21782114 endpoint_url , request_headers , allow_insecure_tls = utils .get_endpoint (INFRASTRUCTURE .APPGW_APIM , 'test-rg' , 'https://apim.azure-api.net' )
21792115
@@ -2198,8 +2134,7 @@ def test_get_endpoint_various_infrastructures(monkeypatch, suppress_console):
21982134 mock_endpoints .appgw_hostname = None
21992135 mock_endpoints .appgw_public_ip = None
22002136
2201- monkeypatch .setattr (utils , 'get_endpoints' , lambda d , r , m = mock_endpoints : m )
2202- monkeypatch .setattr (utils , 'test_url_preflight_check' , lambda d , r , a : 'https://apim.azure-api.net' )
2137+ monkeypatch .setattr (az , 'get_endpoints' , lambda d , r , m = mock_endpoints : m )
22032138
22042139 endpoint_url , request_headers , allow_insecure_tls = utils .get_endpoint (infra , 'test-rg' , 'https://apim.azure-api.net' )
22052140
@@ -2502,24 +2437,6 @@ def test_wait_for_apim_blob_permissions_with_custom_timeout(monkeypatch, suppres
25022437 mock_check .assert_called_once_with ('test-apim' , 'test-storage' , 'test-rg' , 5 )
25032438
25042439
2505- def test_test_url_preflight_check_with_afd_endpoint (monkeypatch , suppress_console ):
2506- """Test test_url_preflight_check selects AFD when available."""
2507- monkeypatch .setattr (az , 'get_frontdoor_url' , lambda x , y : 'https://afd-endpoint.azurefd.net' )
2508-
2509- result = utils .test_url_preflight_check (INFRASTRUCTURE .AFD_APIM_PE , 'test-rg' , 'https://apim.azure-api.net' )
2510-
2511- assert result == 'https://afd-endpoint.azurefd.net'
2512-
2513-
2514- def test_test_url_preflight_check_without_afd (monkeypatch , suppress_console ):
2515- """Test test_url_preflight_check uses APIM when no AFD."""
2516- monkeypatch .setattr (az , 'get_frontdoor_url' , lambda x , y : None )
2517-
2518- result = utils .test_url_preflight_check (INFRASTRUCTURE .SIMPLE_APIM , 'test-rg' , 'https://apim.azure-api.net' )
2519-
2520- assert result == 'https://apim.azure-api.net'
2521-
2522-
25232440def test_get_json_with_nested_structure ():
25242441 """Test get_json with deeply nested JSON."""
25252442 nested_json = '{"level1": {"level2": {"level3": {"value": "deep"}}}}'
0 commit comments