
                            S r SSKJr  SSKJr  SSKJr  SSKJr  SSKrSSKrSSKJ	r	  SSK
Jr  SS	K
Jr  SS
KJr  SSKJr  SSKJr  SSKJr  Sr\R*                  " \R,                  (       + S5       " S S\R.                  5      5       rg)zaIntegration tests for cp STET binary integration.

Could go with cp tests but that file is bulky.    )absolute_import)division)print_function)unicode_literalsN)storage_url)testcase)util)ObjectToURI)unittest)system_util)temporary_file_utilz#!/bin/sh
if [ "$#" -ne 5 ]; then
  echo "Expected 5 arguments. Got $#."
  exit 1
fi

echo "subcommand: $1
config file: $2
blob id: $3
in file: $4
out file: $5" > $5
z STET binary supports only Linux.c                   >   ^  \ rS rSrSrU 4S jrS rS rS rSr	U =r
$ )
TestStetCp2   z6Integration tests for cp integration with STET binary.c                 <  > [         [        U ]  5         U R                  [        S9U l        [        R                  " U R
                  5      n[        R                  " U R
                  UR                  [        R                  -  5        U R                  5       U l        g )Ncontents)superr   setUpCreateTempFileFAKE_STET_BINARYstet_binary_pathosstatchmodst_modeS_IEXECstet_config_path)selfcurrent_stat	__class__s     +platform/gsutil/gslib/tests/test_stet_cp.pyr   TestStetCp.setUp6   so    	*d!# //9I/JD774001LHHT""L$8$84<<$GH //1D    c                 @   U R                  5       nU R                  SS9nU R                  SSR                  U R                  5      SSR                  U R
                  5      SSU[        U5      /SS	9nU R                  S
U5        U R                  S[        U5      /SS9nU R                  SU5        U R                  SR                  U R
                  5      U5        U R                  SR                  [        U5      5      U5        U R                  SR                  U5      U5        U R                  SR                  U5      U5        U R                  [        R                  R                  [        R                  " [        R                   " U5      5      5      5        g )Nzwill be rewrittenr   -oGSUtil:stet_binary_path={}GSUtil:stet_config_path={}cp--stetTreturn_stderr/4.0 B]cat)return_stdoutzsubcommand: encryptconfig file: --config-file={}blob id: --blob-id={}in file: {}out file: {}_.stet_tmp)CreateObjectr   	RunGsUtilformatr   r   suriassertNotInassertInassertFalser   pathexistsr   GetStetTempFileNamer   StorageUrlFromString)r   
object_uri	test_filestderrstdouts        r"   'test_encrypts_upload_if_stet_is_enabled2TestStetCp.test_encrypts_upload_if_stet_is_enabled@   sl   ""$J##-@#AI^^*11$2G2GH$$++!!	#$((IZ	 +/  0F 	Y'^^UD$45T^JFMM'0MM1889N9NOMM)00j1ABFKMM-&&y16:MM*11)<fE
3300;=	>?r$   c                 v   U R                  SS9nU R                  5       nU R                  SSR                  U R                  5      SSR                  U R
                  5      SS[        U5      U/SS	9nU R                  S
U5        [        U5       nUR                  5       nS S S 5        U R                  SW5        U R                  SR                  U R
                  5      U5        U R                  SR                  [        U5      5      U5        U R                  SR                  U5      U5        U R                  SR                  U5      U5        U R                  [        R                  R                  [        R                   " ["        R$                  " U5      5      5      5        g ! , (       d  f       GN= f)Nabcr   r&   r'   r(   r)   r*   Tr+   r-   zsubcommand: decryptr0   r1   r2   r3   )r4   r   r5   r6   r   r   r7   r8   openreadr9   r:   r   r;   r<   r   r=   r   r>   )r   r?   r@   rA   file_readerdownloaded_texts         r"   )test_decrypts_download_if_stet_is_enabled4TestStetCp.test_decrypts_download_if_stet_is_enabled]   sv   ""E"2J##%I^^*11$2G2GH$$++!!	#$((Z)	 +/  0F 	Y'	iK#((*o 
MM'9MM1889N9NO!#MM)00j1AB!#MM-&&y1?CMM*11)<oN
3300;=	>? 
s   F))
F8c                    U R                  5       n[        S5       H  nU R                  USS9  M     U R                  5       n[        R
                  " SS/5         U R                  SSSR                  U R                  5      SS	R                  U R                  5      S
SSU[        U5      /
SS9nU R                  SU5        U R                  US5        SSS5        g! , (       d  f       g= f)zETests that cp does not seek-ahead for bytes if file size will change.   s   123456)tmpdirr   )GSUtiltask_estimation_threshold1)rP   task_estimation_forceTruez-mr&   r'   r(   r)   z-rr*   Tr+   z18.0 B]z
2\.\d KiB]N)CreateTempDirranger   CreateBucketr	   SetBotoConfigForTestr5   r6   r   r   r7   r8   assertRegex)r   rO   _
bucket_urirA   s        r"   4test_does_not_seek_ahead_for_bytes_if_stet_transform?TestStetCp.test_does_not_seek_ahead_for_bytes_if_stet_transform|   s    !F1X
)<  ""$J		"	"43$ 
 ~~
299##%&*,H,O,O''-)*.h
z
	 -1  2f y&) v}-+
 
 
s   A:C
C,)r   r   )__name__
__module____qualname____firstlineno____doc__r   rC   rK   r\   __static_attributes____classcell__)r!   s   @r"   r   r   2   s    >2?:?>. .r$   r   )rb   
__future__r   r   r   r   r   r   gslibr   gslib.testsr   r	   gslib.tests.utilr
   r7   r   gslib.utilsr   r   r   skipIfIS_LINUXGsUtilIntegrationTestCaser    r$   r"   <module>rn      su   2 '  % ' 	      0 % # +  
[)))+MNf.33 f. Of.r$   