async def test_flow_fails_user_credentials_faulty(hass, aioclient_mock):
    'Test config flow.'
    result = (await hass.config_entries.flow.async_init(UNIFI_DOMAIN, context={'source': 'user'}))
    assert (result['type'] == data_entry_flow.RESULT_TYPE_FORM)
    assert (result['step_id'] == 'user')
    aioclient_mock.get('https://1.2.3.4:1234', status=302)
    with patch('aiounifi.Controller.login', side_effect=aiounifi.errors.Unauthorized):
        result = (await hass.config_entries.flow.async_configure(result['flow_id'], user_input={CONF_HOST: '1.2.3.4', CONF_USERNAME: 'username', CONF_PASSWORD: 'password', CONF_PORT: 1234, CONF_VERIFY_SSL: True}))
    assert (result['type'] == data_entry_flow.RESULT_TYPE_FORM)
    assert (result['errors'] == {'base': 'faulty_credentials'})
Test config flow.
async def test_flow_fails_user_credentials_faulty(hass, aioclient_mock):
    
    result = (await hass.config_entries.flow.async_init(UNIFI_DOMAIN, context={'source': 'user'}))
    assert (result['type'] == data_entry_flow.RESULT_TYPE_FORM)
    assert (result['step_id'] == 'user')
    aioclient_mock.get('https://1.2.3.4:1234', status=302)
    with patch('aiounifi.Controller.login', side_effect=aiounifi.errors.Unauthorized):
        result = (await hass.config_entries.flow.async_configure(result['flow_id'], user_input={CONF_HOST: '1.2.3.4', CONF_USERNAME: 'username', CONF_PASSWORD: 'password', CONF_PORT: 1234, CONF_VERIFY_SSL: True}))
    assert (result['type'] == data_entry_flow.RESULT_TYPE_FORM)
    assert (result['errors'] == {'base': 'faulty_credentials'})