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 2018-07-19 22:10:36 +02:00 committed by GitHub
parent a42288d056
commit 2fcacbff23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 82 additions and 23 deletions

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."""