diff --git a/homeassistant/components/proxmoxve/common.py b/homeassistant/components/proxmoxve/common.py index 790f5ffa891d..32131808af7c 100644 --- a/homeassistant/components/proxmoxve/common.py +++ b/homeassistant/components/proxmoxve/common.py @@ -5,7 +5,7 @@ from typing import Any from homeassistant.const import CONF_USERNAME -from .const import AUTH_OTHER, CONF_AUTH_METHOD, CONF_REALM +from .const import AUTH_OTHER, CONF_AUTH_METHOD, CONF_REALM, CONF_TOKEN_ID def sanitize_config_entry(input_data: Mapping[str, Any]) -> dict[str, Any]: @@ -21,4 +21,7 @@ def sanitize_config_entry(input_data: Mapping[str, Any]) -> dict[str, Any]: data[CONF_REALM] = realm data[CONF_USERNAME] = f"{username}@{realm}" + if CONF_TOKEN_ID in data and "!" in data[CONF_TOKEN_ID]: + data[CONF_TOKEN_ID] = data[CONF_TOKEN_ID].split("!")[1] + return data diff --git a/tests/components/proxmoxve/test_config_flow.py b/tests/components/proxmoxve/test_config_flow.py index 877bf92610fa..a11c6637e571 100644 --- a/tests/components/proxmoxve/test_config_flow.py +++ b/tests/components/proxmoxve/test_config_flow.py @@ -62,6 +62,11 @@ MOCK_USER_AUTH_STEP_TOKEN = { CONF_TOKEN_SECRET: "test_token_secret", } +MOCK_USER_AUTH_STEP_TOKEN_FULL_ID = { + CONF_TOKEN_ID: "test_user@pam!test_token_id", + CONF_TOKEN_SECRET: "test_token_secret", +} + # Other authentication method (e.g. LDAP) with realm MOCK_USER_STEP_OTHER = { **MOCK_USER_STEP, @@ -97,6 +102,11 @@ MOCK_USER_FINAL = { [ (MOCK_USER_STEP, MOCK_USER_AUTH_STEP_PASSWORD, MOCK_TEST_CONFIG), (MOCK_USER_STEP_TOKEN, MOCK_USER_AUTH_STEP_TOKEN, MOCK_TEST_TOKEN_CONFIG), + ( + MOCK_USER_STEP_TOKEN, + MOCK_USER_AUTH_STEP_TOKEN_FULL_ID, + MOCK_TEST_TOKEN_CONFIG, + ), (MOCK_USER_STEP_OTHER, MOCK_USER_AUTH_STEP_OTHER, MOCK_TEST_OTHER_CONFIG), ( MOCK_USER_STEP_OTHER_TOKEN,