@@ -64,7 +64,7 @@ def _send_json(self, data: dict):
6464
6565 def _send_not_found (self ):
6666 self .send_response (http .HTTPStatus .NOT_FOUND )
67- msg = "Not found" . encode ( "utf8" )
67+ msg = b "Not found"
6868 self .send_header ("Content-Type" , "text/plain" )
6969 self .send_header ("Content-Length" , len (msg ))
7070 self .end_headers ()
@@ -95,18 +95,18 @@ def do_POST(self):
9595 remaining_http_fails = data ['count' ]
9696 else :
9797 self ._send_not_found ()
98- return
99- print ("Enabling failpoint for type: {}" . format ( failpoint_type ) )
98+ return None
99+ print (f "Enabling failpoint for type: { failpoint_type } " )
100100 self ._send_json (
101- {"message" : "failpoint set for type: '{}'" . format ( failpoint_type ) }
101+ {"message" : f "failpoint set for type: '{ failpoint_type } '" }
102102 )
103- return
103+ return None
104104
105105 if path .match ("/reset" ):
106106 remaining_http_fails = 0
107107 remaining_network_fails = 0
108108 self ._send_json ({"message" : "failpoints reset" })
109- return
109+ return None
110110
111111 # If a failpoint was set, fail the request.
112112 if remaining_network_fails > 0 :
@@ -118,40 +118,39 @@ def do_POST(self):
118118 aws_op = self .headers ['X-Amz-Target' ]
119119 if aws_op == "TrentService.Encrypt" :
120120 self ._send_json ({"CiphertextBlob" : base64 .b64encode (fake_ciphertext .encode ()).decode ()})
121- return
122- elif aws_op == "TrentService.Decrypt" :
121+ return None
122+ if aws_op == "TrentService.Decrypt" :
123123 if remaining_http_fails > 0 :
124124 self ._http_fail ()
125- return
125+ return None
126126 self ._send_json ({"Plaintext" : base64 .b64encode (fake_plaintext .encode ()).decode ()})
127- return
128- else :
129- self ._send_not_found ()
130- return
127+ return None
128+ self ._send_not_found ()
129+ return None
131130
132131 # GCP or Azure auth path: /c01df00d-cafe-g00d-dea1-decea5sedbeef/oauth2/v2.0/token
133132 if path .match ("*token" ):
134133 if remaining_http_fails > 0 :
135134 self ._http_fail ()
136- return
135+ return None
137136 return self ._send_json ({"access_token" : "foo" , "expires_in" : 99999 })
138137 # GCP encrypt path: /v1/projects/{project}/locations/{location}/keyRings/{key-ring}/cryptoKeys/{key}:encrypt
139- elif path .match ("*encrypt" ):
138+ if path .match ("*encrypt" ):
140139 return self ._send_json ({"ciphertext" : base64 .b64encode (fake_ciphertext .encode ()).decode ()})
141140 # GCP decrypt path: /v1/projects/{project}/locations/{location}/keyRings/{key-ring}/cryptoKeys/{key}:decrypt
142- elif path .match ("*decrypt" ):
141+ if path .match ("*decrypt" ):
143142 if remaining_http_fails > 0 :
144143 self ._http_fail ()
145- return
144+ return None
146145 return self ._send_json ({"plaintext" : base64 .b64encode (fake_plaintext .encode ()).decode ()})
147146 # Azure decrypt path: /keys/{key-name}/{key-version}/unwrapkey
148- elif path .match ("*unwrapkey" ):
147+ if path .match ("*unwrapkey" ):
149148 if remaining_http_fails > 0 :
150149 self ._http_fail ()
151- return
150+ return None
152151 return self ._send_json ({"value" : base64 .b64encode (fake_plaintext .encode ()).decode ()})
153152 # Azure encrypt path: /keys/{key-name}/{key-version}/wrapkey
154- elif path .match ("*wrapkey" ):
153+ if path .match ("*wrapkey" ):
155154 return self ._send_json ({"value" : base64 .b64encode (fake_ciphertext .encode ()).decode ()})
156155 self ._send_not_found ()
157156
0 commit comments