# 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):


import os
import stat
from gslib import storage_url
from gslib.tests import testcase
from gslib.tests import util
from gslib.tests.util import ObjectToURI as suri
from gslib.tests.util import unittest
from gslib.utils import system_util
from gslib.utils import temporary_file_util

  def test_decrypts_download_if_stet_is_enabled(self):
    object_uri = self.CreateObject(contents='abc')
    test_file = self.CreateTempFile()

    stderr = self.RunGsUtil([
        '-o', 'GSUtil:stet_binary_path={}'.format(self.stet_binary_path), '-o',
        'GSUtil:stet_config_path={}'.format(
            self.stet_config_path), 'cp', '--stet',
        suri(object_uri), test_file
    ],
                            return_stderr=True)

    # Progress indicator should show transformed file size (variable based on
    # random string generation above). 4.0 B is the pre-transform size.
    self.assertNotIn('/4.0 B]', stderr)

    with open(test_file) as file_reader:
      downloaded_text = file_reader.read()
    self.assertIn('subcommand: decrypt', downloaded_text)
    self.assertIn('config file: --config-file={}'.format(self.stet_config_path),
                  downloaded_text)
    self.assertIn('blob id: --blob-id={}'.format(suri(object_uri)),
                  downloaded_text)
    self.assertIn('in file: {}'.format(test_file), downloaded_text)
    self.assertIn('out file: {}_.stet_tmp'.format(test_file), downloaded_text)

    self.assertFalse(
        os.path.exists(
            temporary_file_util.GetStetTempFileName(

# 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/tests/test_stet_cp.py
import os
import stat
from gslib import storage_url
from gslib.tests import testcase
from gslib.tests import util
from gslib.tests.util import ObjectToURI as suri
from gslib.tests.util import unittest
from gslib.utils import system_util
from gslib.utils import temporary_file_util


  def test_decrypts_download_if_stet_is_enabled(self):
    object_uri = self.CreateObject(contents='abc')
    test_file = self.CreateTempFile()

    stderr = self.RunGsUtil([
        '-o', 'GSUtil:stet_binary_path={}'.format(self.stet_binary_path), '-o',
        'GSUtil:stet_config_path={}'.format(
            self.stet_config_path), 'cp', '--stet',
        suri(object_uri), test_file
    ],
                            return_stderr=True)

    # Progress indicator should show transformed file size (variable based on
    # random string generation above). 4.0 B is the pre-transform size.
    self.assertNotIn('/4.0 B]', stderr)

    with open(test_file) as file_reader:
      downloaded_text = file_reader.read()
    self.assertIn('subcommand: decrypt', downloaded_text)
    self.assertIn('config file: --config-file={}'.format(self.stet_config_path),
                  downloaded_text)
    self.assertIn('blob id: --blob-id={}'.format(suri(object_uri)),
                  downloaded_text)
    self.assertIn('in file: {}'.format(test_file), downloaded_text)
    self.assertIn('out file: {}_.stet_tmp'.format(test_file), downloaded_text)

    self.assertFalse(
        os.path.exists(
            temporary_file_util.GetStetTempFileName(

                storage_url.StorageUrlFromString(test_file))))