forked from clan/clan-core
Working test_secrets_generate
This commit is contained in:
parent
16b043f508
commit
f7c6ab5888
@ -12,7 +12,7 @@
|
|||||||
]}"
|
]}"
|
||||||
ROOT=$(git rev-parse --show-toplevel)
|
ROOT=$(git rev-parse --show-toplevel)
|
||||||
cd "$ROOT/pkgs/clan-cli"
|
cd "$ROOT/pkgs/clan-cli"
|
||||||
nix develop "$ROOT#clan-cli" -c bash -c "TMPDIR=/tmp python -m pytest -m impure ./tests $@"
|
nix develop "$ROOT#clan-cli" -c bash -c "TMPDIR=/tmp python -m pytest -s -m impure ./tests $@"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,7 @@ def main() -> None:
|
|||||||
if args.debug:
|
if args.debug:
|
||||||
setup_logging(logging.DEBUG)
|
setup_logging(logging.DEBUG)
|
||||||
log.debug("Debug log activated")
|
log.debug("Debug log activated")
|
||||||
|
setup_logging(logging.INFO)
|
||||||
|
|
||||||
if not hasattr(args, "func"):
|
if not hasattr(args, "func"):
|
||||||
return
|
return
|
||||||
|
@ -8,9 +8,10 @@ from enum import Enum
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import IO, Any
|
from typing import IO, Any
|
||||||
|
|
||||||
|
from .custom_logger import get_caller
|
||||||
from .errors import ClanCmdError, CmdOut
|
from .errors import ClanCmdError, CmdOut
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
glog = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Log(Enum):
|
class Log(Enum):
|
||||||
@ -59,6 +60,7 @@ def run(
|
|||||||
check: bool = True,
|
check: bool = True,
|
||||||
error_msg: str | None = None,
|
error_msg: str | None = None,
|
||||||
) -> CmdOut:
|
) -> CmdOut:
|
||||||
|
glog.debug(f"running command: {shlex.join(cmd)}. Caller: {get_caller()}")
|
||||||
# Start the subprocess
|
# Start the subprocess
|
||||||
process = subprocess.Popen(
|
process = subprocess.Popen(
|
||||||
cmd,
|
cmd,
|
||||||
|
@ -63,11 +63,18 @@ def get_caller() -> str:
|
|||||||
|
|
||||||
|
|
||||||
def setup_logging(level: Any) -> None:
|
def setup_logging(level: Any) -> None:
|
||||||
handler = logging.StreamHandler()
|
# Get the root logger and set its level
|
||||||
handler.setLevel(level)
|
root_logger = logging.getLogger()
|
||||||
handler.setFormatter(CustomFormatter())
|
root_logger.setLevel(level)
|
||||||
logger = logging.getLogger("registerHandler")
|
|
||||||
|
# Create and add the default handler
|
||||||
|
default_handler = logging.StreamHandler()
|
||||||
|
|
||||||
|
# Create and add your custom handler
|
||||||
|
default_handler.setLevel(level)
|
||||||
|
default_handler.setFormatter(CustomFormatter())
|
||||||
|
root_logger.addHandler(default_handler)
|
||||||
|
|
||||||
|
# Set logging level for other modules used by this module
|
||||||
logging.getLogger("asyncio").setLevel(logging.INFO)
|
logging.getLogger("asyncio").setLevel(logging.INFO)
|
||||||
logging.getLogger("httpx").setLevel(level=logging.WARNING)
|
logging.getLogger("httpx").setLevel(level=logging.WARNING)
|
||||||
logger.addHandler(handler)
|
|
||||||
# logging.basicConfig(level=level, handlers=[handler])
|
|
||||||
|
@ -33,7 +33,8 @@ def test_generate_secret(
|
|||||||
age_keys[0].pubkey,
|
age_keys[0].pubkey,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
cli.run(["--flake", str(test_flake_with_core.path), "secrets", "generate", "vm1"])
|
cmd = ["--flake", str(test_flake_with_core.path), "secrets", "generate", "vm1"]
|
||||||
|
cli.run(cmd)
|
||||||
has_secret(test_flake_with_core.path, "vm1-age.key")
|
has_secret(test_flake_with_core.path, "vm1-age.key")
|
||||||
has_secret(test_flake_with_core.path, "vm1-zerotier-identity-secret")
|
has_secret(test_flake_with_core.path, "vm1-zerotier-identity-secret")
|
||||||
has_secret(test_flake_with_core.path, "vm1-zerotier-subnet")
|
has_secret(test_flake_with_core.path, "vm1-zerotier-subnet")
|
||||||
|
Loading…
Reference in New Issue
Block a user