Skip to content

Commit 49b3f1b

Browse files
authored
Merge pull request #2292 from dhermes/add-new-travis-key
Adding new Travis key.
2 parents 3072014 + 4dfcc40 commit 49b3f1b

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

google/cloud/credentials.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,15 @@ def get_credentials():
6262
6363
{
6464
'type': 'service_account',
65-
'client_id': '...',
66-
'client_email': '...',
65+
'project_id': '...',
6766
'private_key_id': '...',
68-
'private_key': '...'
67+
'private_key': '...',
68+
'client_email': '...',
69+
'client_id': '...',
70+
'auth_uri': '...',
71+
'token_uri': '...',
72+
'auth_provider_x509_cert_url': '...',
73+
'client_x509_cert_url': '...'
6974
}
7075
7176
The second of these is simply a JSON key downloaded from the Google APIs

system_tests/attempt_system_tests.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,37 @@
1919
2020
If being run as part of a Travis build for a merged commit, the
2121
encrypted `key.json` file need be decrypted before running tests.
22+
23+
Before encrypting:
24+
25+
* Visit ``https://github.com/settings/tokens/new``, get a token,
26+
and store the token in travis.token file.
27+
* Visit
28+
``https://console.cloud.google.com/apis/credentials?project={PROJ}``
29+
* Click "Create credentials >> Service account key", select your
30+
service account and create a JSON key (we'll call it ``key.json``)
31+
32+
Encrypt the file via::
33+
34+
$ travis login --github-token=$(cat travis.token)
35+
$ travis encrypt-file --repo=GoogleCloudPlatform/google-cloud-python key.json
36+
37+
After running ``travis encrypt-file``, take note of the ``openssl`` command
38+
printed out. In particular, it'll give the name of the key and
39+
IV (initialization vector) environment variables added to the Travis
40+
project.
41+
42+
See:
43+
https://docs.travis-ci.com/user/encrypting-files/
2244
"""
2345

2446

2547
import os
2648
import subprocess
2749
import sys
2850

51+
from google.cloud.environment_vars import CREDENTIALS
52+
2953
from run_system_test import FailedSystemTestModule
3054
from run_system_test import run_module_tests
3155

@@ -46,6 +70,8 @@
4670
SCRIPTS_DIR = os.path.dirname(__file__)
4771
ROOT_DIR = os.path.abspath(os.path.join(SCRIPTS_DIR, '..'))
4872
ENCRYPTED_KEYFILE = os.path.join(ROOT_DIR, 'system_tests', 'key.json.enc')
73+
ENCRYPTED_KEY_ENV = 'encrypted_c16407eb06cc_key'
74+
ENCRYPTED_INIT_VECTOR_ENV = 'encrypted_c16407eb06cc_iv'
4975

5076

5177
def check_environment():
@@ -73,9 +99,9 @@ def decrypt_keyfile():
7399
print('Running in Travis during merge, decrypting stored '
74100
'key file.')
75101

76-
encrypted_key = os.getenv('encrypted_a1b222e8c14d_key')
77-
encrypted_iv = os.getenv('encrypted_a1b222e8c14d_iv')
78-
out_file = os.getenv('GOOGLE_APPLICATION_CREDENTIALS')
102+
encrypted_key = os.getenv(ENCRYPTED_KEY_ENV)
103+
encrypted_iv = os.getenv(ENCRYPTED_INIT_VECTOR_ENV)
104+
out_file = os.getenv(CREDENTIALS)
79105
# Convert encrypted key file into decrypted file to be used.
80106
subprocess.call([
81107
'openssl', 'aes-256-cbc',

system_tests/key.json.enc

1.17 KB
Binary file not shown.

0 commit comments

Comments
 (0)