def test_from_dict_bad_private_key():
    info = SERVICE_ACCOUNT_INFO.copy()
    info["private_key"] = "garbage"

    with pytest.raises(ValueError) as excinfo:
        _service_account_info.from_dict(info)

    assert excinfo.match(r"key")
def test_from_dict_bad_private_key():
    info = SERVICE_ACCOUNT_INFO.copy()
    info['private_key'] = 'garbage'

    with pytest.raises(ValueError) as excinfo:
        _service_account_info.from_dict(info)

    assert excinfo.match(r'No key could be detected')
Ejemplo n.º 3
0
  def from_service_account_info(cls, info, **kwargs):
    """Creates an OnDemandCredentials instance from a dictionary.

        Args:
            info (Mapping[str, str]): The service account info in Google format.
            kwargs: Additional arguments to pass to the constructor.

        Returns:
            google.auth.jwt.OnDemandCredentials: The constructed credentials.

        Raises:
            ValueError: If the info is not in the expected format.
        """
    signer = _service_account_info.from_dict(info, require=['client_email'])
    return cls._from_signer_and_info(signer, info, **kwargs)
Ejemplo n.º 4
0
    def from_service_account_info(cls, info, **kwargs):
        """Creates an OnDemandCredentials instance from a dictionary.

        Args:
            info (Mapping[str, str]): The service account info in Google
                format.
            kwargs: Additional arguments to pass to the constructor.

        Returns:
            google.auth.jwt.OnDemandCredentials: The constructed credentials.

        Raises:
            ValueError: If the info is not in the expected format.
        """
        signer = _service_account_info.from_dict(
            info, require=['client_email'])
        return cls._from_signer_and_info(signer, info, **kwargs)
def test_from_dict_bad_format():
    with pytest.raises(ValueError) as excinfo:
        _service_account_info.from_dict({}, require=("meep", ))

    assert excinfo.match(r"missing fields")
def test_from_dict():
    signer = _service_account_info.from_dict(SERVICE_ACCOUNT_INFO)
    assert isinstance(signer, crypt.RSASigner)
    assert signer.key_id == SERVICE_ACCOUNT_INFO["private_key_id"]
def test_from_dict_bad_format():
    with pytest.raises(ValueError) as excinfo:
        _service_account_info.from_dict({})

    assert excinfo.match(r'missing fields')