@SkipForS3('S3 customer-supplied encryption keys are not supported.')
  def test_stat_encrypted_object(self):
    """Tests stat command with an encrypted object."""
    if self.test_api <= ApiSelector.XML:
      return unittest.skip(
          'gsutil does not support encryption with the XML API')
    bucket_uri = self.CreateBucket()
    object_uri = self.CreateObject(
        bucket_uri=bucket_uri, object_name='foo',
        contents=TEST_ENCRYPTION_CONTENT1, encryption_key=TEST_ENCRYPTION_KEY1)

    # Stat object with key should return unencrypted hashes.
    with SetBotoConfigForTest([
        ('GSUtil', 'encryption_key', TEST_ENCRYPTION_KEY1)]):
      stdout = self.RunGsUtil(['stat', suri(object_uri)], return_stdout=True)
      self.assertIn(TEST_ENCRYPTION_CONTENT1_MD5, stdout)
      self.assertIn(TEST_ENCRYPTION_CONTENT1_CRC32C, stdout)
      self.assertIn(TEST_ENCRYPTION_KEY1_SHA256_B64, stdout)

    # Stat object without key should return encrypted hashes.
    stdout = self.RunGsUtil(['stat', suri(object_uri)], return_stdout=True)
    self.assertNotIn(TEST_ENCRYPTION_CONTENT1_MD5, stdout)
    self.assertNotIn(TEST_ENCRYPTION_CONTENT1_CRC32C, stdout)
    self.assertIn('encrypted', stdout)
    self.assertIn(TEST_ENCRYPTION_KEY1_SHA256_B64, stdout)
dataset/ETHPy150Open GoogleCloudPlatform/gsutil/gslib/tests/test_stat.py/TestStat.test_stat_encrypted_object/operator `==` -> `<=`