mirror of
https://github.com/msoedov/agentic_security.git
synced 2026-06-23 21:59:57 +02:00
refactor(generate_default_settings):
This commit is contained in:
@@ -128,7 +128,7 @@ Init config
|
||||
```shell
|
||||
agentic_security init
|
||||
|
||||
2025-01-08 20:12:02.449 | INFO | agentic_security.lib:generate_default_cfg:324 - Default configuration generated successfully to agesec.toml.
|
||||
2025-01-08 20:12:02.449 | INFO | agentic_security.lib:generate_default_settings:324 - Default configuration generated successfully to agesec.toml.
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class CLI:
|
||||
Generate the default CI configuration file.
|
||||
"""
|
||||
sys.path.append(os.path.dirname("."))
|
||||
AgenticSecurity().generate_default_cfg(host, port)
|
||||
AgenticSecurity().generate_default_settings(host, port)
|
||||
|
||||
i = init
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class SettingsMixin:
|
||||
|
||||
def get_or_create_config(self) -> bool:
|
||||
if not self.has_local_config():
|
||||
self.generate_default_cfg()
|
||||
self.generate_default_settings()
|
||||
return False
|
||||
self.load_config(self.default_path)
|
||||
settings_version = self.get_config_value("general.version")
|
||||
@@ -86,7 +86,7 @@ class SettingsMixin:
|
||||
return default
|
||||
return value
|
||||
|
||||
def generate_default_cfg(self, host: str = "0.0.0.0", port: int = 8718):
|
||||
def generate_default_settings(self, host: str = "0.0.0.0", port: int = 8718):
|
||||
# Accept host / port as parameters
|
||||
with open(self.default_path, "w") as f:
|
||||
f.write(
|
||||
|
||||
@@ -157,7 +157,7 @@ class TestLibraryLevel:
|
||||
class TestEntrypointCI:
|
||||
def test_generate_default_cfg_to_tmp_path(self):
|
||||
"""
|
||||
Test that the `generate_default_cfg` method generates a valid default config file in a temporary path.
|
||||
Test that the `generate_default_settings` method generates a valid default config file in a temporary path.
|
||||
"""
|
||||
# Create a temporary directory
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
@@ -168,7 +168,7 @@ class TestEntrypointCI:
|
||||
|
||||
# Generate the default configuration
|
||||
security = AgenticSecurity()
|
||||
security.generate_default_cfg()
|
||||
security.generate_default_settings()
|
||||
|
||||
# Check that the config file was created at the temporary path
|
||||
assert os.path.exists(temp_path), f"{temp_path} file should be generated."
|
||||
@@ -193,7 +193,7 @@ class TestEntrypointCI:
|
||||
|
||||
# Generate the default configuration
|
||||
security = AgenticSecurity()
|
||||
security.generate_default_cfg()
|
||||
security.generate_default_settings()
|
||||
|
||||
# Load the generated configuration
|
||||
AgenticSecurity.load_config(temp_path)
|
||||
|
||||
Reference in New Issue
Block a user