Пример #1
0
 def test_convert_config_file_to_json_dict_valid_file_booleans_as_bool(
         self):
     data = Utils._convert_config_file_to_json_dict(HARDENED_FILE)
     assert type(data) == dict
     assert len(data) > 0
     assert type(data['core']['remote_logging']) == bool
     assert data['core']['remote_logging'] == False
Пример #2
0
    def test_load_schema(self):
        schema_data = Utils._load_schema()
        properties = schema_data['properties']

        assert len(properties['admin']) > 0
        assert len(properties['api']) > 0
        assert len(properties['celery']) > 0
        assert len(properties['core']) > 0
        assert len(properties['dask']) > 0
        assert len(properties['ldap']) > 0
        assert len(properties['scheduler']) > 0
        assert len(properties['smtp']) > 0
        assert len(properties['webserver']) > 0
Пример #3
0
def scan(filename):
    """Scan an Airflow configuration file ('airflow.cfg')"""

    # Get validation errors
    errors = Utils.validate(filename)

    # Display results to the user
    for error in errors:
        click.echo(error.title)
        if error.setting:
            click.echo('Section [' + error.section + '], setting "' +
                       error.setting + '": ' + error.message + "\n")
        else:
            click.echo('Section [' + error.section + ']: ' + error.message +
                       "\n")

    # Return error
    if len(errors) > 0:
        click.echo("Total validation errors found: " + str(len(errors)))
        exit(1)
Пример #4
0
 def test_validate_hardened_file(self):
     data = Utils.validate(HARDENED_FILE)
     assert len(data) == 0
Пример #5
0
 def test_validate_default_file(self):
     data = Utils.validate(DEFAULT_FILE)
     assert len(data) == 30
Пример #6
0
 def test_convert_config_file_to_json_dict_arrays_as_str(self):
     data = Utils._convert_config_file_to_json_dict(HARDENED_FILE)
     assert type(data) == dict
     assert len(data) > 0
     assert type(data['celery']['flower_basic_auth']) == str
     assert len(data['celery']['flower_basic_auth']) > 0
Пример #7
0
 def test_convert_config_file_to_json_dict(self):
     data = Utils._convert_config_file_to_json_dict(HARDENED_FILE)
     assert type(data) == dict
     assert len(data) > 0
     assert type(data['core']['logging_level']) == str
     assert data['core']['logging_level'] == 'INFO'
Пример #8
0
 def test_convert_config_file_to_json_dict_file_doesnt_exist(self):
     data = Utils._convert_config_file_to_json_dict('foobar')
     assert type(data) == dict
     assert len(data) == 0
Пример #9
0
 def test_convert_config_file_to_json_dict_file_doesnt_exist(self):
     with pytest.raises(AnyMarkupError):
         Utils._convert_config_file_to_json_dict('foobar')