flyshell 1.5.1__tar.gz → 1.5.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. {flyshell-1.5.1/src/flyshell.egg-info → flyshell-1.5.3}/PKG-INFO +6 -5
  2. {flyshell-1.5.1 → flyshell-1.5.3}/README.md +5 -4
  3. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/abstract/base_plugin.py +17 -1
  4. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/constants.py +3 -3
  5. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/core/data.py +11 -0
  6. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/core/directory.py +8 -2
  7. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/startup/env.py +20 -6
  8. {flyshell-1.5.1 → flyshell-1.5.3/src/flyshell.egg-info}/PKG-INFO +6 -5
  9. {flyshell-1.5.1 → flyshell-1.5.3}/tests/test_env.py +70 -0
  10. {flyshell-1.5.1 → flyshell-1.5.3}/LICENSE +0 -0
  11. {flyshell-1.5.1 → flyshell-1.5.3}/MANIFEST.in +0 -0
  12. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/diskops.c +0 -0
  13. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/posix/cat.c +0 -0
  14. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/posix/cp.c +0 -0
  15. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/posix/dir.c +0 -0
  16. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/posix/mkdir.c +0 -0
  17. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/posix/mv.c +0 -0
  18. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/posix/rename.c +0 -0
  19. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/posix/rm.c +0 -0
  20. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/posix/rmdir.c +0 -0
  21. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/posix/touch.c +0 -0
  22. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/shared/dir_types.c +0 -0
  23. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/shared/dir_types.h +0 -0
  24. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/shared/native_errors.h +0 -0
  25. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/shared/win32_utf.h +0 -0
  26. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/win32/cat.c +0 -0
  27. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/win32/cp.c +0 -0
  28. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/win32/dir.c +0 -0
  29. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/win32/mkdir.c +0 -0
  30. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/win32/mv.c +0 -0
  31. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/win32/rename.c +0 -0
  32. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/win32/rm.c +0 -0
  33. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/win32/rmdir.c +0 -0
  34. {flyshell-1.5.1 → flyshell-1.5.3}/c_src/diskops/win32/touch.c +0 -0
  35. {flyshell-1.5.1 → flyshell-1.5.3}/pyproject.toml +0 -0
  36. {flyshell-1.5.1 → flyshell-1.5.3}/setup.cfg +0 -0
  37. {flyshell-1.5.1 → flyshell-1.5.3}/setup.py +0 -0
  38. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/__init__.py +0 -0
  39. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/abstract/__init__.py +0 -0
  40. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/abstract/base_cmd.py +0 -0
  41. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/abstract/parent_cmd.py +0 -0
  42. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/accounts/__init__.py +0 -0
  43. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/accounts/auth.py +0 -0
  44. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/bin/__init__.py +0 -0
  45. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/builtin/__init__.py +0 -0
  46. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/builtin/fs.py +0 -0
  47. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/builtin/pkg.py +0 -0
  48. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/builtin/system.py +0 -0
  49. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/builtin/utils.py +0 -0
  50. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/core/__init__.py +0 -0
  51. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/core/console.py +0 -0
  52. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/main.py +0 -0
  53. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/native/__init__.py +0 -0
  54. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/native/diskops_bridge.py +0 -0
  55. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/native/diskops_handler.py +0 -0
  56. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/native/legacy/__init__.py +0 -0
  57. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/native/legacy/diskops.py +0 -0
  58. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/startup/__init__.py +0 -0
  59. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/startup/deps.py +0 -0
  60. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell/startup/loader.py +0 -0
  61. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell.egg-info/SOURCES.txt +0 -0
  62. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell.egg-info/dependency_links.txt +0 -0
  63. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell.egg-info/entry_points.txt +0 -0
  64. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell.egg-info/requires.txt +0 -0
  65. {flyshell-1.5.1 → flyshell-1.5.3}/src/flyshell.egg-info/top_level.txt +0 -0
  66. {flyshell-1.5.1 → flyshell-1.5.3}/tests/test_auth.py +0 -0
  67. {flyshell-1.5.1 → flyshell-1.5.3}/tests/test_data.py +0 -0
  68. {flyshell-1.5.1 → flyshell-1.5.3}/tests/test_deps.py +0 -0
  69. {flyshell-1.5.1 → flyshell-1.5.3}/tests/test_directory.py +0 -0
  70. {flyshell-1.5.1 → flyshell-1.5.3}/tests/test_diskops_ext.py +0 -0
  71. {flyshell-1.5.1 → flyshell-1.5.3}/tests/test_diskops_lgc.py +0 -0
  72. {flyshell-1.5.1 → flyshell-1.5.3}/tests/test_fs.py +0 -0
  73. {flyshell-1.5.1 → flyshell-1.5.3}/tests/test_loader.py +0 -0
  74. {flyshell-1.5.1 → flyshell-1.5.3}/tests/test_pkg.py +0 -0
  75. {flyshell-1.5.1 → flyshell-1.5.3}/tests/test_security.py +0 -0
  76. {flyshell-1.5.1 → flyshell-1.5.3}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flyshell
