forked from phoenix/litellm-mirror
fix(initial-commit): decrypts aws keys in entrypoint.sh
This commit is contained in:
parent
3dc578555c
commit
adcd55fca0
3 changed files with 186 additions and 22 deletions
57
tests/test_entrypoint.py
Normal file
57
tests/test_entrypoint.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
# What is this?
|
||||
## Unit tests for 'entrypoint.sh'
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(
|
||||
0, os.path.abspath("../")
|
||||
) # Adds the parent directory to the system path
|
||||
import litellm
|
||||
import subprocess
|
||||
|
||||
|
||||
def test_decrypt_and_reset_env():
|
||||
os.environ["DATABASE_URL"] = (
|
||||
"aws_kms/AQICAHgwddjZ9xjVaZ9CNCG8smFU6FiQvfdrjL12DIqi9vUAQwHwF6U7caMgHQa6tK+TzaoMAAAAzjCBywYJKoZIhvcNAQcGoIG9MIG6AgEAMIG0BgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDCmu+DVeKTm5tFZu6AIBEICBhnOFQYviL8JsciGk0bZsn9pfzeYWtNkVXEsl01AdgHBqT9UOZOI4ZC+T3wO/fXA7wdNF4o8ASPDbVZ34ZFdBs8xt4LKp9niufL30WYBkuuzz89ztly0jvE9pZ8L6BMw0ATTaMgIweVtVSDCeCzEb5PUPyxt4QayrlYHBGrNH5Aq/axFTe0La"
|
||||
)
|
||||
from litellm.proxy.secret_managers.aws_secret_manager import (
|
||||
decrypt_and_reset_env_var,
|
||||
)
|
||||
|
||||
decrypt_and_reset_env_var()
|
||||
|
||||
assert os.environ["DATABASE_URL"] is not None
|
||||
assert isinstance(os.environ["DATABASE_URL"], str)
|
||||
assert not os.environ["DATABASE_URL"].startswith("aws_kms/")
|
||||
|
||||
print("DATABASE_URL={}".format(os.environ["DATABASE_URL"]))
|
||||
|
||||
|
||||
def test_entrypoint_decrypt_and_reset():
|
||||
os.environ["DATABASE_URL"] = (
|
||||
"aws_kms/AQICAHgwddjZ9xjVaZ9CNCG8smFU6FiQvfdrjL12DIqi9vUAQwHwF6U7caMgHQa6tK+TzaoMAAAAzjCBywYJKoZIhvcNAQcGoIG9MIG6AgEAMIG0BgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDCmu+DVeKTm5tFZu6AIBEICBhnOFQYviL8JsciGk0bZsn9pfzeYWtNkVXEsl01AdgHBqT9UOZOI4ZC+T3wO/fXA7wdNF4o8ASPDbVZ34ZFdBs8xt4LKp9niufL30WYBkuuzz89ztly0jvE9pZ8L6BMw0ATTaMgIweVtVSDCeCzEb5PUPyxt4QayrlYHBGrNH5Aq/axFTe0La"
|
||||
)
|
||||
command = "./entrypoint.sh"
|
||||
directory = ".." # Relative to the current directory
|
||||
|
||||
# Run the command using subprocess
|
||||
result = subprocess.run(
|
||||
command, shell=True, cwd=directory, capture_output=True, text=True
|
||||
)
|
||||
|
||||
# Print the output for debugging purposes
|
||||
print("STDOUT:", result.stdout)
|
||||
print("STDERR:", result.stderr)
|
||||
|
||||
# Assert the script ran successfully
|
||||
assert result.returncode == 0, "The shell script did not execute successfully"
|
||||
assert (
|
||||
"DECRYPTS VALUE" in result.stdout
|
||||
), "Expected output not found in script output"
|
||||
assert (
|
||||
"Database push successful!" in result.stdout
|
||||
), "Expected output not found in script output"
|
||||
|
||||
assert False
|
Loading…
Add table
Add a link
Reference in a new issue