Exemplo n.º 1
0
def test_config():
    config = Config("dummy", "dummy")
    CleanupAWSVPCsPlugin.add_config(config)
    Config.init_default_config()
    assert Config.plugin_cleanup_aws_vpcs.enabled is False
    assert Config.plugin_cleanup_aws_vpcs.validate(
        Config.plugin_cleanup_aws_vpcs) is True
Exemplo n.º 2
0
def test_config():
    config = Config("dummy", "dummy")
    CleanupUntaggedPlugin.add_config(config)
    Config.init_default_config()
    assert Config.plugin_cleanup_untagged.enabled is False
    assert Config.plugin_cleanup_untagged.validate(
        Config.plugin_cleanup_untagged) is True
Exemplo n.º 3
0
def test_config():
    config = Config("dummy", "dummy")
    OneLoginPlugin.add_config(config)
    config.init_default_config()
    assert Config.onelogin.region == "us"
    assert Config.onelogin.client_id is None
    assert Config.onelogin.client_secret is None
Exemplo n.º 4
0
def test_config():
    arg_parser = get_arg_parser()
    core_add_args(arg_parser)
    arg_parser.parse_known_args()
    cfg = Config("test")
    cfg.add_config(ConfigTest)
    cfg.init_default_config()
    assert Config.dict() == {
        "configtest": {
            "testvar1": "testing123",
            "testvar2": 12345,
            "testvar3": {
                "mydict": {
                    "foo": "bar",
                    "abc": {
                        "def": "ghi"
                    }
                },
                "myint": 0,
                "mystr": "Hello",
            },
        }
    }
    cfg2 = Config("test2")
    assert cfg.configtest.testvar1 == cfg2.configtest.testvar1
    assert cfg.configtest.testvar1 == Config.configtest.testvar1
    assert cfg.configtest.testvar2 == cfg2.configtest.testvar2
    assert cfg.configtest.testvar3 == cfg2.configtest.testvar3
    Config.configtest.testvar2 += 1
    assert cfg.configtest.testvar2 == 12346
    with pytest.raises(ConfigNotFoundError):
        Config.does_not_exist.foo = "bar"
    with pytest.raises(ConfigNotFoundError):
        cfg.does_not_exist.foo = "bar"
Exemplo n.º 5
0
def test_config():
    config = Config("dummy", "dummy")
    TagValidatorPlugin.add_config(config)
    Config.init_default_config()
    assert Config.plugin_tagvalidator.enabled is False
    assert Config.plugin_tagvalidator.dry_run is False
    assert Config.plugin_tagvalidator.validate(
        Config.plugin_tagvalidator) is True
Exemplo n.º 6
0
def test_config():
    config = Config("dummy", "dummy")
    SlackCollectorPlugin.add_config(config)
    SlackBotPlugin.add_config(config)
    Config.init_default_config()
    assert Config.slack.bot_token is None
    assert Config.slack.include_archived is False
    assert Config.slack.do_not_verify_ssl is False
Exemplo n.º 7
0
def test_config():
    config = Config("dummy", "dummy")
    VSphereCollectorPlugin.add_config(config)
    Config.init_default_config()
    assert Config.vsphere.user is None
    assert Config.vsphere.password is None
    assert Config.vsphere.host is None
    assert Config.vsphere.port == 443
    assert Config.vsphere.insecure is True
Exemplo n.º 8
0
def test_args():
    config = Config("dummy", "dummy")
    GCPCollectorPlugin.add_config(config)
    Config.init_default_config()
    assert len(Config.gcp.service_account) == 0
    assert len(Config.gcp.project) == 0
    assert len(Config.gcp.collect) == 0
    assert len(Config.gcp.no_collect) == 0
    assert Config.gcp.project_pool_size == num_default_threads()
    assert Config.gcp.fork_process is True
Exemplo n.º 9
0
def test_config():
    config = Config("dummy", "dummy")
    OnpremCollectorPlugin.add_config(config)
    config.init_default_config()
    assert Config.onprem.location == "Default location"
    assert Config.onprem.region == "Default region"
    assert Config.onprem.ssh_user == "root"
    assert Config.onprem.ssh_key is None
    assert len(Config.onprem.server) == 0
    assert Config.onprem.pool_size == 5
    assert Config.onprem.fork_process is True
