7df8ed4a60
Change SecScanAPI to use a uri creation func instead of test context Pass config provider through validator context Remove app config dependency for validators
30 lines
983 B
Python
30 lines
983 B
Python
import pytest
|
|
|
|
from util.config.validator import ValidatorContext
|
|
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(ValidatorContext(unvalidated_config))
|
|
|
|
|
|
def test_validate_auth(app):
|
|
config = ValidatorContext({
|
|
'AUTHENTICATION_TYPE': 'AppToken',
|
|
'FEATURE_APP_SPECIFIC_TOKENS': True,
|
|
'FEATURE_DIRECT_LOGIN': False,
|
|
})
|
|
|
|
validator = AppTokenAuthValidator()
|
|
validator.validate(config)
|