Skip to content

Commit a00fc81

Browse files
fix: updating url rule (#864)
Updated **url** rule so that if only url["path"] or url["query"] is given, just path and query is generated. EG: url["path"] will generate path like: "/random/path" EG: url["query"] will generate query like: "?asd=abs"
1 parent ea24436 commit a00fc81

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

pytest_splunk_addon/sample_generation/rule.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,8 @@ def replace(self, sample, token_count):
934934
url = self.fake.url()
935935

936936
if bool(set(["full", "path"]).intersection(value_list)):
937+
if value_list == ["path"]:
938+
url = ""
937939
url = (
938940
url
939941
+ "/"
@@ -944,8 +946,9 @@ def replace(self, sample, token_count):
944946
]
945947
)
946948
)
947-
948949
if bool(set(["full", "query"]).intersection(value_list)):
950+
if value_list == ["query"]:
951+
url = ""
949952
url = url + self.generate_url_query_params()
950953
yield self.token_value(*([str(url)] * 2))
951954
else:

tests/e2e/addons/TA_fiction_indextime/default/props.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ FIELDALIAS-write_ops = w_op_s as write_ops
1212
EVAL-total_ops = read_ops + write_ops
1313
EVAL-vendor_product = if(isnull(vendor_product), "TEST_INDEX_TIME", vendor_product)
1414

15+
[test:indextime:sourcetype_basic]
16+
EVAL-extracted_path = if(match(test_url_path,"^\/.*"), test_url_query, null)
17+
EVAL-extracted_query = if(match(test_url_query,"^\?.*"), test_url_query, null)
18+
1519
[test:indextime:sourcetype:file_all_dependent]
1620
TRANSFORMS-sourcetype_file_all_dependent_change_host = sourcetype_file_all_dependent_change_host
1721

tests/e2e/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,11 @@
497497
"*test_splunk_fiction_indextime.py::Test_App::test_indextime_key_fields*test:indextime:sourcetype:modinput_host_event_time_plugin::modinput_host_event_time_plugin.samples_2* PASSED*",
498498
"*test_splunk_fiction_indextime.py::Test_App::test_indextime_key_fields*test:indextime:sourcetype:user_email_relation_time_plugin::sample_file_two.samples* PASSED*",
499499
"*test_splunk_fiction_indextime.py::Test_App::test_indextime_key_fields*test:indextime:sourcetype_basic::sample-file-samples-13* PASSED*",
500+
"*test_splunk_fiction_indextime.py::Test_App::test_props_fields[test:indextime:sourcetype_basic::field::extracted_query* PASSED*",
501+
"*test_splunk_fiction_indextime.py::Test_App::test_props_fields[test:indextime:sourcetype_basic::field::extracted_path* PASSED*",
502+
"*test_splunk_fiction_indextime.py::Test_App::test_props_fields[test:indextime:sourcetype_basic* PASSED*",
503+
"*test_splunk_fiction_indextime.py::Test_App::test_props_fields_no_dash_not_empty[test:indextime:sourcetype_basic::field::extracted_path* PASSED*",
504+
"*test_splunk_fiction_indextime.py::Test_App::test_props_fields_no_dash_not_empty[test:indextime:sourcetype_basic::field::extracted_query* PASSED*",
500505
"*test_splunk_fiction_indextime.py::Test_App::test_indextime_key_fields*test:indextime:sourcetype_basic::sample-file-samples-14* PASSED*",
501506
"*test_splunk_fiction_indextime.py::Test_App::test_indextime_key_fields*test:indextime:sourcetype_basic::sample-file-samples-15* PASSED*",
502507
"*test_splunk_fiction_indextime.py::Test_App::test_indextime_key_fields*test:indextime:sourcetype_basic::sample-file-samples-16* PASSED*",

0 commit comments

Comments
 (0)