From 46fd321d06383f7ba9a84b95e689537857d7d218 Mon Sep 17 00:00:00 2001 From: nmemmert <67961292+nmemmert@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:54:03 -0500 Subject: [PATCH] test auth --- test_oauth_config.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/test_oauth_config.py b/test_oauth_config.py index 5e00753..b77e8c6 100644 --- a/test_oauth_config.py +++ b/test_oauth_config.py @@ -13,14 +13,25 @@ def get_systemd_env_var(var_name): """Get environment variable from systemd service""" try: result = subprocess.run( - ['systemctl', 'show', 'pdf-renamer', '-p', f'Environment'], + ['systemctl', 'show', 'pdf-renamer', '-p', 'Environment'], capture_output=True, text=True, check=True ) - env_lines = result.stdout.strip().split('\n') - for line in env_lines: - if f'{var_name}=' in line: - # Extract the value after the equals sign - return line.split('=', 1)[1].strip('"') + env_line = result.stdout.strip() + if not env_line or '=' not in env_line: + return None + + # The Environment line contains: Environment=VAR1=value1 VAR2=value2 ... + # Extract everything after the first '=' + env_string = env_line.split('=', 1)[1] + + # Split by spaces to get individual VAR=value pairs + env_pairs = env_string.split() + + # Find the specific variable + for pair in env_pairs: + if pair.startswith(f'{var_name}='): + return pair.split('=', 1)[1] + return None except subprocess.CalledProcessError: return None