Add re-auth and re-configure flow to libreNMS - #180301
Open
mib1185 wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds LibreNMS reauthentication and reconfiguration flows, including validation, translations, and tests.
Changes:
- Adds API-key reauthentication and connection reconfiguration.
- Adds flow translations and test coverage.
- Promotes LibreNMS to Silver quality scale.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/librenms/config_flow.py |
Implements reauthentication and reconfiguration flows. |
homeassistant/components/librenms/strings.json |
Adds flow translations. |
homeassistant/components/librenms/manifest.json |
Promotes the integration to Silver. |
homeassistant/components/librenms/quality_scale.yaml |
Marks both flows complete. |
tests/components/librenms/test_config_flow.py |
Tests successful and failing flow paths. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+190
to
+191
| else: | ||
| try: |
|
|
||
| return self.async_show_form( | ||
| step_id="reauth_confirm", | ||
| data_schema=vol.Schema({vol.Required(CONF_API_KEY): str}), |
| entry = self._get_reconfigure_entry() | ||
| current_data = entry.data | ||
|
|
||
| url = f"{'https' if current_data[CONF_SSL] else 'http'}://{current_data[CONF_HOST]}:{current_data[CONF_PORT]}" |
| url = user_input[CONF_URL] | ||
| verify_ssl = user_input[CONF_VERIFY_SSL] | ||
| try: | ||
| (host, port, ssl) = _parse_url(user_input[CONF_URL]) |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (4)
homeassistant/components/librenms/config_flow.py:166
- Render the API key with a password selector. Using
strmakes reauthentication show a normal text field, unlike the initial flow at lines 45–47, so the credential is visible while entered.
data_schema=vol.Schema({vol.Required(CONF_API_KEY): str}),
homeassistant/components/librenms/config_flow.py:179
- Build the suggested URL with
URL.build. Concatenating an IPv6 host such as::1produceshttps://::1:443, so opening reconfigure for an existing IPv6 entry supplies an invalid default; the coordinator already usesURL.buildto bracket these hosts correctly.
url = f"{'https' if current_data[CONF_SSL] else 'http'}://{current_data[CONF_HOST]}:{current_data[CONF_PORT]}"
homeassistant/components/librenms/config_flow.py:191
- Abort when another entry already uses the submitted host and port. The user flow enforces this pair as the integration's uniqueness key, but reconfigure currently skips the same check, allowing two entries to target one LibreNMS instance.
else:
try:
homeassistant/components/librenms/config_flow.py:187
- Reject URL schemes other than HTTP and HTTPS.
_parse_urlmaps every non-HTTPS scheme tossl=False, so an input such asftp://librenms:443can pass parsing and be saved as an HTTP endpoint instead of returninginvalid_url; the URL selector only controls the browser input type and does not validate the scheme server-side.
(host, port, ssl) = _parse_url(user_input[CONF_URL])
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
SSIA
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: