Skip to content

Commit c8379d5

Browse files
committed
fix(review): address PR feedback
- Enhance deprecation error message with example payload - Add test case for invalid key type failure mode - Improve test coverage Signed-off-by: Scott R. Shinn <scott@atomicorp.com>
1 parent 42a050e commit c8379d5

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

server/oracle-service.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ def _handle_signing(operation):
102102
except Exception as e:
103103
return jsonify({'error': f'Invalid Base64 data: {e}'}), 400
104104
elif package_hash or repodata_hash:
105-
return jsonify({'error': 'Signing by hash is deprecated. Please provide base64 encoded "data".'}), 400
105+
err_msg = (
106+
'Signing by hash is deprecated. Please provide base64 encoded "data" field instead '
107+
'(e.g., {"data": "base64_encoded_content", "key_type": "modern"})'
108+
)
109+
return jsonify({'error': err_msg}), 400
106110
else:
107111
return jsonify({'error': 'Missing "data" field (base64 encoded content required)'}), 400
108112

tests/test_signing_fix.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,15 @@ def test_sign_binary_data(self):
7070

7171
print("Verification successful!")
7272

73+
def test_sign_invalid_key_type(self):
74+
engine = SigningEngine(gnupg_home=self.gpg_home)
75+
data = b"Some data"
76+
77+
with self.assertRaises(ValueError) as cm:
78+
engine.sign_data(data, 'invalid_key_type')
79+
80+
print(f"Caught expected error: {cm.exception}")
81+
self.assertIn("Unknown key type", str(cm.exception))
82+
7383
if __name__ == '__main__':
7484
unittest.main()

0 commit comments

Comments
 (0)