Allow auth providers to influence is_active (#15557)

* Allow auth providers to influence is_active

* Fix auth script test
This commit is contained in:
Paulus Schoutsen authored and Paulus Schoutsen committed 2018-07-20 12:32:44 +02:00
1 parent 61b3822374
commit b3bed7fb37
11 files changed
+82 -23

No files matched your search

+15 -2
View File
@@ -4,7 +4,7 @@ import uuid
import pytest
from homeassistant.auth import auth_store, models as auth_models
from homeassistant.auth import auth_store, models as auth_models, AuthManager
from homeassistant.auth.providers import insecure_example
from tests.common import mock_coro
@@ -23,6 +23,7 @@ def provider(hass, store):
'type': 'insecure_example',
'users': [
{
'name': 'Test Name',
'username': 'user-test',
'password': 'password-test',
},
@@ -34,7 +35,15 @@ def provider(hass, store):
})
async def test_create_new_credential(provider):
@pytest.fixture
def manager(hass, store, provider):
"""Mock manager."""
return AuthManager(hass, store, {
(provider.type, provider.id): provider
})
async def test_create_new_credential(manager, provider):
"""Test that we create a new credential."""
credentials = await provider.async_get_or_create_credentials({
'username': 'user-test',
@@ -42,6 +51,10 @@ async def test_create_new_credential(provider):
})
assert credentials.is_new is True
user = await manager.async_get_or_create_user(credentials)
assert user.name == 'Test Name'
assert user.is_active
async def test_match_existing_credentials(store, provider):
"""See if we match existing users."""