# Path: gslib/storage_url.py
# PROVIDER_REGEX = re.compile(r'(?P<provider>[^:]*)://$')
# BUCKET_REGEX = re.compile(r'(?P<provider>[^:]*)://(?P<bucket>[^/]*)/{0,1}$')
# OBJECT_REGEX = re.compile(
#     r'(?P<provider>[^:]*)://(?P<bucket>[^/]*)/(?P<object>.*)')
# GS_GENERATION_REGEX = re.compile(r'(?P<object>.+)#(?P<generation>[0-9]+)$')
# S3_VERSION_REGEX = re.compile(r'(?P<object>.+)#(?P<version_id>.+)$')
# FILE_OBJECT_REGEX = re.compile(r'([^:]*://)(?P<filepath>.*)')
# WILDCARD_REGEX = re.compile(r'[*?\[\]]')
# class StorageUrl(object):
# class _FileUrl(StorageUrl):
# class _CloudUrl(StorageUrl):
#   def Clone(self):
#   def IsFileUrl(self):
#   def IsCloudUrl(self):
#   def IsStream():
#   def IsFifo(self):
#   def CreatePrefixUrl(self, wildcard_suffix=None):
#   def _WarnIfUnsupportedDoubleWildcard(self):
#   def url_string(self):
#   def versionless_url_string(self):
#   def __eq__(self, other):
#   def __hash__(self):
#   def __init__(self, url_string, is_stream=False, is_fifo=False):
#   def Clone(self):
#   def IsFileUrl(self):
#   def IsCloudUrl(self):
#   def IsStream(self):
#   def IsFifo(self):
#   def IsDirectory(self):
#   def CreatePrefixUrl(self, wildcard_suffix=None):
#   def url_string(self):
#   def versionless_url_string(self):
#   def __str__(self):
#   def __init__(self, url_string):
#   def Clone(self):
#   def IsFileUrl(self):
#   def IsCloudUrl(self):
#   def IsStream(self):
#   def IsFifo(self):
#   def IsBucket(self):
#   def IsObject(self):
#   def HasGeneration(self):
#   def IsProvider(self):
#   def CreatePrefixUrl(self, wildcard_suffix=None):
#   def bucket_url_string(self):
#   def url_string(self):
#   def versionless_url_string(self):
#   def __str__(self):
# def GetSchemeFromUrlString(url_str):
# def IsKnownUrlScheme(scheme_str):
# def _GetPathFromUrlString(url_str):
# def ContainsWildcard(url_string):
# def GenerationFromUrlAndString(url, generation):
# def HaveFileUrls(args_to_check):
# def HaveProviderUrls(args_to_check):
# def IsCloudSubdirPlaceholder(url, blr=None):
# def IsFileUrlString(url_str):
# def StorageUrlFromString(url_str):
# def StripOneSlash(url_str):
# def UrlsAreForSingleProvider(url_args):
# 
# Path: gslib/utils/execution_util.py
# def ExecuteExternalCommand(command_and_flags):


import os
import shutil
from gslib import storage_url
from gslib.tests import testcase
from gslib.tests import util
from gslib.tests.util import unittest
from gslib.utils import execution_util
from gslib.utils import stet_util
from unittest import mock
    source_url = storage_url.StorageUrlFromString('in')
    destination_url = storage_url.StorageUrlFromString('gs://bucket/obj')
    with util.SetBotoConfigForTest([
        ('GSUtil', 'stet_binary_path', None),
        ('GSUtil', 'stet_config_path', fake_config_path),
    ]):
      out_file_url = stet_util.encrypt_upload(source_url, destination_url,
                                              mock_logger)

    self.assertEqual(out_file_url,
                     storage_url.StorageUrlFromString('in_.stet_tmp'))
    mock_execute_external_command.assert_called_once_with([
        fake_stet_binary_path,
        'encrypt',
        '--config-file={}'.format(fake_config_path),
        '--blob-id=gs://bucket/obj',
        'in',
        'in_.stet_tmp',
    ])
    mock_logger.debug.assert_called_once_with('stderr')

    os.environ['PATH'] = previous_path

  @mock.patch.object(execution_util, 'ExecuteExternalCommand')
  def test_stet_upload_uses_no_config_if_not_provided(
      self, mock_execute_external_command):
    mock_execute_external_command.return_value = ('stdout', 'stderr')
    mock_logger = mock.Mock()

    source_url = storage_url.StorageUrlFromString('in')

