diff --git a/homeassistant/components/emulated_hue/__init__.py b/homeassistant/components/emulated_hue/__init__.py index 8e855653642..13a4af544c1 100644 --- a/homeassistant/components/emulated_hue/__init__.py +++ b/homeassistant/components/emulated_hue/__init__.py @@ -111,6 +111,7 @@ async def async_setup(hass, yaml_config): DescriptionXmlView(config).register(app, app.router) HueUsernameView().register(app, app.router) + HueConfigView(config).register(app, app.router) HueUnauthorizedUser().register(app, app.router) HueAllLightsStateView(config).register(app, app.router) HueOneLightStateView(config).register(app, app.router) @@ -118,7 +119,6 @@ async def async_setup(hass, yaml_config): HueAllGroupsStateView(config).register(app, app.router) HueGroupView(config).register(app, app.router) HueFullStateView(config).register(app, app.router) - HueConfigView(config).register(app, app.router) upnp_listener = UPNPResponderThread( config.host_ip_addr, diff --git a/homeassistant/components/emulated_hue/hue_api.py b/homeassistant/components/emulated_hue/hue_api.py index 239dd85d5a0..7bba23b4b78 100644 --- a/homeassistant/components/emulated_hue/hue_api.py +++ b/homeassistant/components/emulated_hue/hue_api.py @@ -246,6 +246,7 @@ class HueConfigView(HomeAssistantView): """Return config view of emulated hue.""" url = "/api/{username}/config" + extra_urls = ["/api/config"] name = "emulated_hue:username:config" requires_auth = False @@ -254,12 +255,10 @@ class HueConfigView(HomeAssistantView): self.config = config @core.callback - def get(self, request, username): + def get(self, request, username=""): """Process a request to get the configuration.""" if not is_local(ip_address(request.remote)): return self.json_message("only local IPs allowed", HTTP_UNAUTHORIZED) - if username != HUE_API_USERNAME: - return self.json(UNAUTHORIZED_USER) json_response = create_config_model(self.config, request) diff --git a/tests/components/emulated_hue/test_hue_api.py b/tests/components/emulated_hue/test_hue_api.py index 9c6fb9d37a8..95b4374e11e 100644 --- a/tests/components/emulated_hue/test_hue_api.py +++ b/tests/components/emulated_hue/test_hue_api.py @@ -467,6 +467,24 @@ async def test_discover_config(hue_client): assert "linkbutton" in config_json assert config_json["linkbutton"] is True + # Test without username + result = await hue_client.get("/api/config") + + assert result.status == 200 + assert "application/json" in result.headers["content-type"] + + config_json = await result.json() + assert "error" not in config_json + + # Test with wrong username username + result = await hue_client.get("/api/wronguser/config") + + assert result.status == 200 + assert "application/json" in result.headers["content-type"] + + config_json = await result.json() + assert "error" not in config_json + async def test_get_light_state(hass_hue, hue_client): """Test the getting of light state.""" @@ -1177,7 +1195,6 @@ async def test_unauthorized_user_blocked(hue_client): """Test unauthorized_user blocked.""" getUrls = [ "/api/wronguser", - "/api/wronguser/config", ] for getUrl in getUrls: result = await hue_client.get(getUrl)