3
- Version: 1.5.1
3
+ Version: 1.5.3
4
4
  Summary: A modular, zero-dependency command-line environment in Python.
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.10
@@ -23,7 +23,7 @@ Dynamic: license-file
23
23
  ![Dependencies](https://img.shields.io/badge/dependencies-zero-brightgreen.svg)
24
24
  ![Tests](https://github.com/kianodev/flyshell/actions/workflows/ci.yml/badge.svg)
25
25
 
26
- > Documentation last updated: v1.5.1
26
+ > Documentation last updated: v1.5.3
27
27
 
28
28
  A modular, zero-dependency command-line environment and extensible runtime interface built in Python with compiled C-extensions.
29
29
 
@@ -208,9 +208,10 @@ Additional functions are available for you to use:
208
208
 
209
209
  1. `get_data(key, default=None)`: Retrieves a value from local plugin memory.
210
210
  2. `set_data(key, value)`: Updates a key in local memory and automatically persists it to SQLite via `save_storage()`.
211
- 3. `load_storage()`: Reloads fresh key-value pairs directly from SQLite into `self.storage`.
212
- 4. `save_storage()`: Writes all in-memory key-value pairs in `self.storage` back to SQLite.
213
- 5. `get_api_key(key, default=None)`: Fetches the specified API key from `flyshell_keys.env`.
211
+ 3. `delete_data(key)`: Deletes the specified key and automatically persists it to SQLite, returning **True** if found and **False** if not found.
212
+ 4. `load_storage()`: Reloads fresh key-value pairs directly from SQLite into `self.storage`.
213
+ 5. `save_storage()`: Writes all in-memory key-value pairs in `self.storage` back to SQLite.
214
+ 6. `get_api_key(key, default=None)`: Fetches the specified API key from `flyshell_keys.env`.
214
215
 
215
216
  Plugins save automatically on shut-down.
216
217
 
@@ -6,7 +6,7 @@
6
6
  ![Dependencies](https://img.shields.io/badge/dependencies-zero-brightgreen.svg)
7
7
  ![Tests](https://github.com/kianodev/flyshell/actions/workflows/ci.yml/badge.svg)
8
8
 
9
- > Documentation last updated: v1.5.1
9
+ > Documentation last updated: v1.5.3
10
10
 
11
11
  A modular, zero-dependency command-line environment and extensible runtime interface built in Python with compiled C-extensions.
12
12
 
@@ -191,9 +191,10 @@ Additional functions are available for you to use:
191
191
 
192
192
  1. `get_data(key, default=None)`: Retrieves a value from local plugin memory.
193
193
  2. `set_data(key, value)`: Updates a key in local memory and automatically persists it to SQLite via `save_storage()`.
194
- 3. `load_storage()`: Reloads fresh key-value pairs directly from SQLite into `self.storage`.
195
- 4. `save_storage()`: Writes all in-memory key-value pairs in `self.storage` back to SQLite.
196
- 5. `get_api_key(key, default=None)`: Fetches the specified API key from `flyshell_keys.env`.
194
+ 3. `delete_data(key)`: Deletes the specified key and automatically persists it to SQLite, returning **True** if found and **False** if not found.
195
+ 4. `load_storage()`: Reloads fresh key-value pairs directly from SQLite into `self.storage`.
196
+ 5. `save_storage()`: Writes all in-memory key-value pairs in `self.storage` back to SQLite.
197
+ 6. `get_api_key(key, default=None)`: Fetches the specified API key from `flyshell_keys.env`.
197
198
 
198
199
  Plugins save automatically on shut-down.
199
200
 
@@ -25,7 +25,13 @@ class BasePlugin:
25
25
  self.on_load()
26
26
 
27
27
  def get_api_key(self, key_name: str, default=None):
28
- return self.api_keys_data.get(key_name, default)
28
+ if key_name in self.api_keys_data:
29
+ return self.api_keys_data[key_name]
30
+ target = key_name.lower()
31
+ for k, v in self.api_keys_data.items():
32
+ if k.lower() == target:
33
+ return v
34
+ return default
29
35
 
30
36
  def on_load(self):
31
37
  pass
@@ -77,6 +83,13 @@ class BasePlugin:
77
83
  self.storage[key] = value
78
84
  self.save_storage()
79
85
 
86
+ def delete_data(self, key: str) -> bool:
87
+ if key in self.storage:
88
+ del self.storage[key]
89
+ self.save_storage()
90
+ return True
91
+ return False
92
+
80
93
  def load_storage(self) -> dict:
81
94
  fresh_data = data.get_all_plugin_data(self.plugin_name)
82
95
  self.storage = fresh_data
@@ -84,6 +97,9 @@ class BasePlugin:
84
97
  return self.storage
85
98
 
86
99
  def save_storage(self):
100
+ existing_keys = set(data.get_all_plugin_data(self.plugin_name).keys())
101
+ for stale_key in existing_keys - set(self.storage.keys()):
102
+ data.delete_plugin_data(self.plugin_name, stale_key)
87
103
  for k, v in self.storage.items():
88
104
  data.set_plugin_data(self.plugin_name, k, v)
89
105
  self.context["storage"] = self.storage
@@ -5,9 +5,9 @@ import os
5
5
  import platform
6
6
  import time
7
7
 
8
- BUILD = 169
9
- VERFULL = "1.5.1c"
10
- VERSION = "1.5.1"
8
+ BUILD = 177
9
+ VERFULL = "1.5.3d"
10
+ VERSION = "1.5.3"
11
11
 
12
12
 
13
13
  def _resolve_app_dir() -> Path:
@@ -262,3 +262,14 @@ def purge_all_plugin_data(filename=c.FILE_PATH) -> bool:
262
262
  conn.execute("DELETE FROM plugin_kv")
263
263
  conn.execute("DELETE FROM plugins")
264
264
  return True
265
+
266
+
267
+ def delete_plugin_data(plugin_name: str, key: str, filename=c.FILE_PATH) -> bool:
268
+ initialise(filename)
269
+ with _get_connection(filename) as conn:
270
+ with conn:
271
+ cursor = conn.execute(
272
+ "DELETE FROM plugin_kv WHERE plugin_name = ? AND key = ?",
273
+ (plugin_name, key),
274
+ )
275
+ return cursor.rowcount > 0
@@ -10,6 +10,7 @@ from flyshell.native import diskops_handler as diskops
10
10
  from flyshell.startup import deps
11
11
 
12
12
  from datetime import datetime, timezone
13
+ import copy
13
14
  import shlex
14
15
  import sys
15
16
 
@@ -166,7 +167,8 @@ def _execute_single(raw_cmd: str) -> int:
166
167
  plugin = c.PLUGINS[cmd_name]
167
168
  required_keys = getattr(plugin, "api_keys", [])
168
169
  available_keys = getattr(plugin, "api_keys_data", {})
169
- missing = [k for k in required_keys if k not in available_keys]
170
+ available_lower = {k.lower() for k in available_keys}
171
+ missing = [k for k in required_keys if k.lower() not in available_lower]
170
172
  if missing:
171
173
  env_path = getattr(plugin, "env_file_path", "flyshell_keys.env")
172
174
  print(
@@ -181,6 +183,7 @@ def _execute_single(raw_cmd: str) -> int:
181
183
  )
182
184
  print(f"Please run 'sys pip install {' '.join(missing_deps)}'\n")
183
185
  return 1
186
+ storage_before = copy.deepcopy(getattr(plugin, "storage", {}))
184
187
  try:
185
188
  result = plugin.execute(args)
186
189
  return result if isinstance(result, int) else 0
@@ -197,7 +200,10 @@ def _execute_single(raw_cmd: str) -> int:
197
200
  finally:
198
201
  if hasattr(plugin, "on_unload"):
199
202
  plugin.on_unload()
200
- if hasattr(plugin, "save_storage"):
203
+ if (
204
+ hasattr(plugin, "save_storage")
205
+ and getattr(plugin, "storage", {}) != storage_before
206
+ ):
201
207
  plugin.save_storage()
202
208
  else:
203
209
  print(
@@ -31,8 +31,8 @@ def read_env_file() -> dict[str, str]:
31
31
  if not line or line.startswith("#") or "=" not in line:
32
32
  continue
33
33
  raw_k, raw_v = line.split("=", 1)
34
- clean_k = raw_k.strip().replace("[", "").replace("]", "")
35
- clean_v = raw_v.strip().strip("\"'").replace("[", "").replace("]", "")
34
+ clean_k = raw_k.strip()
35
+ clean_v = raw_v.strip().strip("\"'")
36
36
  if clean_k:
37
37
  entries[clean_k] = clean_v
38
38
  return entries
@@ -72,11 +72,23 @@ def get_plugin_api_keys(plugin_name_or_dir: str) -> dict[str, str]:
72
72
  f"{dir_name.lower()}_",
73
73
  f"{plugin_name_or_dir.strip().lower()}_",
74
74
  }
75
+ other_prefixes = set()
76
+ if hasattr(c, "PLUGINS"):
77
+ for cmd_name, plugin in c.PLUGINS.items():
78
+ other_dir = str(plugin.context.get("plugin_dir_name") or cmd_name).lower()
79
+ for candidate in (f"{other_dir}_", f"{cmd_name.lower()}_"):
80
+ if candidate not in prefixes:
81
+ other_prefixes.add(candidate)
75
82
  plugin_keys = {}
76
83
  for raw_k, val in all_env.items():
77
84
  k_lower = raw_k.lower()
78
85
  for prefix in prefixes:
79
86
  if k_lower.startswith(prefix):
87
+ if any(
88
+ len(other) > len(prefix) and k_lower.startswith(other)
89
+ for other in other_prefixes
90
+ ):
91
+ break
80
92
  key_name = raw_k[len(prefix) :]
81
93
  plugin_keys[key_name] = val
82
94
  break
@@ -130,7 +142,8 @@ def get_plugin_keys_formatted(target_name: str) -> tuple[int, str]:
130
142
  def set_plugin_api_key(plugin_name: str, key_name: str, value: str) -> tuple[int, str]:
131
143
  if not plugin_name or not key_name:
132
144
  return (1, "Command Error: Both plugin name and key name are required.")
133
- target_key = f"{plugin_name.strip().lower()}_{key_name.strip().upper()}"
145
+ dir_name, _ = _resolve_plugin_dir_name(plugin_name)
146
+ target_key = f"{dir_name.strip().lower()}_{key_name.strip().upper()}"
134
147
  clean_val = value.strip().strip("\"'")
135
148
  env_path = get_env_path()
136
149
  try:
@@ -163,7 +176,8 @@ def set_plugin_api_key(plugin_name: str, key_name: str, value: str) -> tuple[int
163
176
  def remove_plugin_api_key(plugin_name: str, key_name: str) -> tuple[int, str]:
164
177
  if not plugin_name or not key_name:
165
178
  return (1, "Command Error: Both plugin name and key name are required.")
166
- target_key = f"{plugin_name.strip().lower()}_{key_name.strip().lower()}"
179
+ dir_name, _ = _resolve_plugin_dir_name(plugin_name)
180
+ target_key = f"{dir_name.strip().lower()}_{key_name.strip().upper()}"
167
181
  env_path = get_env_path()
168
182
  if not env_path.exists():
169
183
  return (
@@ -178,8 +192,8 @@ def remove_plugin_api_key(plugin_name: str, key_name: str) -> tuple[int, str]:
178
192
  stripped = line.strip()
179
193
  if stripped and not stripped.startswith("#") and "=" in stripped:
180
194
  k, _ = stripped.split("=", 1)
181
- clean_k = k.strip().replace("[", "").replace("]", "").lower()
182
- if clean_k == target_key:
195
+ clean_k = k.strip().lower()
196
+ if clean_k == target_key.lower():
183
197
  found = True
184
198
  continue
185
199
  new_lines.append(line)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flyshell
3
- Version: 1.5.1
3
+ Version: 1.5.3
4
4
  Summary: A modular, zero-dependency command-line environment in Python.
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.10
@@ -23,7 +23,7 @@ Dynamic: license-file
23
23
  ![Dependencies](https://img.shields.io/badge/dependencies-zero-brightgreen.svg)
24
24
  ![Tests](https://github.com/kianodev/flyshell/actions/workflows/ci.yml/badge.svg)
25
25
 
26
- > Documentation last updated: v1.5.1
26
+ > Documentation last updated: v1.5.3
27
27
 
28
28
  A modular, zero-dependency command-line environment and extensible runtime interface built in Python with compiled C-extensions.
29
29
 
@@ -208,9 +208,10 @@ Additional functions are available for you to use:
208
208
 
209
209
  1. `get_data(key, default=None)`: Retrieves a value from local plugin memory.
210
210
  2. `set_data(key, value)`: Updates a key in local memory and automatically persists it to SQLite via `save_storage()`.
211
- 3. `load_storage()`: Reloads fresh key-value pairs directly from SQLite into `self.storage`.
212
- 4. `save_storage()`: Writes all in-memory key-value pairs in `self.storage` back to SQLite.
213
- 5. `get_api_key(key, default=None)`: Fetches the specified API key from `flyshell_keys.env`.
211
+ 3. `delete_data(key)`: Deletes the specified key and automatically persists it to SQLite, returning **True** if found and **False** if not found.
212
+ 4. `load_storage()`: Reloads fresh key-value pairs directly from SQLite into `self.storage`.
213
+ 5. `save_storage()`: Writes all in-memory key-value pairs in `self.storage` back to SQLite.
214
+ 6. `get_api_key(key, default=None)`: Fetches the specified API key from `flyshell_keys.env`.
214
215
 
215
216
  Plugins save automatically on shut-down.
216
217
 
@@ -148,3 +148,73 @@ def test_get_plugin_keys_formatted_invalid_input():
148
148
  code, output = env.get_plugin_keys_formatted("")
149
149
  assert code == 1
150
150
  assert "valid plugin name" in output
151
+
152
+
153
+ def test_env_preserves_square_brackets_in_values(mock_env_file):
154
+ mock_env_file.write_text('sample_token="abc[123]xyz"\n')
155
+ keys = env.get_plugin_api_keys("sample")
156
+ assert keys == {"token": "abc[123]xyz"}
157
+
158
+
159
+ def test_set_and_remove_key_resolves_plugin_identifier(mock_env_file, monkeypatch):
160
+ class AliasedPlugin(BasePlugin):
161
+ name = "Weather Tool"
162
+ identifier = "weather"
163
+
164
+ def execute(self, args):
165
+ return 0
166
+
167
+ ctx = {
168
+ "plugin_name": "weather",
169
+ "plugin_dir_name": "weather_folder",
170
+ "file_path": None,
171
+ "env_path": str(mock_env_file),
172
+ "api_keys": {},
173
+ }
174
+ monkeypatch.setitem(c.PLUGINS, "weather", AliasedPlugin(ctx))
175
+ code, _ = env.set_plugin_api_key("weather", "api_key", "secret123")
176
+ assert code == 0
177
+ assert "weather_folder_API_KEY=secret123" in mock_env_file.read_text(
178
+ encoding="utf-8"
179
+ )
180
+ code, _ = env.remove_plugin_api_key("weather", "api_key")
181
+ assert code == 0
182
+ assert "weather_folder_API_KEY" not in mock_env_file.read_text(encoding="utf-8")
183
+
184
+
185
+ def test_case_insensitive_api_key_lookup_and_execution(mock_env_file, monkeypatch):
186
+ class CasePlugin(BasePlugin):
187
+ api_keys = ["API_TOKEN"]
188
+
189
+ def execute(self, args):
190
+ assert self.get_api_key("API_TOKEN") == "secret_123"
191
+ assert self.get_api_key("api_token") == "secret_123"
192
+ return 0
193
+
194
+ ctx = {
195
+ "plugin_name": "caseplug",
196
+ "plugin_dir_name": "caseplug",
197
+ "file_path": None,
198
+ "env_path": str(mock_env_file),
199
+ "api_keys": {"api_token": "secret_123"},
200
+ }
201
+ instance = CasePlugin(ctx)
202
+ monkeypatch.setitem(c.PLUGINS, "caseplug", instance)
203
+ assert directory._execute_single("caseplug") == 0
204
+
205
+
206
+ def test_get_plugin_api_keys_avoids_prefix_collision(mock_env_file, monkeypatch):
207
+ mock_env_file.write_text(
208
+ "weather_api_key=base_secret\n" "weather_pro_api_key=pro_secret\n"
209
+ )
210
+
211
+ class DummyPlugin(BasePlugin):
212
+ def execute(self, args):
213
+ return 0
214
+
215
+ p1 = DummyPlugin({"plugin_name": "weather", "plugin_dir_name": "weather"})
216
+ p2 = DummyPlugin({"plugin_name": "weather_pro", "plugin_dir_name": "weather_pro"})
217
+ monkeypatch.setitem(c.PLUGINS, "weather", p1)
218
+ monkeypatch.setitem(c.PLUGINS, "weather_pro", p2)
219
+ assert env.get_plugin_api_keys("weather") == {"api_key": "base_secret"}
220
+ assert env.get_plugin_api_keys("weather_pro") == {"api_key": "pro_secret"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes