# Path: gslib/tests/testcase/integration_testcase.py
# def SkipForGS(reason):
#   if not RUN_S3_TESTS:
#     return unittest.skip(reason)
#   else:
#     return lambda func: func
# 
# Path: gslib/tests/testcase/integration_testcase.py
# def SkipForJSON(reason):
#   if USING_JSON_API:
#     return unittest.skip(reason)
#   else:
#     return lambda func: func
# 
# Path: gslib/tests/testcase/integration_testcase.py
# def SkipForXML(reason):
#   """Skips the test if running S3 tests, or if prefer_api isn't set to json."""
#   if not USING_JSON_API or RUN_S3_TESTS:
#     return unittest.skip(reason)
#   else:
#     return lambda func: func


import gslib.tests.testcase as testcase
from gslib.tests.testcase.integration_testcase import SkipForGS
from gslib.tests.testcase.integration_testcase import SkipForJSON
from gslib.tests.testcase.integration_testcase import SkipForXML
from gslib.tests.util import ObjectToURI as suri
from gslib.tests.util import SetBotoConfigForTest
    self.RunGsUtil(self._set_pap_cmd + ['inherited', suri(bucket_uri)])
    self.VerifyPublicAccessPreventionValue(bucket_uri, 'inherited')

  @SkipForXML('Public access prevention only runs on GCS JSON API')
  def test_turning_on(self):
    bucket_uri = self.CreateBucket()
    self.RunGsUtil(self._set_pap_cmd + ['enforced', suri(bucket_uri)])
    self.VerifyPublicAccessPreventionValue(bucket_uri, 'enforced')

  @SkipForXML('Public access prevention only runs on GCS JSON API')
  def test_turning_on_and_off(self):
    bucket_uri = self.CreateBucket()

    self.RunGsUtil(self._set_pap_cmd + ['enforced', suri(bucket_uri)])
    self.VerifyPublicAccessPreventionValue(bucket_uri, 'enforced')

    self.RunGsUtil(self._set_pap_cmd + ['inherited', suri(bucket_uri)])
    self.VerifyPublicAccessPreventionValue(bucket_uri, 'inherited')

  @SkipForXML('Public access prevention only runs on GCS JSON API')
  def test_multiple_buckets(self):
    bucket_uri1 = self.CreateBucket()
    bucket_uri2 = self.CreateBucket()
    stdout = self.RunGsUtil(
        self._get_pap_cmd +
        [suri(bucket_uri1), suri(bucket_uri2)],
        return_stdout=True)
    self.assertRegex(stdout, r'%s:\s+inherited' % suri(bucket_uri1))
    self.assertRegex(stdout, r'%s:\s+inherited' % suri(bucket_uri2))


# Path: gslib/tests/testcase/integration_testcase.py
# def SkipForGS(reason):
#   if not RUN_S3_TESTS:
#     return unittest.skip(reason)
#   else:
#     return lambda func: func
# 
# Path: gslib/tests/testcase/integration_testcase.py
# def SkipForJSON(reason):
#   if USING_JSON_API:
#     return unittest.skip(reason)
#   else:
#     return lambda func: func
# 
# Path: gslib/tests/testcase/integration_testcase.py
# def SkipForXML(reason):
#   """Skips the test if running S3 tests, or if prefer_api isn't set to json."""
#   if not USING_JSON_API or RUN_S3_TESTS:
#     return unittest.skip(reason)
#   else:
#     return lambda func: func


# Path: gslib/tests/test_pap.py
import gslib.tests.testcase as testcase
from gslib.tests.testcase.integration_testcase import SkipForGS
from gslib.tests.testcase.integration_testcase import SkipForJSON
from gslib.tests.testcase.integration_testcase import SkipForXML
from gslib.tests.util import ObjectToURI as suri
from gslib.tests.util import SetBotoConfigForTest

    self.RunGsUtil(self._set_pap_cmd + ['inherited', suri(bucket_uri)])
    self.VerifyPublicAccessPreventionValue(bucket_uri, 'inherited')

  @SkipForXML('Public access prevention only runs on GCS JSON API')
  def test_turning_on(self):
    bucket_uri = self.CreateBucket()
    self.RunGsUtil(self._set_pap_cmd + ['enforced', suri(bucket_uri)])
    self.VerifyPublicAccessPreventionValue(bucket_uri, 'enforced')

  @SkipForXML('Public access prevention only runs on GCS JSON API')
  def test_turning_on_and_off(self):
    bucket_uri = self.CreateBucket()

    self.RunGsUtil(self._set_pap_cmd + ['enforced', suri(bucket_uri)])
    self.VerifyPublicAccessPreventionValue(bucket_uri, 'enforced')

    self.RunGsUtil(self._set_pap_cmd + ['inherited', suri(bucket_uri)])
    self.VerifyPublicAccessPreventionValue(bucket_uri, 'inherited')

  @SkipForXML('Public access prevention only runs on GCS JSON API')
  def test_multiple_buckets(self):
    bucket_uri1 = self.CreateBucket()
    bucket_uri2 = self.CreateBucket()
    stdout = self.RunGsUtil(
        self._get_pap_cmd +
        [suri(bucket_uri1), suri(bucket_uri2)],
        return_stdout=True)
    self.assertRegex(stdout, r'%s:\s+inherited' % suri(bucket_uri1))
    self.assertRegex(stdout, r'%s:\s+inherited' % suri(bucket_uri2))


  @SkipForJSON('Testing XML only behavior')