@@ -809,6 +809,33 @@ def test_nbdkit_instance_name():
809809 # Force kill if it's being stubborn
810810 p .kill ()
811811
812+ def test_data_plugin_supports_base64_in_format_string ():
813+ import base64
814+ test_state = params_get (params , "test_state" )
815+ if test_state == "positive" :
816+ # Prepare the data
817+ original_text = b"nbdkit-test123"
818+ # Encode bytes to a base64 string
819+ b64_input = base64 .b64encode (original_text ).decode ()
820+ cmd_str = f"nbdkit -U - data \' base64:{ b64_input } \' --run 'nbdcopy $uri -'"
821+ # Execute command
822+ result = process .run (cmd_str , shell = True , ignore_status = True )
823+ # Result.stdout contains the raw binary output from nbdcopy
824+ cmd_output = result .stdout
825+ if original_text not in cmd_output :
826+ test .fail (f"Base64 decoding failed. Expected { original_text !r} , got { cmd_output !r} " )
827+ elif test_state == "negative" :
828+ # Negative scenario - Check with invalid value
829+ invalid_b64 = "base64:SGVsbG8@@@"
830+ cmd_str = f"nbdkit -U - data \' { invalid_b64 } \' --run 'nbdcopy $uri -'"
831+ # Execute command
832+ result = process .run (cmd_str , shell = True , ignore_status = True )
833+ # Verify the error message
834+ cmd_output = result .stderr_text
835+ err_msg = params_get (params , "expected_err_msg" )
836+ if err_msg not in cmd_output :
837+ test .fail (f"Error message - \' { err_msg } \' not appeared." )
838+
812839 if version_required and not multiple_versions_compare (
813840 version_required ):
814841 test .cancel ("Testing requires version: %s" % version_required )
@@ -889,5 +916,7 @@ def test_nbdkit_instance_name():
889916 check_blocksize_constraints ()
890917 elif checkpoint == 'test_nbdkit_instance_name' :
891918 test_nbdkit_instance_name ()
919+ elif checkpoint == 'test_data_plugin_supports_base64_in_format_string' :
920+ test_data_plugin_supports_base64_in_format_string ()
892921 else :
893922 test .error ('Not found testcase: %s' % checkpoint )
0 commit comments