File tree Expand file tree Collapse file tree
app/tests/components_tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import hashlib
2+ import hmac
13import io
24import json
35from datetime import datetime , timedelta , timezone
@@ -554,23 +556,23 @@ def test_handle_completed_job():
554556 time_limit = 60 ,
555557 requires_gpu_type = GPUTypeChoices .NO_GPU ,
556558 use_warm_pool = False ,
557- signing_key = b"" ,
559+ signing_key = b"itsasecret " ,
558560 )
559561
560- return_code = 0
561-
562- with io . BytesIO () as f :
563- f . write (
564- json . dumps (
565- { "return_code" : return_code , "pk" : f"algorithms-job- { pk } " }
566- ). encode ( "utf-8" )
567- )
568- f . seek ( 0 )
569- executor ._s3_client . upload_fileobj (
570- Fileobj = f ,
571- Bucket = settings . COMPONENTS_OUTPUT_BUCKET_NAME ,
572- Key = executor . _result_key ,
573- )
562+ content = json . dumps (
563+ { "return_code" : 0 , "pk" : f"algorithms-job- { pk } " }
564+ ). encode ( "utf-8" )
565+ signature = hmac . new (
566+ key = b"itsasecret" , msg = content , digestmod = hashlib . sha256
567+ ). hexdigest ()
568+ executor . _s3_client . upload_fileobj (
569+ Fileobj = io . BytesIO ( content ),
570+ Bucket = settings . COMPONENTS_OUTPUT_BUCKET_NAME ,
571+ Key = executor ._result_key ,
572+ ExtraArgs = {
573+ "Metadata" : { "signature_hmac_sha256" : signature } ,
574+ } ,
575+ )
574576
575577 assert executor ._handle_completed_job () is None
576578
You can’t perform that action at this time.
0 commit comments