30 lines
920 B
Python
30 lines
920 B
Python
|
import pytest
|
||
|
|
||
|
from util.config.validators import ConfigValidationException
|
||
|
from util.config.validators.validate_apptokenauth import AppTokenAuthValidator
|
||
|
|
||
|
from test.fixtures import *
|
||
|
|
||
|
@pytest.mark.parametrize('unvalidated_config', [
|
||
|
({'AUTHENTICATION_TYPE': 'AppToken'}),
|
||
|
({'AUTHENTICATION_TYPE': 'AppToken', 'FEATURE_APP_SPECIFIC_TOKENS': False}),
|
||
|
({'AUTHENTICATION_TYPE': 'AppToken', 'FEATURE_APP_SPECIFIC_TOKENS': True,
|
||
|
'FEATURE_DIRECT_LOGIN': True}),
|
||
|
])
|
||
|
def test_validate_invalid_auth_config(unvalidated_config, app):
|
||
|
validator = AppTokenAuthValidator()
|
||
|
|
||
|
with pytest.raises(ConfigValidationException):
|
||
|
validator.validate(unvalidated_config, None, None)
|
||
|
|
||
|
|
||
|
def test_validate_auth(app):
|
||
|
config = {
|
||
|
'AUTHENTICATION_TYPE': 'AppToken',
|
||
|
'FEATURE_APP_SPECIFIC_TOKENS': True,
|
||
|
'FEATURE_DIRECT_LOGIN': False,
|
||
|
}
|
||
|
|
||
|
validator = AppTokenAuthValidator()
|
||
|
validator.validate(config, None, None)
|