Add option to overwrite transfer URLs with a client's base URL. (#306)
Needed because FromData and InitializeUpload methods sometimes ignore
custom endpoints set by the client.
Test environment was a bit broken, but Python 2.7 tests passed. Python 3
tests had a few unrelated failures probably related to the fact that my
Python3.5 version was having SSL issues. Ended up running the tests with
Python3.9. Failures:
```
ERROR: Testing pickling and unpickling of FieldList instances.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/google/home/hartunian/Desktop/apitools/apitools/base/protorpclite/messages_test.py", line 511, in testPickle
unpickled = pickle.loads(pickle.dumps(field_list))
File "/usr/local/google/home/hartunian/Desktop/apitools/apitools/base/protorpclite/messages.py", line 1147, in extend
self.__field.validate(sequence)
AttributeError: 'FieldList' object has no attribute '_FieldList__field'
======================================================================
ERROR: Testing pickling and unpickling of Message instances.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/google/home/hartunian/Desktop/apitools/apitools/base/protorpclite/messages_test.py", line 1876, in testPickle
unpickled = pickle.loads(pickle.dumps(message))
File "/usr/local/google/home/hartunian/Desktop/apitools/apitools/base/protorpclite/messages.py", line 1147, in extend
self.__field.validate(sequence)
AttributeError: 'FieldList' object has no attribute '_FieldList__field'
======================================================================
FAIL: Test decoding improperly encoded base64 bytes value.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/google/home/hartunian/Desktop/apitools/apitools/base/protorpclite/protojson.py", line 324, in decode_field
return base64.b64decode(value)
File "/usr/lib/python3.9/base64.py", line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Invalid base64-encoded string: number of data characters (17) cannot be 1 more than a multiple of 4
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/google/home/hartunian/Desktop/apitools/apitools/base/protorpclite/test_util.py", line 70, in assertRaisesWithRegexpMatch
function(*params, **kwargs)
File "/usr/local/google/home/hartunian/Desktop/apitools/apitools/base/protorpclite/protojson.py", line 214, in decode_message
message = self.__decode_dictionary(message_type, dictionary)
apitools.base.protorpclite.messages.DecodeError: Base64 decoding error: Invalid base64-encoded string: number of data characters (17) cannot be 1 more than a multiple of 4
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/google/home/hartunian/Desktop/apitools/apitools/base/protorpclite/protojson_test.py", line 441, in testDecodeBadBase64BytesField
self.assertRaisesWithRegexpMatch(
File "/usr/local/google/home/hartunian/Desktop/apitools/apitools/base/protorpclite/test_util.py", line 75, in assertRaisesWithRegexpMatch
self.assertTrue(match, 'Expected match "%s", found "%s"' % (regexp,
AssertionError: False is not true : Expected match "Base64 decoding error: Incorrect padding", found "Base64 decoding error: Invalid base64-encoded string: number of data characters (17) cannot be 1 more than a multiple of 4"
======================================================================
FAIL: testConvertIdThatNeedsEscaping (apitools.base.py.batch_test.BatchTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/google/home/hartunian/Desktop/apitools/apitools/base/py/batch_test.py", line 360, in testConvertIdThatNeedsEscaping
self._DoTestConvertIdToHeader('~tilde1', '<%s+%%7Etilde1>')
File "/usr/local/google/home/hartunian/Desktop/apitools/apitools/base/py/batch_test.py", line 352, in _DoTestConvertIdToHeader
self.assertEqual(
AssertionError: '<30037b18-267d-4e07-9ac8-bc3c8da9a959+%7Etilde1>' != '<30037b18-267d-4e07-9ac8-bc3c8da9a959+~tilde1>'
- <30037b18-267d-4e07-9ac8-bc3c8da9a959+%7Etilde1>
? ^^^
+ <30037b18-267d-4e07-9ac8-bc3c8da9a959+~tilde1>
```4 files changed