Exemplo n.º 10
0
def test_config():
    config = Config("dummy", "dummy")
    KubernetesCollectorPlugin.add_config(config)
    config.init_default_config()
    assert len(Config.k8s.context) == 0
    assert Config.k8s.config is None
    assert len(Config.k8s.cluster) == 0
    assert len(Config.k8s.apiserver) == 0
    assert len(Config.k8s.token) == 0
    assert len(Config.k8s.cacert) == 0
    assert len(Config.k8s.collect) == 0
    assert len(Config.k8s.no_collect) == 0
    assert Config.k8s.pool_size == num_default_threads()
    assert Config.k8s.fork_process is False
    assert Config.k8s.all_contexts is False
Exemplo n.º 11
0
def test_config_override():
    arg_parser = get_arg_parser()
    core_add_args(arg_parser)
    arg_parser.parse_known_args()
    cfg = Config("test")
    cfg.add_config(ConfigTest)
    cfg.init_default_config()
    assert Config.dict() == {
        "configtest": {
            "testvar1": "testing123",
            "testvar2": 12346,
            "testvar3": {
                "mydict": {
                    "foo": "bar",
                    "abc": {
                        "def": "ghi"
                    }
                },
                "myint": 0,
                "mystr": "Hello",
            },
        }
    }
    ArgumentParser.args.config_override = [
        "configtest.testvar1=testing124",
        "configtest.testvar3.myint=1",
        "configtest.testvar3.mystr=World",
        "configtest.testvar3.mydict.foo=baz",
        "configtest.testvar3.mydict.abc.def=jkl",
    ]
    cfg.override_config(cfg.running_config)
    assert Config.dict() == {
        "configtest": {
            "testvar1": "testing124",
            "testvar2": 12346,
            "testvar3": {
                "mydict": {
                    "foo": "baz",
                    "abc": {
                        "def": "jkl"
                    }
                },
                "myint": 1,
                "mystr": "World",
            },
        }
    }
Exemplo n.º 12
0
def test_args():
    config = Config("dummy", "dummy")
    AWSCollectorPlugin.add_config(config)
    Config.init_default_config()
    assert Config.aws.access_key_id is None
    assert Config.aws.secret_access_key is None
    assert Config.aws.role is None
    assert Config.aws.role_override is False
    assert Config.aws.account is None
    assert Config.aws.region is None
    assert Config.aws.scrape_org is False
    assert Config.aws.fork_process is True
    assert Config.aws.scrape_exclude_account == []
    assert Config.aws.assume_current is False
    assert Config.aws.do_not_scrape_current is False
    assert Config.aws.account_pool_size == num_default_threads()
    assert Config.aws.region_pool_size == 20
    assert Config.aws.parallel_api_requests == 10
    assert len(Config.aws.collect) == 0
    assert len(Config.aws.no_collect) == 0
Exemplo n.º 13
0
def test_config() -> None:
    config = Config("dummy", "dummy")
    DigitalOceanCollectorPlugin.add_config(config)
    Config.init_default_config()
    assert len(Config.digitalocean.api_tokens) == 0
    assert len(Config.digitalocean.spaces_access_keys) == 0
Exemplo n.º 14
0
def test_config():
    config = Config("dummy", "dummy")
    ProtectorPlugin.add_config(config)
    Config.init_default_config()
    assert Config.plugin_protector.enabled is False
    assert Config.plugin_protector.validate(Config.plugin_protector) is True
Exemplo n.º 15
0
def test_config():
    config = Config("dummy", "dummy")
    CleanupExpiredPlugin.add_config(config)
    Config.init_default_config()
    assert Config.plugin_cleanup_expired.enabled is False
Exemplo n.º 16
0
def test_config():
    config = Config("dummy", "dummy")
    GithubCollectorPlugin.add_config(config)
    config.init_default_config()
    assert Config.github.access_token is None
Exemplo n.º 17
0
def test_config():
    config = Config("dummy", "dummy")
    CleanupAWSLoadbalancersPlugin.add_config(config)
    Config.init_default_config()
    assert Config.plugin_cleanup_aws_loadbalancers.enabled is False
    assert Config.plugin_cleanup_aws_loadbalancers.min_age == "7 days"
Exemplo n.º 18
0
def test_config():
    config = Config("dummy", "dummy")
    CleanupVolumesPlugin.add_config(config)
    Config.init_default_config()
    assert Config.plugin_cleanup_volumes.enabled is False
    assert Config.plugin_cleanup_volumes.min_age == "14 days"