Skip to content

Commit d92f5c1

Browse files
committed
http: add redirect conflict
This conflict is added, since the migration here would not preserve behaviour. Change-Id: I24b70f383fdaa68e07845dfca64cabe79e31e13e
1 parent 5d61094 commit d92f5c1

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

cmk/update_config/http/conflicts.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def detect_conflicts(rule_value: Mapping[str, object]) -> Conflict | MigratableV
159159
mode_fields=["method", "post_data"],
160160
)
161161
try:
162-
_migrate_expect_response(mode.expect_response or [])
162+
migrated_expect_response = _migrate_expect_response(mode.expect_response or [])
163163
except ValueError:
164164
return Conflict(
165165
type_="only_status_codes_allowed",
@@ -171,6 +171,11 @@ def detect_conflicts(rule_value: Mapping[str, object]) -> Conflict | MigratableV
171171
mode_fields=["ssl"],
172172
disable_sni=True,
173173
)
174+
if migrated_expect_response and mode.onredirect in ["follow", "sticky", "stickyport"]:
175+
return Conflict(
176+
type_="v1_checks_redirect_response",
177+
mode_fields=["onredirect", "expect_response"],
178+
)
174179
elif value.disable_sni: # Cert mode is always https
175180
return Conflict(
176181
type_="cant_disable_sni_with_https",

tests/unit/cmk/update_config/http/test_migrate.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,18 @@
730730

731731
EXAMPLE_90: Mapping[str, object] = {}
732732

733+
EXAMPLE_91: Mapping[str, object] = {
734+
"name": "authorization",
735+
"host": HOST_1,
736+
"mode": (
737+
"url",
738+
{
739+
"expect_response": ["302"],
740+
"onredirect": "stickyport",
741+
},
742+
),
743+
}
744+
733745

734746
@pytest.mark.parametrize(
735747
"rule_value",
@@ -1167,6 +1179,13 @@ def test_migrate_ssl(rule_value: Mapping[str, object], expected: str) -> None:
11671179
cant_load=True,
11681180
),
11691181
),
1182+
(
1183+
EXAMPLE_91,
1184+
Conflict(
1185+
type_="v1_checks_redirect_response",
1186+
mode_fields=["onredirect", "expect_response"],
1187+
),
1188+
),
11701189
],
11711190
)
11721191
def test_detect_conflicts(rule_value: Mapping[str, object], conflict: Conflict) -> None:

0 commit comments

Comments
 (0)