Ejemplo n.º 1
0
 def test_p12_type_non_bytes_to_sign(self):
     from oauth2client.service_account import ServiceAccountCredentials
     ACCOUNT_NAME = 'dummy_service_account_name'
     PRIVATE_KEY_TEXT = b'dummy_private_key_text'
     STRING_TO_SIGN = u'dummy_signature'
     SIGNER = object()
     CREDENTIALS = ServiceAccountCredentials(ACCOUNT_NAME, SIGNER)
     CREDENTIALS._private_key_pkcs12 = PRIVATE_KEY_TEXT
     CREDENTIALS._private_key_password = '******'
     self._run_with_fake_crypto(CREDENTIALS, PRIVATE_KEY_TEXT,
                                STRING_TO_SIGN)
Ejemplo n.º 2
0
 def test_p12_type_non_bytes_to_sign(self):
     from oauth2client.service_account import ServiceAccountCredentials
     ACCOUNT_NAME = 'dummy_service_account_name'
     PRIVATE_KEY_TEXT = b'dummy_private_key_text'
     STRING_TO_SIGN = u'dummy_signature'
     SIGNER = object()
     CREDENTIALS = ServiceAccountCredentials(
         ACCOUNT_NAME, SIGNER)
     CREDENTIALS._private_key_pkcs12 = PRIVATE_KEY_TEXT
     CREDENTIALS._private_key_password = '******'
     self._run_with_fake_crypto(CREDENTIALS, PRIVATE_KEY_TEXT,
                                STRING_TO_SIGN)
Ejemplo n.º 3
0
 def _make_credentials(self):
     private_key = datafile('privatekey.' + self.format_)
     signer = crypt.Signer.from_string(private_key)
     credentials = ServiceAccountCredentials(
         '*****@*****.**', signer,
         scopes='read+write',
         sub='*****@*****.**')
     if self.format_ == 'pem':
         credentials._private_key_pkcs8_pem = private_key
     elif self.format_ == 'p12':
         credentials._private_key_pkcs12 = private_key
         credentials._private_key_password = _PASSWORD_DEFAULT
     else:  # pragma: NO COVER
         raise ValueError('Unexpected format.')
     return credentials