Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new Travis key. #2292

Merged
merged 1 commit into from
Sep 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions google/cloud/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,15 @@ def get_credentials():
{
'type': 'service_account',
'client_id': '...',
'client_email': '...',
'project_id': '...',
'private_key_id': '...',
'private_key': '...'
'private_key': '...',
'client_email': '...',
'client_id': '...',
'auth_uri': '...',
'token_uri': '...',
'auth_provider_x509_cert_url': '...',
'client_x509_cert_url': '...'
}
The second of these is simply a JSON key downloaded from the Google APIs
Expand Down
32 changes: 29 additions & 3 deletions system_tests/attempt_system_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,37 @@
If being run as part of a Travis build for a merged commit, the
encrypted `key.json` file need be decrypted before running tests.
Before encrypting:
* Visit ``https://github.com/settings/tokens/new``, get a token,
and store the token in travis.token file.
* Visit
``https://console.cloud.google.com/apis/credentials?project={PROJ}``
* Click "Create credentials >> Service account key", select your
service account and create a JSON key (we'll call it ``key.json``)
Encrypt the file via::
$ travis login --github-token=$(cat travis.token)
$ travis encrypt-file --repo=GoogleCloudPlatform/google-cloud-python key.json
After running ``travis encrypt-file``, take note of the ``openssl`` command
printed out. In particular, it'll give the name of the key and
IV (initialization vector) environment variables added to the Travis
project.
See:
https://docs.travis-ci.com/user/encrypting-files/
"""


import os
import subprocess
import sys

from google.cloud.environment_vars import CREDENTIALS

from run_system_test import FailedSystemTestModule
from run_system_test import run_module_tests

Expand All @@ -46,6 +70,8 @@
SCRIPTS_DIR = os.path.dirname(__file__)
ROOT_DIR = os.path.abspath(os.path.join(SCRIPTS_DIR, '..'))
ENCRYPTED_KEYFILE = os.path.join(ROOT_DIR, 'system_tests', 'key.json.enc')
ENCRYPTED_KEY_ENV = 'encrypted_c16407eb06cc_key'
ENCRYPTED_INIT_VECTOR_ENV = 'encrypted_c16407eb06cc_iv'


def check_environment():
Expand Down Expand Up @@ -73,9 +99,9 @@ def decrypt_keyfile():
print('Running in Travis during merge, decrypting stored '
'key file.')

encrypted_key = os.getenv('encrypted_a1b222e8c14d_key')
encrypted_iv = os.getenv('encrypted_a1b222e8c14d_iv')
out_file = os.getenv('GOOGLE_APPLICATION_CREDENTIALS')
encrypted_key = os.getenv(ENCRYPTED_KEY_ENV)
encrypted_iv = os.getenv(ENCRYPTED_INIT_VECTOR_ENV)
out_file = os.getenv(CREDENTIALS)
# Convert encrypted key file into decrypted file to be used.
subprocess.call([
'openssl', 'aes-256-cbc',
Expand Down
Binary file modified system_tests/key.json.enc
Binary file not shown.