def test_get_credentials_no_credfile_default_loc():
    test_def_config = os.path.expanduser('~/.config/gce/foo.json')
    try:
        gceutils.get_credentials('foo')
    except GCEProjectCredentialsException as ex:
        expected_msg = '"%s" credentials not found' % test_def_config
        assert expected_msg == format(ex)
def test_get_credentials_no_args():
    try:
        gceutils.get_credentials()
    except GCEProjectCredentialsException as ex:
        expected_msg = 'Either project name or credentials file path must '
        expected_msg += 'be given'
        assert expected_msg == format(ex)
def test_get_credentials_format_error():
    cred_file = data_path + '/fake_credentials.json'
    try:
        gceutils.get_credentials(credentials_file=cred_file)
    except GCEProjectCredentialsException as ex:
        expected_msg = 'Could not extract credentials from "{cred_file}": ' \
                       'Service account info was not in the ' \
                       'expected format'.format(cred_file=cred_file)
        assert expected_msg in format(ex)
Esempio n. 4
0
    def credentials(self):
        if not self._credentials:
            self._credentials = utils.get_credentials(
                self.project,
                self.credentials_path
            )

        return self._credentials
def test_get_credentials_no_credfile():
    try:
        gceutils.get_credentials(credentials_file='foo')
    except GCEProjectCredentialsException as ex:
        expected_msg = 'Provided credentials file "foo" not found'
        assert expected_msg == format(ex)