Use GCS V2 API and project_id from boto config if necessary in integration_testcase#CreateBucket().
git-svn-id: svn://svn.chromium.org/gsutil/trunk/src@326 56d8b958-6b11-9cbd-d51d-67dd3ef4e9fa
diff --git a/gslib/project_id.py b/gslib/project_id.py
index ea6e604..8329c52 100644
--- a/gslib/project_id.py
+++ b/gslib/project_id.py
@@ -48,11 +48,13 @@
# We only include the project ID header if it's a GS URI and a project_id
# was specified and
- # (it's an 'mb', 'disablelogging, or 'enablelogging' command
+ # (it's an 'mb', 'disablelogging, or 'enablelogging' command or
+ # a boto request in integration tests or
# (an 'ls' command that doesn't specify a bucket or wildcarded bucket)).
if (uri.scheme.lower() == 'gs' and self.project_id
and (command == 'mb' or command == 'disablelogging'
or command == 'enablelogging'
+ or command == 'test'
or (command == 'ls' and not uri.names_bucket())
or (command == WILDCARD_BUCKET_ITERATOR))):
# Note: check for None (as opposed to "not headers") here because
diff --git a/gslib/tests/testcase/integration_testcase.py b/gslib/tests/testcase/integration_testcase.py
index b7772ee..2f82197 100644
--- a/gslib/tests/testcase/integration_testcase.py
+++ b/gslib/tests/testcase/integration_testcase.py
@@ -25,6 +25,7 @@
import boto
from boto.exception import GSResponseError
+from gslib.project_id import ProjectIdHandler
import gslib.tests.util as util
from gslib.tests.util import Retry
from gslib.tests.util import unittest
@@ -50,6 +51,11 @@
self.bucket_uris = []
self.tempdirs = []
+ # Set up API version and project ID handler.
+ self.api_version = boto.config.get_value(
+ 'GSUtil', 'default_api_version', '1')
+ self.proj_id_handler = ProjectIdHandler()
+
# Retry with an exponential backoff if a server error is received. This
# ensures that we try *really* hard to clean up after ourselves.
@Retry(GSResponseError, logger=LOGGER)
@@ -98,8 +104,14 @@
StorageUri for the created bucket.
"""
bucket_name = bucket_name or self.MakeTempName('bucket')
+
bucket_uri = boto.storage_uri('gs://%s' % bucket_name.lower(),
suppress_consec_slashes=False)
+
+ # Apply API version and project ID headers if necessary.
+ headers = {'x-goog-api-version': self.api_version}
+ self.proj_id_handler.FillInProjectHeaderIfNeeded('test', bucket_uri, headers)
+
bucket_uri.create_bucket(storage_class=storage_class)
self.bucket_uris.append(bucket_uri)
for i in range(test_objects):