Blame SOURCES/bz2058243-02-make-booth-ticket-mode-value-case-insensitive.patch

4434d4
From de4845ea2d22c7dd9f4539360b44a900b1cea193 Mon Sep 17 00:00:00 2001
4434d4
From: Tomas Jelinek <tojeline@redhat.com>
4434d4
Date: Thu, 14 Jul 2022 16:46:33 +0200
4434d4
Subject: [PATCH 2/3] make booth ticket mode value case insensitive
4434d4
4434d4
---
4434d4
 pcs/lib/booth/config_validators.py        | 10 ++++++++
4434d4
 pcs/lib/commands/booth.py                 | 14 +++++++++---
4434d4
 pcs_test/tier0/lib/commands/test_booth.py | 28 ++++++++++++++++-------
4434d4
 3 files changed, 41 insertions(+), 11 deletions(-)
4434d4
4434d4
diff --git a/pcs/lib/booth/config_validators.py b/pcs/lib/booth/config_validators.py
4434d4
index 99badc46..6c4a4ddc 100644
4434d4
--- a/pcs/lib/booth/config_validators.py
4434d4
+++ b/pcs/lib/booth/config_validators.py
4434d4
@@ -100,6 +100,16 @@ def remove_ticket(conf_facade, ticket_name):
4434d4
     return []
4434d4
 
4434d4
 
4434d4
+def ticket_options_normalization() -> validate.TypeNormalizeFunc:
4434d4
+    return validate.option_value_normalization(
4434d4
+        {
4434d4
+            "mode": (
4434d4
+                lambda value: value.lower() if isinstance(value, str) else value
4434d4
+            )
4434d4
+        }
4434d4
+    )
4434d4
+
4434d4
+
4434d4
 def validate_ticket_name(ticket_name: str) -> reports.ReportItemList:
4434d4
     if not __TICKET_NAME_RE.search(ticket_name):
4434d4
         return [
4434d4
diff --git a/pcs/lib/commands/booth.py b/pcs/lib/commands/booth.py
4434d4
index e7891fbe..fc1454ce 100644
4434d4
--- a/pcs/lib/commands/booth.py
4434d4
+++ b/pcs/lib/commands/booth.py
4434d4
@@ -23,7 +23,10 @@ from pcs.common.reports.item import (
4434d4
 )
4434d4
 from pcs.common.services.errors import ManageServiceError
4434d4
 from pcs.common.str_tools import join_multilines
4434d4
-from pcs.lib import tools
4434d4
+from pcs.lib import (
4434d4
+    tools,
4434d4
+    validate,
4434d4
+)
4434d4
 from pcs.lib.booth import (
4434d4
     config_files,
4434d4
     config_validators,
4434d4
@@ -329,17 +332,22 @@ def config_ticket_add(
4434d4
     booth_env = env.get_booth_env(instance_name)
4434d4
     try:
4434d4
         booth_conf = booth_env.config.read_to_facade()
4434d4
+        options_pairs = validate.values_to_pairs(
4434d4
+            options, config_validators.ticket_options_normalization()
4434d4
+        )
4434d4
         report_processor.report_list(
4434d4
             config_validators.add_ticket(
4434d4
                 booth_conf,
4434d4
                 ticket_name,
4434d4
-                options,
4434d4
+                options_pairs,
4434d4
                 allow_unknown_options=allow_unknown_options,
4434d4
             )
4434d4
         )
4434d4
         if report_processor.has_errors:
4434d4
             raise LibraryError()
4434d4
-        booth_conf.add_ticket(ticket_name, options)
4434d4
+        booth_conf.add_ticket(
4434d4
+            ticket_name, validate.pairs_to_values(options_pairs)
4434d4
+        )
4434d4
         booth_env.config.write_facade(booth_conf, can_overwrite=True)
4434d4
     except RawFileError as e:
4434d4
         report_processor.report(raw_file_error_report(e))
4434d4
diff --git a/pcs_test/tier0/lib/commands/test_booth.py b/pcs_test/tier0/lib/commands/test_booth.py
4434d4
index 2b20a199..12b169c2 100644
4434d4
--- a/pcs_test/tier0/lib/commands/test_booth.py
4434d4
+++ b/pcs_test/tier0/lib/commands/test_booth.py
4434d4
@@ -1194,7 +1194,7 @@ class ConfigTicketAdd(TestCase, FixtureMixin):
4434d4
             },
4434d4
         )
4434d4
 
4434d4
-    def test_success_ticket_options(self):
4434d4
+    def assert_success_ticket_options(self, options_command, options_config):
4434d4
         self.config.raw_file.read(
4434d4
             file_type_codes.BOOTH_CONFIG,
4434d4
             self.fixture_cfg_path(),
4434d4
@@ -1203,17 +1203,29 @@ class ConfigTicketAdd(TestCase, FixtureMixin):
4434d4
         self.config.raw_file.write(
4434d4
             file_type_codes.BOOTH_CONFIG,
4434d4
             self.fixture_cfg_path(),
4434d4
-            self.fixture_cfg_content(
4434d4
-                ticket_list=[
4434d4
-                    ["ticketA", [("retries", "10"), ("timeout", "20")]]
4434d4
-                ]
4434d4
-            ),
4434d4
+            self.fixture_cfg_content(ticket_list=[["ticketA", options_config]]),
4434d4
             can_overwrite=True,
4434d4
         )
4434d4
         commands.config_ticket_add(
4434d4
-            self.env_assist.get_env(),
4434d4
-            "ticketA",
4434d4
+            self.env_assist.get_env(), "ticketA", options_command
4434d4
+        )
4434d4
+
4434d4
+    def test_success_ticket_options(self):
4434d4
+        self.assert_success_ticket_options(
4434d4
             {"timeout": "20", "retries": "10"},
4434d4
+            [("retries", "10"), ("timeout", "20")],
4434d4
+        )
4434d4
+
4434d4
+    def test_success_ticket_options_mode(self):
4434d4
+        self.assert_success_ticket_options(
4434d4
+            {"timeout": "20", "retries": "10", "mode": "manual"},
4434d4
+            [("mode", "manual"), ("retries", "10"), ("timeout", "20")],
4434d4
+        )
4434d4
+
4434d4
+    def test_success_ticket_options_mode_case_insensitive(self):
4434d4
+        self.assert_success_ticket_options(
4434d4
+            {"timeout": "20", "retries": "10", "mode": "MaNuAl"},
4434d4
+            [("mode", "manual"), ("retries", "10"), ("timeout", "20")],
4434d4
         )
4434d4
 
4434d4
     def test_ticket_already_exists(self):
4434d4
-- 
4434d4
2.35.3
4434d4