Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a3d36ed

Browse filesBrowse files
author
Jon Wayne Parrott
committed
Adding test for customer-supplied disk encryption key. Fixes GoogleCloudPlatform#281 (GoogleCloudPlatform#342)
1 parent d5cffb7 commit a3d36ed
Copy full SHA for a3d36ed

File tree

Expand file treeCollapse file tree

1 file changed

+32
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+32
-0
lines changed

‎compute/encryption/generate_wrapped_rsa_key_test.py

Copy file name to clipboardExpand all lines: compute/encryption/generate_wrapped_rsa_key_test.py
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,40 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313

14+
import os
15+
1416
import generate_wrapped_rsa_key
17+
from googleapiclient import discovery
18+
from oauth2client.client import GoogleCredentials
1519

1620

1721
def test_main():
1822
generate_wrapped_rsa_key.main(None)
23+
24+
25+
def test_create_disk(cloud_config):
26+
credentials = GoogleCredentials.get_application_default()
27+
compute = discovery.build('compute', 'beta', credentials=credentials)
28+
29+
# Generate the key.
30+
key_bytes = os.urandom(32)
31+
google_public_key = generate_wrapped_rsa_key.get_google_public_cert_key()
32+
wrapped_rsa_key = generate_wrapped_rsa_key.wrap_rsa_key(
33+
google_public_key, key_bytes)
34+
35+
# Create the disk, if the encryption key is invalid, this will raise.
36+
compute.disks().insert(
37+
project=cloud_config.project,
38+
zone='us-central1-f',
39+
body={
40+
'name': 'new-encrypted-disk',
41+
'diskEncryptionKey': {
42+
'rsaEncryptedKey': wrapped_rsa_key.decode('utf-8')
43+
}
44+
}).execute()
45+
46+
# Delete the disk.
47+
compute.disks().delete(
48+
project=cloud_config.project,
49+
zone='us-central1-f',
50+
disk='new-encrypted-disk').execute()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.