# Path: gslib/storage_url.py
# PROVIDER_REGEX = re.compile(r'(?P<provider>[^:]*)://$')
# BUCKET_REGEX = re.compile(r'(?P<provider>[^:]*)://(?P<bucket>[^/]*)/{0,1}$')
# OBJECT_REGEX = re.compile(
#     r'(?P<provider>[^:]*)://(?P<bucket>[^/]*)/(?P<object>.*)')
# GS_GENERATION_REGEX = re.compile(r'(?P<object>.+)#(?P<generation>[0-9]+)$')
# S3_VERSION_REGEX = re.compile(r'(?P<object>.+)#(?P<version_id>.+)$')
# FILE_OBJECT_REGEX = re.compile(r'([^:]*://)(?P<filepath>.*)')
# WILDCARD_REGEX = re.compile(r'[*?\[\]]')
# class StorageUrl(object):
# class _FileUrl(StorageUrl):
# class _CloudUrl(StorageUrl):
#   def Clone(self):
#   def IsFileUrl(self):
#   def IsCloudUrl(self):
#   def IsStream():
#   def IsFifo(self):
#   def CreatePrefixUrl(self, wildcard_suffix=None):
#   def _WarnIfUnsupportedDoubleWildcard(self):
#   def url_string(self):
#   def versionless_url_string(self):
#   def __eq__(self, other):
#   def __hash__(self):
#   def __init__(self, url_string, is_stream=False, is_fifo=False):
#   def Clone(self):
#   def IsFileUrl(self):
#   def IsCloudUrl(self):
#   def IsStream(self):
#   def IsFifo(self):
#   def IsDirectory(self):
#   def CreatePrefixUrl(self, wildcard_suffix=None):
#   def url_string(self):
#   def versionless_url_string(self):
#   def __str__(self):
#   def __init__(self, url_string):
#   def Clone(self):
#   def IsFileUrl(self):
#   def IsCloudUrl(self):
#   def IsStream(self):
#   def IsFifo(self):
#   def IsBucket(self):
#   def IsObject(self):
#   def HasGeneration(self):
#   def IsProvider(self):
#   def CreatePrefixUrl(self, wildcard_suffix=None):
#   def bucket_url_string(self):
#   def url_string(self):
#   def versionless_url_string(self):
#   def __str__(self):
# def GetSchemeFromUrlString(url_str):
# def IsKnownUrlScheme(scheme_str):
# def _GetPathFromUrlString(url_str):
# def ContainsWildcard(url_string):
# def GenerationFromUrlAndString(url, generation):
# def HaveFileUrls(args_to_check):
# def HaveProviderUrls(args_to_check):
# def IsCloudSubdirPlaceholder(url, blr=None):
# def IsFileUrlString(url_str):
# def StorageUrlFromString(url_str):
# def StripOneSlash(url_str):
# def UrlsAreForSingleProvider(url_args):
# 
# Path: gslib/utils/execution_util.py
# def ExecuteExternalCommand(command_and_flags):


# Path: gslib/tests/test_stet_util.py
import os
import shutil
from gslib import storage_url
from gslib.tests import testcase
from gslib.tests import util
from gslib.tests.util import unittest
from gslib.utils import execution_util
from gslib.utils import stet_util
from unittest import mock

    source_url = storage_url.StorageUrlFromString('in')
    destination_url = storage_url.StorageUrlFromString('gs://bucket/obj')
    with util.SetBotoConfigForTest([
        ('GSUtil', 'stet_binary_path', None),
        ('GSUtil', 'stet_config_path', fake_config_path),
    ]):
      out_file_url = stet_util.encrypt_upload(source_url, destination_url,
                                              mock_logger)

    self.assertEqual(out_file_url,
                     storage_url.StorageUrlFromString('in_.stet_tmp'))
    mock_execute_external_command.assert_called_once_with([
        fake_stet_binary_path,
        'encrypt',
        '--config-file={}'.format(fake_config_path),
        '--blob-id=gs://bucket/obj',
        'in',
        'in_.stet_tmp',
    ])
    mock_logger.debug.assert_called_once_with('stderr')

    os.environ['PATH'] = previous_path

  @mock.patch.object(execution_util, 'ExecuteExternalCommand')
  def test_stet_upload_uses_no_config_if_not_provided(
      self, mock_execute_external_command):
    mock_execute_external_command.return_value = ('stdout', 'stderr')
    mock_logger = mock.Mock()

    source_url = storage_url.StorageUrlFromString('in')

    destination_url = storage_url.StorageUrlFromString('gs://bucket/obj')