55import tempfile
66from pathlib import Path
77from zipfile import is_zipfile
8+ from os import environ
89
910from otdf_python .gotdf_python import EncryptionConfig
1011
11- SOME_PLAINTEXT_FILE = Path (__file__ ).parent / "go.mod"
12-
1312
1413def verify_hello ():
1514 from otdf_python .gotdf_python import Hello
@@ -22,11 +21,14 @@ def _get_configuration() -> EncryptionConfig:
2221 platformEndpoint = "localhost:8080"
2322
2423 config : EncryptionConfig = EncryptionConfig (
25- ClientId = "opentdf-sdk" ,
26- ClientSecret = "secret" ,
27- PlatformEndpoint = platformEndpoint ,
28- TokenEndpoint = "http://localhost:8888/auth/realms/opentdf/protocol/openid-connect/token" ,
29- KasUrl = f"http://{ platformEndpoint } /kas" ,
24+ ClientId = environ .get ("OPENTDF_CLIENT_ID" , "opentdf-sdk" ),
25+ ClientSecret = environ .get ("OPENTDF_CLIENT_SECRET" , "secret" ),
26+ PlatformEndpoint = environ .get ("OPENTDF_HOSTNAME" , platformEndpoint ),
27+ TokenEndpoint = environ .get (
28+ "OIDC_TOKEN_ENDPOINT" ,
29+ "http://localhost:8888/auth/realms/opentdf/protocol/openid-connect/token" ,
30+ ),
31+ KasUrl = environ .get ("OPENTDF_KAS_URL" , f"http://{ platformEndpoint } /kas" ),
3032 # FIXME: Be careful with binding the 'DataAttributes' field on this struct.
3133 #
3234 # In golang, this is initialized as []string , but passing
@@ -77,6 +79,9 @@ def verify_encrypt_file() -> None:
7779 "The output path should not exist before calling 'EncryptFile()'."
7880 )
7981
82+ SOME_PLAINTEXT_FILE = Path (tmpDir ) / "new-file.txt"
83+ SOME_PLAINTEXT_FILE .write_text ("Hello world" )
84+
8085 outputFilePath = EncryptFile (
8186 inputFilePath = str (SOME_PLAINTEXT_FILE ),
8287 outputFilePath = str (SOME_ENCRYPTED_FILE ),
@@ -87,10 +92,10 @@ def verify_encrypt_file() -> None:
8792 if not SOME_ENCRYPTED_FILE .exists ():
8893 raise ValueError ("The output file does not exist!" )
8994
90- if not (
91- SOME_ENCRYPTED_FILE . stat (). st_size > 2500
92- and is_zipfile ( SOME_ENCRYPTED_FILE )
93- ):
95+ encrypted_file_size = SOME_ENCRYPTED_FILE . stat (). st_size
96+ print ( f"The encrypted file size is { encrypted_file_size } " )
97+
98+ if not ( encrypted_file_size > 1500 and is_zipfile ( SOME_ENCRYPTED_FILE ) ):
9499 raise ValueError ("The output file has unexpected content!" )
95100
96101 # breakpoint()
0 commit comments