Exemple #1
0
async def test_ssdp_legacy_missing_auth(hass: HomeAssistant, remotews: Mock):
    """Test starting a flow from discovery with authentication."""
    with patch(
            "homeassistant.components.samsungtv.bridge.Remote",
            side_effect=AccessDenied("Boom"),
    ):

        # confirm to add the entry
        result = await hass.config_entries.flow.async_init(
            DOMAIN,
            context={"source": config_entries.SOURCE_SSDP},
            data=MOCK_SSDP_DATA)
        assert result["type"] == "form"
        assert result["step_id"] == "confirm"

        # missing authentication

        with patch(
                "homeassistant.components.samsungtv.bridge.SamsungTVLegacyBridge.try_connect",
                return_value=RESULT_AUTH_MISSING,
        ):
            result = await hass.config_entries.flow.async_configure(
                result["flow_id"], user_input="whatever")
            assert result["type"] == "abort"
            assert result["reason"] == RESULT_AUTH_MISSING
async def test_user_legacy_missing_auth(hass):
    """Test starting a flow by user with authentication."""
    with patch(
            "homeassistant.components.samsungtv.bridge.Remote",
            side_effect=AccessDenied("Boom"),
    ), patch("homeassistant.components.samsungtv.config_flow.socket"):
        # legacy device missing authentication
        result = await hass.config_entries.flow.async_init(
            DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA)
        assert result["type"] == "abort"
        assert result["reason"] == "auth_missing"
async def test_user_legacy_missing_auth(hass: HomeAssistant, remote: Mock):
    """Test starting a flow by user with authentication."""
    with patch(
        "homeassistant.components.samsungtv.bridge.Remote",
        side_effect=AccessDenied("Boom"),
    ):
        # legacy device missing authentication
        result = await hass.config_entries.flow.async_init(
            DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
        )
        assert result["type"] == "abort"
        assert result["reason"] == RESULT_AUTH_MISSING
Exemple #4
0
async def test_autodetect_auth_missing(hass, remote):
    """Test for send key with autodetection of protocol."""
    with patch(
            "homeassistant.components.samsungtv.config_flow.Remote",
            side_effect=[AccessDenied("Boom")],
    ) as remote:
        result = await hass.config_entries.flow.async_init(
            DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA)
        assert result["type"] == "abort"
        assert result["reason"] == "auth_missing"
        assert remote.call_count == 1
        assert remote.call_args_list == [call(AUTODETECT_WEBSOCKET)]
Exemple #5
0
async def test_autodetect_auth_missing(hass: HomeAssistant):
    """Test for send key with autodetection of protocol."""
    with patch(
            "homeassistant.components.samsungtv.bridge.Remote",
            side_effect=[AccessDenied("Boom")],
    ) as remote:
        result = await hass.config_entries.flow.async_init(
            DOMAIN,
            context={"source": config_entries.SOURCE_USER},
            data=MOCK_USER_DATA)
        assert result["type"] == "abort"
        assert result["reason"] == RESULT_AUTH_MISSING
        assert remote.call_count == 1
        assert remote.call_args_list == [call(AUTODETECT_LEGACY)]
async def test_autodetect_auth_missing(opp: OpenPeerPower, remote: Mock):
    """Test for send key with autodetection of protocol."""
    with patch(
            "openpeerpower.components.samsungtv.bridge.Remote",
            side_effect=[AccessDenied("Boom")],
    ) as remote, patch(
            "openpeerpower.components.samsungtv.config_flow.socket.gethostbyname",
            return_value="fake_host",
    ):
        result = await opp.config_entries.flow.async_init(
            DOMAIN,
            context={"source": config_entries.SOURCE_USER},
            data=MOCK_USER_DATA)
        assert result["type"] == "abort"
        assert result["reason"] == RESULT_AUTH_MISSING
        assert remote.call_count == 1
        assert remote.call_args_list == [call(AUTODETECT_LEGACY)]
Exemple #7
0
async def test_ssdp_missing_auth(hass):
    """Test starting a flow from discovery with authentication."""
    with patch(
            "homeassistant.components.samsungtv.config_flow.Remote",
            side_effect=AccessDenied("Boom"),
    ), patch("homeassistant.components.samsungtv.config_flow.socket"):

        # confirm to add the entry
        result = await hass.config_entries.flow.async_init(
            DOMAIN, context={"source": "ssdp"}, data=MOCK_SSDP_DATA)
        assert result["type"] == "form"
        assert result["step_id"] == "confirm"

        # missing authentication
        result = await hass.config_entries.flow.async_configure(
            result["flow_id"], user_input="whatever")
        assert result["type"] == "abort"
        assert result["reason"] == "auth_missing"
async def test_ssdp_legacy_missing_auth(opp: OpenPeerPower, remote: Mock):
    """Test starting a flow from discovery with authentication."""
    with patch(
            "openpeerpower.components.samsungtv.bridge.Remote",
            side_effect=AccessDenied("Boom"),
    ):

        # confirm to add the entry
        result = await opp.config_entries.flow.async_init(
            DOMAIN,
            context={"source": config_entries.SOURCE_SSDP},
            data=MOCK_SSDP_DATA)
        assert result["type"] == "form"
        assert result["step_id"] == "confirm"

        # missing authentication
        result = await opp.config_entries.flow.async_configure(
            result["flow_id"], user_input="whatever")
        assert result["type"] == "abort"
        assert result["reason"] == RESULT_AUTH_MISSING