Skip to content

Commit 84324f7

Browse files
Replace policy_xml_replacement with read_policy_xml
Resolves #16
1 parent 5e9a29c commit 84324f7

File tree

4 files changed

+2
-31
lines changed

4 files changed

+2
-31
lines changed

infrastructure/afd-apim/create.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"# 3) Define the APIs and their operations and policies\n",
4646
"\n",
4747
"# Policies\n",
48-
"hello_world_policy_xml = utils.policy_xml_replacement(HELLO_WORLD_XML_POLICY_PATH)\n",
48+
"hello_world_policy_xml = utils.read_policy_xml(HELLO_WORLD_XML_POLICY_PATH)\n",
4949
"\n",
5050
"# Hello World (Root)\n",
5151
"api_hwroot_get = GET_APIOperation('This is a GET for API 1', hello_world_policy_xml)\n",

samples/general/create.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"api2 = API('API2', 'API 2', '/api2', 'This is API 2', operations = [api2_post], tags = tags)\n",
6767
"\n",
6868
"# Request Headers\n",
69-
"rh_policy_xml = utils.policy_xml_replacement(REQUEST_HEADERS_XML_POLICY_PATH)\n",
69+
"rh_policy_xml = utils.read_policy_xml(REQUEST_HEADERS_XML_POLICY_PATH)\n",
7070
"rh_get = GET_APIOperation('Gets the request headers for the current request and returns them. Great for troubleshooting.', rh_policy_xml)\n",
7171
"rh = API('requestheaders', 'Request Headers', '/request-headers', 'API for request headers', operations = [rh_get], tags = tags)\n",
7272
"\n",

shared/python/utils.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -306,26 +306,6 @@ def does_resource_group_exist(rg_name: str) -> bool:
306306
output = run(f"az group show --name {rg_name}", print_output = False, print_errors = False)
307307
return output.success
308308

309-
def policy_xml_replacement(policy_xml_filepath: str) -> str:
310-
"""
311-
Read and return the contents of a policy XML file.
312-
313-
Args:
314-
policy_xml_filepath (str): Path to the policy XML file.
315-
316-
Returns:
317-
str: Contents of the policy XML file.
318-
"""
319-
320-
# Read the specified policy XML file
321-
with open(policy_xml_filepath, 'r') as policy_xml_file:
322-
policy_template_xml = policy_xml_file.read()
323-
324-
# TODO: Perform any replacements here
325-
326-
# Convert the XML to JSON format
327-
return policy_template_xml
328-
329309
def read_policy_xml(policy_xml_filepath: str) -> str:
330310
"""
331311
Read and return the contents of a policy XML file.

tests/python/test_utils.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,6 @@ def test_read_policy_xml_empty_file(monkeypatch):
162162
result = utils.read_policy_xml('empty.xml')
163163
assert result == ''
164164

165-
# ------------------------------
166-
# policy_xml_replacement
167-
# ------------------------------
168-
169-
def test_policy_xml_replacement(monkeypatch):
170-
m = mock_open(read_data='<xml>foo</xml>')
171-
monkeypatch.setattr(builtins, 'open', m)
172-
assert utils.policy_xml_replacement('dummy.xml') == '<xml>foo</xml>'
173-
174165
# ------------------------------
175166
# cleanup_resources (smoke)
176167
# ------------------------------

0 commit comments

Comments
 (0)