Skip to content

Commit

Permalink
Fix test comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
zachberger authored and danawillow committed May 10, 2019
1 parent b208ef5 commit 1d9fed9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions third_party/terraform/tests/resource_compute_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1451,8 +1451,11 @@ func testAccCheckComputeInstanceDiskKmsEncryptionKey(n string, instance *compute
} else {
if disk.DiskEncryptionKey != nil {
expectedKey := diskNameToEncryptionKey[GetResourceNameFromSelfLink(disk.Source)].KmsKeyName
if disk.DiskEncryptionKey.KmsKeyName != expectedKey {
return fmt.Errorf("Disk %d has unexpected encryption key in GCP.\nExpected: %s\nActual: %s", i, expectedKey, disk.DiskEncryptionKey.Sha256)
// The response for crypto keys often includes the version of the key which needs to be removed
// format: projects/<project>/locations/<region>/keyRings/<keyring>/cryptoKeys/<key>/cryptoKeyVersions/1
actualKey := strings.Split(disk.DiskEncryptionKey.KmsKeyName, "/cryptoKeyVersions")[0]
if actualKey != expectedKey {
return fmt.Errorf("Disk %d has unexpected encryption key in GCP.\nExpected: %s\nActual: %s", i, expectedKey, actualKey)
}
}
}
Expand Down

0 comments on commit 1d9fed9

Please sign in to comment.