Conversation
google/auth/__init__.py
Outdated
|
|
||
|
|
||
| __all__ = [ | ||
| 'default' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @@ -0,0 +1,295 @@ | |||
| # Copyright 2015 Google Inc. | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/_default.py
Outdated
|
|
||
| """Application default credentials. | ||
|
|
||
| Implementes application default credentials and project ID detection.""" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/_default.py
Outdated
| # Environment variable for explicit application default credentials and project | ||
| # ID. | ||
| _CREDENTIALS_ENV = 'GOOGLE_APPLICATION_CREDENTIALS' | ||
| _PROJECT_ENV = 'GCLOUD_PROJECT' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/_default.py
Outdated
| # The ~/.config subdirectory containing gcloud credentials. | ||
| _CLOUDSDK_CONFIG_DIRECTORY = 'gcloud' | ||
| # The environment variable name which can replace ~/.config if set. | ||
| _CLOUDSDK_CONFIG_ENV = 'CLOUDSDK_CONFIG' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| def test__load_credentials_from_file_invalid_type(tmpdir): | ||
| jsonfile = tmpdir.join('invalid.json') | ||
| jsonfile.write(json.dumps({'type': 'not-a-real-type'})) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| assert project_id == SERVICE_ACCOUNT_FILE_DATA['project_id'] | ||
|
|
||
|
|
||
| @mock.patch.dict(os.environ, {}, clear=True) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
tests/test__default.py
Outdated
|
|
||
| LOAD_FILE_PATCH = mock.patch( | ||
| 'google.auth._default._load_credentials_from_file', return_value=( | ||
| mock.sentinel.credentials, mock.sentinel.project_id)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
|
|
||
| @LOAD_FILE_PATCH | ||
| def test__get_explicit_environ_credentials(mock_load, monkeypatch): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
tests/test__default.py
Outdated
| config_path = _default._get_gcloud_sdk_config_path() | ||
|
|
||
| assert os.path.split(config_path) == ( | ||
| 'appdata', _default._CLOUDSDK_CONFIG_DIRECTORY) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| If the Cloud SDK has an active project, the project ID is returned. The | ||
| active project can be set using:: | ||
|
|
||
| gcloud config set project |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| _get_gcloud_sdk_credentials, | ||
| _get_gae_credentials, | ||
| _get_gce_credentials) | ||
| lambda: _get_gce_credentials(request)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @@ -0,0 +1,295 @@ | |||
| # Copyright 2015 Google Inc. | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/_default.py
Outdated
| # Environment variable for explicit application default credentials and project | ||
| # ID. | ||
| _CREDENTIALS_ENV = 'GOOGLE_APPLICATION_CREDENTIALS' | ||
| _PROJECT_ENV = 'GCLOUD_PROJECT' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/_default.py
Outdated
| # The ~/.config subdirectory containing gcloud credentials. | ||
| _CLOUDSDK_CONFIG_DIRECTORY = 'gcloud' | ||
| # The environment variable name which can replace ~/.config if set. | ||
| _CLOUDSDK_CONFIG_ENV = 'CLOUDSDK_CONFIG' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/_default.py
Outdated
| 'Could not automatically determine credentials. Please set {env} or ' | ||
| 'explicitly create credential and re-run the application. For more ' | ||
| 'information, please see https://developers.google.com/accounts/docs' | ||
| '/application-default-credentials.'.format(env=_CREDENTIALS_ENV)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/_default.py
Outdated
| refresh_token=info['refresh_token'], | ||
| token_uri=_GOOGLE_OAUTH2_TOKEN_ENDPOINT, | ||
| client_id=info['client_id'], | ||
| client_secret=info['client_secret']) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| if credential_type == _SERVICE_ACCOUNT_TYPE: | ||
| credentials = service_account.Credentials.from_service_account_info( | ||
| info) | ||
| return credentials, info.get('project_id') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| def test__load_credentials_from_file_invalid_type(tmpdir): | ||
| jsonfile = tmpdir.join('invalid.json') | ||
| jsonfile.write(json.dumps({'type': 'not-a-real-type'})) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
|
|
||
| @LOAD_FILE_PATCH | ||
| def test__get_explicit_environ_credentials(mock_load, monkeypatch): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| If the Cloud SDK has an active project, the project ID is returned. The | ||
| active project can be set using:: | ||
|
|
||
| gcloud config set project |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/_default.py
Outdated
| Could not automatically determine credentials. Please set {env} or ' | ||
| explicitly create credential and re-run the application. For more ' | ||
| information, please see ' | ||
| 'https://developers.google.com/accounts/docs/application-default-credentials. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/environment_vars.py
Outdated
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Environment variables used by google.auth.""" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/environment_vars.py
Outdated
|
|
||
|
|
||
| PROJECT = 'GOOGLE_CLOUD_PROJECT' | ||
| """Environment variable defining default project.""" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
tests/test__default.py
Outdated
|
|
||
|
|
||
| def test__load_credentials_from_file_authorized_user_bad_format(tmpdir): | ||
| filename = tmpdir.join('authoirzed_user_bad.json') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
LGTM pending my few tiny nits |
No description provided.