Skip to content

Commit

Permalink
Merge pull request googleapis#2292 from dhermes/add-new-travis-key
Browse files Browse the repository at this point in the history
Adding new Travis key.
  • Loading branch information
dhermes authored Sep 9, 2016
2 parents 3072014 + 4dfcc40 commit 49b3f1b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
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.

0 comments on commit 49b3f1b

Please sign in to comment.