roksta 0.2.7__cp312-cp312-macosx_10_13_universal2.whl → 0.3.2__cp312-cp312-macosx_10_13_universal2.whl

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.

Potentially problematic release.


This version of roksta might be problematic. Click here for more details.

Files changed (91) hide show
  1. roksta/ai/call_ai.cpython-312-darwin.so +0 -0
  2. roksta/ai/gemini.cpython-312-darwin.so +0 -0
  3. roksta/ai/generic.cpython-312-darwin.so +0 -0
  4. roksta/ai/llm.cpython-312-darwin.so +0 -0
  5. roksta/ai/openai.cpython-312-darwin.so +0 -0
  6. roksta/ai/tools/__init__.cpython-312-darwin.so +0 -0
  7. roksta/ai/tools/delete_file.cpython-312-darwin.so +0 -0
  8. roksta/ai/tools/edit_file.cpython-312-darwin.so +0 -0
  9. roksta/ai/tools/final_response.cpython-312-darwin.so +0 -0
  10. roksta/ai/tools/get_file_summaries.cpython-312-darwin.so +0 -0
  11. roksta/ai/tools/read_file.cpython-312-darwin.so +0 -0
  12. roksta/ai/tools/regex_replace.cpython-312-darwin.so +0 -0
  13. roksta/ai/tools/shell_any.cpython-312-darwin.so +0 -0
  14. roksta/ai/tools/shell_limited.cpython-312-darwin.so +0 -0
  15. roksta/ai/tools/tool_defs.cpython-312-darwin.so +0 -0
  16. roksta/ai/tools/tool_utils.cpython-312-darwin.so +0 -0
  17. roksta/ai/tools/write_file.cpython-312-darwin.so +0 -0
  18. roksta/balance.cpython-312-darwin.so +0 -0
  19. roksta/check_for_updates.cpython-312-darwin.so +0 -0
  20. roksta/clarify_goal.cpython-312-darwin.so +0 -0
  21. roksta/command_handlers/__init__.cpython-312-darwin.so +0 -0
  22. roksta/command_handlers/handle_activate_command.cpython-312-darwin.so +0 -0
  23. roksta/command_handlers/handle_add_funds_command.cpython-312-darwin.so +0 -0
  24. roksta/command_handlers/handle_auto_charge_command.cpython-312-darwin.so +0 -0
  25. roksta/command_handlers/handle_auto_commit_command.cpython-312-darwin.so +0 -0
  26. roksta/command_handlers/handle_building_command.cpython-312-darwin.so +0 -0
  27. roksta/command_handlers/handle_chat_command.cpython-312-darwin.so +0 -0
  28. roksta/command_handlers/handle_dev_rate_command.cpython-312-darwin.so +0 -0
  29. roksta/command_handlers/handle_feedback_command.cpython-312-darwin.so +0 -0
  30. roksta/command_handlers/handle_goal_command.cpython-312-darwin.so +0 -0
  31. roksta/command_handlers/handle_help_command.cpython-312-darwin.so +0 -0
  32. roksta/command_handlers/handle_init_command.cpython-312-darwin.so +0 -0
  33. roksta/command_handlers/handle_linting_command.cpython-312-darwin.so +0 -0
  34. roksta/command_handlers/handle_login_command.cpython-312-darwin.so +0 -0
  35. roksta/command_handlers/handle_logout_command.cpython-312-darwin.so +0 -0
  36. roksta/command_handlers/handle_payment_details_command.cpython-312-darwin.so +0 -0
  37. roksta/command_handlers/handle_quit_command.cpython-312-darwin.so +0 -0
  38. roksta/command_handlers/handle_redeem_command.cpython-312-darwin.so +0 -0
  39. roksta/command_handlers/handle_request_activation_command.cpython-312-darwin.so +0 -0
  40. roksta/command_handlers/handle_testing_command.cpython-312-darwin.so +0 -0
  41. roksta/command_handlers/handle_usage_command.cpython-312-darwin.so +0 -0
  42. roksta/create_default_config.cpython-312-darwin.so +0 -0
  43. roksta/env.cpython-312-darwin.so +0 -0
  44. roksta/extended_text_area.cpython-312-darwin.so +0 -0
  45. roksta/firebase.cpython-312-darwin.so +0 -0
  46. roksta/fix_tests.cpython-312-darwin.so +0 -0
  47. roksta/goal_workflow.cpython-312-darwin.so +0 -0
  48. roksta/init_codebase.cpython-312-darwin.so +0 -0
  49. roksta/lint_code.cpython-312-darwin.so +0 -0
  50. roksta/main.cpython-312-darwin.so +0 -0
  51. roksta/new_features.cpython-312-darwin.so +0 -0
  52. roksta/propose_solution.cpython-312-darwin.so +0 -0
  53. roksta/roksta.cpython-312-darwin.so +0 -0
  54. roksta/select_files.cpython-312-darwin.so +0 -0
  55. roksta/tips.cpython-312-darwin.so +0 -0
  56. roksta/utils.cpython-312-darwin.so +0 -0
  57. roksta/write_code.cpython-312-darwin.so +0 -0
  58. {roksta-0.2.7.dist-info → roksta-0.3.2.dist-info}/METADATA +2 -1
  59. roksta-0.3.2.dist-info/RECORD +121 -0
  60. tests/conftest.py +42 -0
  61. tests/functions/{api_v0_01 → api_v1_01}/__init__.py +1 -1
  62. tests/functions/{api_v0_01 → api_v1_01}/test__analytics.py +2 -3
  63. tests/functions/{api_v0_01 → api_v1_01}/test__gemini_proxy.py +51 -6
  64. tests/functions/{api_v0_01 → api_v1_01}/test__generic_proxy.py +31 -2
  65. tests/functions/{api_v0_01 → api_v1_01}/test__get_payment_details.py +2 -2
  66. tests/functions/{api_v0_01 → api_v1_01}/test__openai_proxy.py +50 -14
  67. tests/functions/{api_v0_01 → api_v1_01}/test__redeem_credit_code.py +2 -2
  68. tests/functions/{api_v0_01 → api_v1_01}/test__sync_emails.py +3 -2
  69. tests/functions/{api_v0_01 → api_v1_01}/test__take_payment.py +2 -2
  70. tests/functions/{api_v0_01 → api_v1_01}/test__use_activation_code.py +3 -2
  71. tests/functions/api_v1_02/__init__.py +2 -0
  72. tests/functions/api_v1_02/test__analytics.py +416 -0
  73. tests/functions/api_v1_02/test__gemini_proxy.py +352 -0
  74. tests/functions/api_v1_02/test__generic_proxy.py +428 -0
  75. tests/functions/api_v1_02/test__get_payment_details.py +356 -0
  76. tests/functions/api_v1_02/test__openai_proxy.py +449 -0
  77. tests/functions/api_v1_02/test__redeem_credit_code.py +167 -0
  78. tests/functions/api_v1_02/test__sync_emails.py +325 -0
  79. tests/functions/api_v1_02/test__take_payment.py +491 -0
  80. tests/functions/api_v1_02/test__use_activation_code.py +438 -0
  81. tests/functions/api_v1_02/test_proxy_keyword_replacement.py +557 -0
  82. tests/functions/api_v1_02/test_replace_keywords.py +74 -0
  83. tests/functions/test_utils.py +484 -0
  84. roksta/ai/tools.cpython-312-darwin.so +0 -0
  85. roksta/command_handlers.cpython-312-darwin.so +0 -0
  86. roksta-0.2.7.dist-info/RECORD +0 -78
  87. tests/functions/test_utils_functions.py +0 -222
  88. {roksta-0.2.7.dist-info → roksta-0.3.2.dist-info}/WHEEL +0 -0
  89. {roksta-0.2.7.dist-info → roksta-0.3.2.dist-info}/entry_points.txt +0 -0
  90. {roksta-0.2.7.dist-info → roksta-0.3.2.dist-info}/top_level.txt +0 -0
  91. /tests/functions/{test_main_functions.py → test_main.py} +0 -0
