Add multi-factor auth module setup flow (#16141)
* Add mfa setup flow * Lint * Address code review comment * Fix unit test * Add assertion for WS response ordering * Missed a return * Remove setup_schema from MFA base class * Move auth.util.validate_current_user -> webscoket_api.ws_require_user
This commit is contained in:
1 parent
e567b2281d
commit
914d90a2bc
8 files changed
+386
-36
No files matched your search
@@ -125,3 +125,21 @@ async def test_login(hass):
|
||||
result['flow_id'], {'pin': '123456'})
|
||||
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result['data'].id == 'mock-user'
|
||||
|
||||
|
||||
async def test_setup_flow(hass):
|
||||
"""Test validating pin."""
|
||||
auth_module = await auth_mfa_module_from_config(hass, {
|
||||
'type': 'insecure_example',
|
||||
'data': [{'user_id': 'test-user', 'pin': '123456'}]
|
||||
})
|
||||
|
||||
flow = await auth_module.async_setup_flow('new-user')
|
||||
|
||||
result = await flow.async_step_init()
|
||||
assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
|
||||
|
||||
result = await flow.async_step_init({'pin': 'abcdefg'})
|
||||
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert auth_module._data[1]['user_id'] == 'new-user'
|
||||
assert auth_module._data[1]['pin'] == 'abcdefg'
|
||||
Reference in new issue
Block a user