@@ -0,0 +1,484 @@
1
+ import importlib.util
2
+ import os
3
+ import sys
4
+ import types
5
+ import json
6
+ import base64
7
+ import uuid
8
+ import pytest
9
+
10
+
11
+ # Helper to create simple module stubs
12
+ def _make_fake_firebase_functions():
13
+ fake_https = types.ModuleType('firebase_functions.https_fn')
14
+
15
+ class FakeResponse:
16
+ def __init__(self, response=None, mimetype=None, status=200, **kwargs):
17
+ # Mirror the small subset of the real Response API used by the code/tests
18
+ self.status_code = status
19
+ if isinstance(response, bytes):
20
+ self._text = response.decode('utf-8')
21
+ else:
22
+ # If a non-string is passed (unlikely), coerce to JSON text for assertions
23
+ self._text = response if isinstance(response, str) else (json.dumps(response) if response is not None else '')
24
+ self.mimetype = mimetype
25
+ self.headers = {'Content-Type': mimetype} if mimetype else {}
26
+
27
+ def get_data(self, as_text=False):
28
+ return self._text if as_text else self._text.encode('utf-8')
29
+
30
+ fake_https.Response = FakeResponse
31
+ # Provide a Request attribute used in type annotations in the module under test
32
+ fake_https.Request = types.SimpleNamespace
33
+
34
+ fake_root = types.ModuleType('firebase_functions')
35
+ fake_root.https_fn = fake_https
36
+ return fake_root, fake_https
37
+
38
+
39
+ def _make_fake_firebase_admin():
40
+ fake = types.ModuleType('firebase_admin')
41
+ # Minimal auth object so import succeeds; tests here don't rely on actual auth behaviour
42
+ fake.auth = types.SimpleNamespace(verify_id_token=lambda token: {'uid': 'test'})
43
+ return fake
44
+
45
+
46
+ def _make_fake_google_secretmanager():
47
+ google = types.ModuleType('google')
48
+ google_cloud = types.ModuleType('google.cloud')
49
+ secretmanager = types.ModuleType('google.cloud.secretmanager')
50
+
51
+ class FakeClient:
52
+ def access_secret_version(self, request):
53
+ raise RuntimeError("SecretManager should not be called in these tests")
54
+
55
+ secretmanager.SecretManagerServiceClient = FakeClient
56
+ google_cloud.secretmanager = secretmanager
57
+ google.cloud = google_cloud
58
+ return google, google_cloud, secretmanager
59
+
60
+
61
+ def _load_utils_module(monkeypatch):
62
+ """Load a fresh copy of functions/utils.py as an isolated module.
63
+
64
+ This helper inserts necessary fake modules into sys.modules via the
65
+ provided monkeypatch fixture before loading the module so its import-time
66
+ dependencies succeed and are controllable by the tests.
67
+ """
68
+ repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
69
+ utils_path = os.path.join(repo_root, 'functions', 'utils.py')
70
+ assert os.path.exists(utils_path), f"Expected functions/utils.py to exist at {utils_path}"
71
+
72
+ # Prepare and register lightweight stubs needed at import time
73
+ fake_firebase_root, fake_https = _make_fake_firebase_functions()
74
+ monkeypatch.setitem(sys.modules, 'firebase_functions', fake_firebase_root)
75
+ monkeypatch.setitem(sys.modules, 'firebase_functions.https_fn', fake_https)
76
+
77
+ fake_firebase_admin = _make_fake_firebase_admin()
78
+ monkeypatch.setitem(sys.modules, 'firebase_admin', fake_firebase_admin)
79
+
80
+ google, google_cloud, secretmanager = _make_fake_google_secretmanager()
81
+ monkeypatch.setitem(sys.modules, 'google', google)
82
+ monkeypatch.setitem(sys.modules, 'google.cloud', google_cloud)
83
+ monkeypatch.setitem(sys.modules, 'google.cloud.secretmanager', secretmanager)
84
+
85
+ # Create a unique module name so each test gets a fresh module object
86
+ module_name = f"tests.utils_isolated_{uuid.uuid4().hex}"
87
+ spec = importlib.util.spec_from_file_location(module_name, utils_path)
88
+ module = importlib.util.module_from_spec(spec)
89
+ # Ensure the new module is discoverable under its name during execution
90
+ monkeypatch.setitem(sys.modules, module_name, module)
91
+ spec.loader.exec_module(module)
92
+ return module
93
+
94
+
95
+ def test_create_json_response_returns_expected_json_and_status(monkeypatch):
96
+ mod = _load_utils_module(monkeypatch)
97
+
98
+ resp = mod.create_json_response(True, {"alpha": 1}, 201)
99
+
100
+ assert hasattr(resp, 'status_code')
101
+ assert resp.status_code == 201
102
+
103
+ body_text = resp.get_data(as_text=True)
104
+ parsed = json.loads(body_text)
105
+ assert parsed == {"success": True, "payload": {"alpha": 1}}
106
+
107
+
108
+ def test_get_sealedbox_private_key_raises_when_pynacl_privatekey_missing(monkeypatch):
109
+ # Ensure a nacl.public module exists but does NOT expose PrivateKey so the
110
+ # import inside get_sealedbox_private_key raises and the function reports
111
+ # that encryption support is unavailable.
112
+ nacl_mod = types.ModuleType('nacl')
113
+ nacl_public = types.ModuleType('nacl.public')
114
+
115
+ # Provide PublicKey/SealedBox but omit PrivateKey to trigger the import error
116
+ class PublicKeyStub:
117
+ def __init__(self, data):
118
+ self._data = bytes(data)
119
+
120
+ class SealedBoxStub:
121
+ def __init__(self, key):
122
+ pass
123
+
124
+ nacl_public.PublicKey = PublicKeyStub
125
+ nacl_public.SealedBox = SealedBoxStub
126
+
127
+ monkeypatch.setitem(sys.modules, 'nacl', nacl_mod)
128
+ monkeypatch.setitem(sys.modules, 'nacl.public', nacl_public)
129
+
130
+ mod = _load_utils_module(monkeypatch)
131
+
132
+ with pytest.raises(Exception) as excinfo:
133
+ mod.get_sealedbox_private_key()
134
+
135
+ assert 'Encryption support is unavailable' in str(excinfo.value)
136
+
137
+
138
+ def test_get_sealedbox_private_key_initializes_and_caches_private_key(monkeypatch):
139
+ # Provide a PrivateKey implementation and stub get_secret_key to return
140
+ # a valid 32-byte base64-encoded secret. Verify the value is cached and
141
+ # the secret fetch is only performed once.
142
+ key_bytes = b"\x02" * 32
143
+
144
+ nacl_mod = types.ModuleType('nacl')
145
+ nacl_public = types.ModuleType('nacl.public')
146
+
147
+ class PrivateKeyStub:
148
+ def __init__(self, data):
149
+ # Accept bytes-like input
150
+ self._data = bytes(data)
151
+
152
+ def __repr__(self):
153
+ return f"PrivateKeyStub(len={len(self._data)})"
154
+
155
+ nacl_public.PrivateKey = PrivateKeyStub
156
+ monkeypatch.setitem(sys.modules, 'nacl', nacl_mod)
157
+ monkeypatch.setitem(sys.modules, 'nacl.public', nacl_public)
158
+
159
+ mod = _load_utils_module(monkeypatch)
160
+
161
+ calls = {'count': 0}
162
+
163
+ def fake_get_secret_key(name):
164
+ calls['count'] += 1
165
+ return base64.b64encode(key_bytes).decode('ascii')
166
+
167
+ # Replace the module-level get_secret_key with our fake
168
+ mod.get_secret_key = fake_get_secret_key
169
+
170
+ # Ensure fresh start
171
+ mod._SEALEDBOX_PRIVATE_KEY = None
172
+
173
+ first = mod.get_sealedbox_private_key()
174
+ second = mod.get_sealedbox_private_key()
175
+
176
+ assert first is second
177
+ assert calls['count'] == 1
178
+ assert hasattr(first, '_data') and first._data == key_bytes
179
+
180
+
181
+ def test_get_sealedbox_private_key_invalid_length_does_not_cache_and_raises(monkeypatch):
182
+ # Provide PrivateKey but have the secret manager return an invalid-length key
183
+ invalid_key = b"\x03" * 16
184
+
185
+ nacl_mod = types.ModuleType('nacl')
186
+ nacl_public = types.ModuleType('nacl.public')
187
+
188
+ class PrivateKeyStub:
189
+ def __init__(self, data):
190
+ self._data = bytes(data)
191
+
192
+ nacl_public.PrivateKey = PrivateKeyStub
193
+ monkeypatch.setitem(sys.modules, 'nacl', nacl_mod)
194
+ monkeypatch.setitem(sys.modules, 'nacl.public', nacl_public)
195
+
196
+ mod = _load_utils_module(monkeypatch)
197
+
198
+ def fake_get_secret_key(name):
199
+ return base64.b64encode(invalid_key).decode('ascii')
200
+
201
+ mod.get_secret_key = fake_get_secret_key
202
+
203
+ # Ensure fresh start
204
+ mod._SEALEDBOX_PRIVATE_KEY = None
205
+
206
+ with pytest.raises(Exception) as excinfo:
207
+ mod.get_sealedbox_private_key()
208
+
209
+ assert 'Failed to initialize sealed-box private key' in str(excinfo.value)
210
+ # Failure should not be cached
211
+ assert mod._SEALEDBOX_PRIVATE_KEY is None
212
+
213
+
214
+ # ------------------------- Additional tests to improve coverage -------------------------
215
+
216
+ def test_get_secret_key_returns_secret_on_success(monkeypatch):
217
+ mod = _load_utils_module(monkeypatch)
218
+
219
+ fake_payload = types.SimpleNamespace(data=b'secret-value')
220
+ fake_response = types.SimpleNamespace(payload=fake_payload)
221
+
222
+ class FakeClient:
223
+ def access_secret_version(self, request):
224
+ return fake_response
225
+
226
+ # Patch the SecretManager client on the imported module
227
+ monkeypatch.setattr(mod.secretmanager, 'SecretManagerServiceClient', FakeClient, raising=True)
228
+
229
+ result = mod.get_secret_key('my-secret')
230
+ assert result == 'secret-value'
231
+
232
+
233
+ def test_get_secret_key_raises_on_backend_error(monkeypatch):
234
+ mod = _load_utils_module(monkeypatch)
235
+
236
+ class FakeClient:
237
+ def access_secret_version(self, request):
238
+ raise RuntimeError('boom')
239
+
240
+ monkeypatch.setattr(mod.secretmanager, 'SecretManagerServiceClient', FakeClient, raising=True)
241
+
242
+ with pytest.raises(Exception) as excinfo:
243
+ mod.get_secret_key('does-not-matter')
244
+ assert 'Failed to retrieve secret key from Secret Manager' in str(excinfo.value)
245
+
246
+
247
+ def test_verify_firebase_token_success(monkeypatch):
248
+ mod = _load_utils_module(monkeypatch)
249
+ req = types.SimpleNamespace(headers={'Authorization': 'Bearer SOME_TOKEN'})
250
+
251
+ res = mod.verify_firebase_token(req)
252
+ assert res == {'uid': 'test'}
253
+
254
+
255
+ def test_verify_firebase_token_missing_or_invalid_header_raises(monkeypatch):
256
+ mod = _load_utils_module(monkeypatch)
257
+ req = types.SimpleNamespace(headers={})
258
+
259
+ with pytest.raises(Exception) as excinfo:
260
+ mod.verify_firebase_token(req)
261
+ # The implementation wraps the underlying message, but the cause should be present
262
+ assert 'Missing or invalid Authorization' in str(excinfo.value)
263
+
264
+
265
+ def test_verify_firebase_token_verify_id_token_failure_raises(monkeypatch):
266
+ mod = _load_utils_module(monkeypatch)
267
+
268
+ def fake_verify(token):
269
+ raise ValueError('invalid token')
270
+
271
+ # Replace the verifier with one that raises
272
+ mod.auth.verify_id_token = fake_verify
273
+
274
+ req = types.SimpleNamespace(headers={'Authorization': 'Bearer x'})
275
+ with pytest.raises(Exception) as excinfo:
276
+ mod.verify_firebase_token(req)
277
+ assert 'invalid token' in str(excinfo.value)
278
+
279
+
280
+ def test_get_api_key_delegates_to_get_secret_key(monkeypatch):
281
+ mod = _load_utils_module(monkeypatch)
282
+
283
+ called = {}
284
+
285
+ def fake_get_secret_key(name):
286
+ called['name'] = name
287
+ return 'X'
288
+
289
+ mod.get_secret_key = fake_get_secret_key
290
+
291
+ result = mod.get_api_key(mod.LlmFamily.OPENAI)
292
+ assert result == 'X'
293
+ assert called['name'] == 'openai-api-key'
294
+
295
+
296
+ def test_get_request_json_plaintext_returns_parsed_json(monkeypatch):
297
+ mod = _load_utils_module(monkeypatch)
298
+
299
+ def get_json(silent=False):
300
+ return {'a': 1}
301
+
302
+ req = types.SimpleNamespace(headers={}, get_json=get_json)
303
+ result = mod.get_request_json(req, strict=False)
304
+ assert result == {'a': 1}
305
+
306
+
307
+ def test_get_request_json_plaintext_strict_raises_on_get_json_error(monkeypatch):
308
+ mod = _load_utils_module(monkeypatch)
309
+
310
+ def get_json(silent=False):
311
+ raise ValueError('bad json')
312
+
313
+ req = types.SimpleNamespace(headers={}, get_json=get_json)
314
+ with pytest.raises(Exception):
315
+ mod.get_request_json(req, strict=True)
316
+
317
+
318
+ def test_get_request_json_plaintext_non_strict_returns_none_on_get_json_error(monkeypatch):
319
+ mod = _load_utils_module(monkeypatch)
320
+
321
+ def get_json(silent=False):
322
+ raise ValueError('bad json')
323
+
324
+ req = types.SimpleNamespace(headers={}, get_json=get_json)
325
+ result = mod.get_request_json(req, strict=False)
326
+ assert result is None
327
+
328
+
329
+ def _install_sealedbox_stub(monkeypatch, decrypt_behavior):
330
+ """Helper: install a nacl.public.SealedBox stub whose decrypt returns or throws.
331
+
332
+ decrypt_behavior may be either:
333
+ - a bytes object to return from decrypt(), or
334
+ - a callable that accepts ciphertext and returns bytes / raises.
335
+ """
336
+ nacl_mod = types.ModuleType('nacl')
337
+ nacl_public = types.ModuleType('nacl.public')
338
+
339
+ class SealedBox:
340
+ def __init__(self, key):
341
+ self._key = key
342
+
343
+ def decrypt(self, ciphertext):
344
+ if callable(decrypt_behavior):
345
+ return decrypt_behavior(ciphertext)
346
+ return decrypt_behavior
347
+
348
+ nacl_public.SealedBox = SealedBox
349
+ nacl_mod.public = nacl_public
350
+
351
+ # Ensure both module paths exist in sys.modules so `from nacl.public import SealedBox` works
352
+ monkeypatch.setitem(sys.modules, 'nacl', nacl_mod)
353
+ monkeypatch.setitem(sys.modules, 'nacl.public', nacl_public)
354
+
355
+
356
+ def test_get_request_json_encrypted_success_using_get_data(monkeypatch):
357
+ mod = _load_utils_module(monkeypatch)
358
+
359
+ plaintext = b'{"ok": true}'
360
+ ciphertext = b'FAKECIPHERTEXT'
361
+ body_b64 = base64.b64encode(ciphertext)
362
+
363
+ # Request exposes get_data(as_text=False)
364
+ def get_data(as_text=False):
365
+ return body_b64
366
+
367
+ req = types.SimpleNamespace(headers={mod.ENCRYPTION_HEADER_NAME: 'true'}, get_data=get_data)
368
+
369
+ # SealedBox.decrypt will return the plaintext regardless of ciphertext
370
+ _install_sealedbox_stub(monkeypatch, plaintext)
371
+ # Stub the private key loader so it doesn't call Secret Manager
372
+ monkeypatch.setattr(mod, 'get_sealedbox_private_key', lambda: 'DUMMY', raising=False)
373
+
374
+ res = mod.get_request_json(req, strict=True)
375
+ assert res == {"ok": True}
376
+
377
+
378
+ def test_get_request_json_encrypted_fallback_when_get_data_rejects_as_text_arg(monkeypatch):
379
+ mod = _load_utils_module(monkeypatch)
380
+
381
+ plaintext = b'{"ok": 1}'
382
+ ciphertext = b'CT'
383
+ body_b64 = base64.b64encode(ciphertext)
384
+
385
+ def get_data(*args, **kwargs):
386
+ # Simulate a stub that raises when given the as_text kwarg
387
+ if 'as_text' in kwargs:
388
+ raise TypeError('no as_text')
389
+ return body_b64
390
+
391
+ req = types.SimpleNamespace(headers={mod.ENCRYPTION_HEADER_NAME: 'true'}, get_data=get_data)
392
+
393
+ _install_sealedbox_stub(monkeypatch, plaintext)
394
+ monkeypatch.setattr(mod, 'get_sealedbox_private_key', lambda: 'DUMMY', raising=False)
395
+
396
+ res = mod.get_request_json(req, strict=True)
397
+ assert res == {"ok": 1}
398
+
399
+
400
+ def test_get_request_json_encrypted_uses_data_attribute_if_no_get_data(monkeypatch):
401
+ mod = _load_utils_module(monkeypatch)
402
+
403
+ plaintext = b'{"v": 42}'
404
+ ciphertext = b'CT2'
405
+ body_b64 = base64.b64encode(ciphertext)
406
+
407
+ req = types.SimpleNamespace(headers={mod.ENCRYPTION_HEADER_NAME: 'true'}, data=body_b64)
408
+
409
+ _install_sealedbox_stub(monkeypatch, plaintext)
410
+ monkeypatch.setattr(mod, 'get_sealedbox_private_key', lambda: 'DUMMY', raising=False)
411
+
412
+ res = mod.get_request_json(req, strict=True)
413
+ assert res == {"v": 42}
414
+
415
+
416
+ def test_get_request_json_encrypted_invalid_base64(monkeypatch):
417
+ mod = _load_utils_module(monkeypatch)
418
+
419
+ # Make b64 decoder throw to exercise that error path deterministically
420
+ def fake_b64decode(_):
421
+ raise Exception('bad base64')
422
+
423
+ monkeypatch.setattr(mod.base64, 'b64decode', fake_b64decode, raising=True)
424
+
425
+ def get_data(as_text=False):
426
+ return b'NOT-BASE64'
427
+
428
+ req = types.SimpleNamespace(headers={mod.ENCRYPTION_HEADER_NAME: 'true'}, get_data=get_data)
429
+
430
+ # Non-strict should return None
431
+ res = mod.get_request_json(req, strict=False)
432
+ assert res is None
433
+
434
+ # Strict should raise
435
+ with pytest.raises(Exception):
436
+ mod.get_request_json(req, strict=True)
437
+
438
+
439
+ def test_get_request_json_encrypted_decrypt_failure(monkeypatch):
440
+ mod = _load_utils_module(monkeypatch)
441
+
442
+ ciphertext = b'CT'
443
+ body_b64 = base64.b64encode(ciphertext)
444
+
445
+ # SealedBox.decrypt will raise to simulate decryption failure
446
+ def raise_on_decrypt(_):
447
+ raise RuntimeError('bad decrypt')
448
+
449
+ _install_sealedbox_stub(monkeypatch, raise_on_decrypt)
450
+ monkeypatch.setattr(mod, 'get_sealedbox_private_key', lambda: 'DUMMY', raising=False)
451
+
452
+ def get_data(as_text=False):
453
+ return body_b64
454
+
455
+ req = types.SimpleNamespace(headers={mod.ENCRYPTION_HEADER_NAME: 'true'}, get_data=get_data)
456
+
457
+ # Non-strict returns None
458
+ assert mod.get_request_json(req, strict=False) is None
459
+
460
+ # Strict raises
461
+ with pytest.raises(Exception):
462
+ mod.get_request_json(req, strict=True)
463
+
464
+
465
+ def test_get_request_json_encrypted_invalid_json_after_decrypt(monkeypatch):
466
+ mod = _load_utils_module(monkeypatch)
467
+
468
+ # Decrypt returns bytes that are not valid JSON
469
+ _install_sealedbox_stub(monkeypatch, b'not-json')
470
+ monkeypatch.setattr(mod, 'get_sealedbox_private_key', lambda: 'DUMMY', raising=False)
471
+
472
+ body_b64 = base64.b64encode(b'CT')
473
+
474
+ def get_data(as_text=False):
475
+ return body_b64
476
+
477
+ req = types.SimpleNamespace(headers={mod.ENCRYPTION_HEADER_NAME: 'true'}, get_data=get_data)
478
+
479
+ assert mod.get_request_json(req, strict=False) is None
480
+ with pytest.raises(Exception):
481
+ mod.get_request_json(req, strict=True)
482
+
483
+
484
+ # End of additional tests
Binary file
@@ -1,78 +0,0 @@
1
- roksta/default_config.cpython-312-darwin.so,sha256=Y-DEmdi-YpyroffYtiQ631HjKd-bZVWRxn49LIDRUcc,102232
2
- roksta/__init__.cpython-312-darwin.so,sha256=aGhoZOTGADw_8ui447BG2io1Nf9nx4Qs353LjHeBrFc,85632
3
- roksta/codebase_listing.cpython-312-darwin.so,sha256=GDTBAN99YQvxlb6RTKaBN3I7wn-7zc2jVlDdIaGpGVE,155720
4
- roksta/make_issue.cpython-312-darwin.so,sha256=Sjvsc3d8Tkvkklm2n8VXymWeFfJGB6Sf8XUDLF8K-L8,221968
5
- roksta/create_default_config.cpython-312-darwin.so,sha256=HEMzoryrPvKgG8rU7otatfUzdgKsQe1T9bBNxK3Nnf4,121864
6
- roksta/gen_codebase_summaries.cpython-312-darwin.so,sha256=2AJ-0gS93G9jk8Zr9iH0QVbknSijFnbjhtQdEULYVrw,637776
7
- roksta/balance.cpython-312-darwin.so,sha256=QAm-Q3P792PDsFX3EgLfF7gt1Cs9NKc4wmOV0oJWAcw,340288
8
- roksta/propose_solution.cpython-312-darwin.so,sha256=MQtr01d3Ok4AaqODFGT985P8jTufNzbqc-lMeV1z0Rk,207352
9
- roksta/command_handlers.cpython-312-darwin.so,sha256=tbuUZg8BWwspNIHm0tw640etcK6HlXj2pL6WwuC-2Lo,950008
10
- roksta/analytics.cpython-312-darwin.so,sha256=LLY7YZ95KCkyE-3OpYx04fE0OsPsv7PitQNhjBWvnLk,273024
11
- roksta/utils.cpython-312-darwin.so,sha256=jgl9rbcb17Ve-KHMF5kCSUcVEn7VtQWdGdHETgjsoiA,588904
12
- roksta/check_for_updates.cpython-312-darwin.so,sha256=DMO-ijojEUz-A1I5KgXn8CewwvQyslw16ICwHjMquO0,306632
13
- roksta/response_formats.cpython-312-darwin.so,sha256=nnb92jNdRh8g4Xq1ocI6xqeDvIKMX9x_1etlDcA-t8M,121112
14
- roksta/main.cpython-312-darwin.so,sha256=yQAp1Uc-5200PGWGMYlyqljxivIHsXX_reH3R6Fdifs,138808
15
- roksta/env.cpython-312-darwin.so,sha256=mt3XSxcP5M6VSM-H9HCgXuAAaHwWamv8QVBUg-XUMWQ,104520
16
- roksta/get_failing_tests.cpython-312-darwin.so,sha256=WRLjGOl5idN3jrSaC5b9L81VZTlCYMSnjwbuDUSemIg,224152
17
- roksta/fix_tests.cpython-312-darwin.so,sha256=LUHtij6Lr4opaPHm6QSAX_A895PvUbvI3MS8kW9WxYo,240544
18
- roksta/firebase_auth_web.cpython-312-darwin.so,sha256=UL94FIDhUwIt3befN3FmCyiPANxo_66dLb9Wp5CojR4,472600
19
- roksta/run_cli_goal.cpython-312-darwin.so,sha256=ZMHes3egj1mezMkqHGRtGbVjCWf68rsGhQw1qt5NjS4,223808
20
- roksta/build_project.cpython-312-darwin.so,sha256=R4p3o9ZxFNVcs1-y2ovIfdiHE5xryMLkv9YgSoyd1ks,191040
21
- roksta/rewrite_goal.cpython-312-darwin.so,sha256=rIME3oOjnPK41PWYJaHQpyGuqgxIrt15ld-dNpqb8M4,190944
22
- roksta/roksta.cpython-312-darwin.so,sha256=ybvg31CLS0xiWM6HTcltwNueTAvx3D_v8-zN2SN-xAo,555184
23
- roksta/clarify_goal.cpython-312-darwin.so,sha256=59BdRuKeKscoYS5FWGnTtr9cB25owCi-j3Uf_Swy8ww,207680
24
- roksta/init_codebase.cpython-312-darwin.so,sha256=B1rJefykkkb3Lhg5TpFdLqwBSR3Al5VEkoIkvjVuJNE,291600
25
- roksta/gen_one_line_goal.cpython-312-darwin.so,sha256=_7TixHwo32-8MFKj8tYln6wERC3mVkRC9oWfH09rgAk,207624
26
- roksta/new_features.cpython-312-darwin.so,sha256=xhcbX_7tXCDCWSHi_NAJMv0_wu8doErQjztixEK1p8s,85712
27
- roksta/firebase_config.cpython-312-darwin.so,sha256=EOpQM7e9pW2ZqAlkjbeOV-Iyoq4DSU__DIZpeDmO9gI,86776
28
- roksta/chat_workflow.cpython-312-darwin.so,sha256=DKC26wml81h4tNSE5-Bji5C92y2A94j3_Aayq_sbNOE,273664
29
- roksta/select_files.cpython-312-darwin.so,sha256=7DnRFSWLr7MGS8f1d4TbmNwJpEj0LlD6q-nZHPnjvbU,207648
30
- roksta/enums.cpython-312-darwin.so,sha256=13gc6A4RbZG7DGQIk5o2PlRwX4ymKpdiOzcJV58rxFQ,338440
31
- roksta/write_code.cpython-312-darwin.so,sha256=54RA7v4dckjsEQCxmHApzukTfKD0xEdowuXB2_Fxo-Q,191008
32
- roksta/tips.cpython-312-darwin.so,sha256=M88nPYTB9mlIJzdjdJ2D709wdeEpjIIUrLDvpa0ywTI,85672
33
- roksta/goal_workflow.cpython-312-darwin.so,sha256=AWO5y0Gm53wezf5s4iAyy57iCv99DRxw0ZW8gAaxkHU,521744
34
- roksta/firebase.cpython-312-darwin.so,sha256=O2g9eG2EWDjcFhP2t77TkYImMykrbOv0CAUSkMmHi6I,488032
35
- roksta/parse_readme.cpython-312-darwin.so,sha256=UQaLbWoB2rOPPDMHSNDA9muAptft1iJ-vkjyKWN9T4s,207152
36
- roksta/logger.cpython-312-darwin.so,sha256=lIfX2V-QExvKZK3LcLF4qQGeMduT5ZVPUXwg0kk57rU,122160
37
- roksta/lint_code.cpython-312-darwin.so,sha256=PwG4THA4hikmTGDxXiAYH7IJip6ZpiiT8Qs5_4LmRYs,207904
38
- roksta/extended_text_area.cpython-312-darwin.so,sha256=9RkHasJWx-qQ_ROBjld7vtr4BgT15wd_-kfxqLr2QCw,307272
39
- roksta/checkpoints.cpython-312-darwin.so,sha256=UdKnNkQweTrMxDjpfjruXtEFVyNG4B4mrg2K07f3ojg,254432
40
- roksta/get_codebase_structure.cpython-312-darwin.so,sha256=_ZS1xgbWZUm8grv1lrmstrepFvH-ZK-xczOQ4-doM60,206272
41
- roksta/ai/__init__.cpython-312-darwin.so,sha256=5_lHxLo2XMbdiUPvD567zM1pag2REJBiRZkorL9pEdw,85632
42
- roksta/ai/generic.cpython-312-darwin.so,sha256=cKS86aGAMEO3Fdwv8ZoRK14wLZbDRdzmYSKKJF3ewuw,306800
43
- roksta/ai/gemini.cpython-312-darwin.so,sha256=USUzPnquPyOcDSolWQBhgp0N_xlkPJq8A5UL-vAOO9w,406000
44
- roksta/ai/tools.cpython-312-darwin.so,sha256=Zw5gPjpJnxflc3AHyK2IDCKOzGT9TelqJ1mDj5uc17k,637352
45
- roksta/ai/openai.cpython-312-darwin.so,sha256=5OkpWqbS-mVNT2OJGuyya6q7YdF_3t7nRL89n03qDDE,290400
46
- roksta/ai/call_ai.cpython-312-darwin.so,sha256=XqZ02InC0Cz9Rmotu4NrAD-gaItr5PeYQB6V1F9O83I,240624
47
- roksta/ai/llm.cpython-312-darwin.so,sha256=DfuRAPnOuZSRlksV0zCSSG5czhLyY-tNrLLCwOBedYY,271640
48
- tests/conftest.py,sha256=WBja46X2wduZRF2t4LARhbNvLlU8oRhSW_HB6ara8Yg,6295
49
- tests/__init__.py,sha256=J6ztnXNqM8TSQCgHXMWb6NRq1kN_h4ql63Jq-TYR8XE,124
50
- tests/functions/test_auth.py,sha256=I3oFTw2LTuUsnQ75v5SCfgUPnpel_pDKqUH0VAJpXQw,992
51
- tests/functions/__init__.py,sha256=mLXx3UARcv07vs_fGJuy3L5ZRn9IRsF9zIuL5IOnwdk,95
52
- tests/functions/test_utils_functions.py,sha256=gS-SxnK0QnVUooxcXlJKodjqOB1HVmUxufwzUPQ7qAk,7368
53
- tests/functions/test_main_functions.py,sha256=h0W_4ISo95WzRy2HpXZw3cuNOTcYk_2QCIZffZJEfEU,2575
54
- tests/functions/api_v1_00/test__sync_emails.py,sha256=OTyf2YbBK7e4pWIQTUGYR4x6il1Hb3g4FYqQ_fRj1nA,12699
55
- tests/functions/api_v1_00/test__take_payment.py,sha256=I-XJasGuLW5wTMAu4nAgFkA8Mo_zVpGPvkJ2LrrJGCk,18022
56
- tests/functions/api_v1_00/test__gemini_proxy.py,sha256=mf8ubRmNxxxN80H6EA-iDPwu6Oue6Rmgxl6tiFNpfrU,13344
57
- tests/functions/api_v1_00/test__analytics.py,sha256=oKjd7_zjnttcb-5BuA93yllkm0OOF4YWnfTUW1-icnM,15806
58
- tests/functions/api_v1_00/__init__.py,sha256=3RCSoj_5UQPw9Z5NeAgYz2s4gfcZIi7g36qk_Ed5TiA,124
59
- tests/functions/api_v1_00/test__use_activation_code.py,sha256=tNyTkkRtrpjei-7F31UNwrcU-PbP-QnkWNU7h2n5Yqo,16960
60
- tests/functions/api_v1_00/test__redeem_credit_code.py,sha256=7GD3tGgO2Lk0BCjUmzZACJiwocEhLBvXrrut0x13IWU,6347
61
- tests/functions/api_v1_00/test__openai_proxy.py,sha256=xlO2zmG64LlrKrbjFz-ds6Map7vy4SjIuHfZJDAqGK8,17726
62
- tests/functions/api_v1_00/test__get_payment_details.py,sha256=i5Px3NkLxqw8D3tVPrYdRJJF5jlNmysSuX_NNolbIa4,13735
63
- tests/functions/api_v1_00/test__generic_proxy.py,sha256=KZkOtmc71aOnWlz2L7B6CFhRNEV73bExG3GR14oD2L0,17673
64
- tests/functions/api_v0_01/test__sync_emails.py,sha256=zCfuh1M6qJlGaCpCWuUE0Ao9Pp5pVkBJXXjoctldkpk,12698
65
- tests/functions/api_v0_01/test__take_payment.py,sha256=2WDv_7cYTozVMl7hDLNDTF9gmfrgna3oR8xgfRa-plA,18022
66
- tests/functions/api_v0_01/test__gemini_proxy.py,sha256=R-lzyVsNtqJFGILKhgy1cUIHg1SYPSFKNDbKp2fua-k,11152
67
- tests/functions/api_v0_01/test__analytics.py,sha256=nMs_aYuXDEFWz9aY21MYwbgugF-czRbucAzis4-8kgc,15807
68
- tests/functions/api_v0_01/__init__.py,sha256=BOIFrFcANRAbpnX0Bez6rtkj6xJnOli1fqzFX5SpkV0,124
69
- tests/functions/api_v0_01/test__use_activation_code.py,sha256=EgifjM9wkW1fkQoBK9z5PEEM5xwpRHyt_g7QWy6xrec,16959
70
- tests/functions/api_v0_01/test__redeem_credit_code.py,sha256=WSs7CE2pkHsied_tg3XCR3RJ9blwQEkOzy-s3lkV_w0,6347
71
- tests/functions/api_v0_01/test__openai_proxy.py,sha256=Nda-RDUVYBQl2wI5mxxr9Ca-9k9HJV5EgEmdIvyytGs,15761
72
- tests/functions/api_v0_01/test__get_payment_details.py,sha256=3LYAp9m1RDsf928HGJ6P_YTji7F4srkDv0iWcKTwW54,13735
73
- tests/functions/api_v0_01/test__generic_proxy.py,sha256=cJftek6njsphK_yesUX1QxphGcD5TEkhQNC5ROvnaIg,16190
74
- roksta-0.2.7.dist-info/RECORD,,
75
- roksta-0.2.7.dist-info/WHEEL,sha256=3DzZhK-rNIkkEIppB3qbu6syT4kayeV5HkusnWIqMIg,142
76
- roksta-0.2.7.dist-info/entry_points.txt,sha256=mzRdYg_DlzZRwjxYUt9-gyoRCkM1QBTeTbwETgiTdGw,44
77
- roksta-0.2.7.dist-info/top_level.txt,sha256=lvciNZQ1dPGXpiCLdWVXK03n9fKHjbQdwjqQbnUjeYM,13
78
- roksta-0.2.7.dist-info/METADATA,sha256=sAEp7h8ZrxTSvu8itkn48UfRLVshhC1sOT7urCnt1xM,1427