def test_unknown(self):
     hcl_res = hcl2.loads("""
         resource "google_compute_instance_from_template" "default" {
           name                     = "instance_from_template"
           source_instance_template = google_compute_instance_template.default.id
         }
             """)
     resource_conf = hcl_res['resource'][0]['google_compute_instance_from_template']['default']
     scan_result = check.scan_resource_conf(conf=resource_conf)
     self.assertEqual(CheckResult.UNKNOWN, scan_result)
 def test_failure_1(self):
     hcl_res = hcl2.loads("""
         resource "google_compute_instance" "default" {
           name         = "test"
           machine_type = "n1-standard-1"
           zone         = "us-central1-a"
         }
             """)
     resource_conf = hcl_res['resource'][0]['google_compute_instance']['default']
     scan_result = check.scan_resource_conf(conf=resource_conf)
     self.assertEqual(CheckResult.FAILED, scan_result)
 def test_failure_3(self):
     hcl_res = hcl2.loads("""
         resource "google_compute_instance_from_template" "default" {
           name                     = "instance_from_template"
           source_instance_template = google_compute_instance_template.default.id
           service_account {
             scopes = ["userinfo-email", "compute-ro", "storage-ro"]
             email  =  "*****@*****.**"
           }
         }
             """)
     resource_conf = hcl_res['resource'][0]['google_compute_instance_from_template']['default']
     scan_result = check.scan_resource_conf(conf=resource_conf)
     self.assertEqual(CheckResult.FAILED, scan_result)
 def test_success_4(self):
     hcl_res = hcl2.loads("""
         resource "google_compute_instance_from_template" "default" {
           name                     = "instance_from_template"
           source_instance_template = google_compute_instance_template.default.id
           service_account {
             scopes = ["userinfo-email", "compute-ro", "storage-ro"]
             email  = "*****@*****.**"
           }
         }
             """)
     resource_conf = hcl_res['resource'][0]['google_compute_instance_from_template']['default']
     scan_result = check.scan_resource_conf(conf=resource_conf)
     self.assertEqual(CheckResult.PASSED, scan_result)
 def test_success_3(self):
     hcl_res = hcl2.loads("""
         resource "google_compute_instance_template" "default" {
           name         = "account"
           machine_type = "n1-standard-1"
           zone         = "us-central1-a"
           service_account {
             scopes = ["userinfo-email", "compute-ro", "storage-ro"]
             email  = "*****@*****.**"
           }
         }
             """)
     resource_conf = hcl_res['resource'][0]['google_compute_instance_template']['default']
     scan_result = check.scan_resource_conf(conf=resource_conf)
     self.assertEqual(CheckResult.PASSED, scan_result)
 def test_failure_2(self):
     hcl_res = hcl2.loads("""
         resource "google_compute_instance" "default" {
           name         = "test"
           machine_type = "n1-standard-1"
           zone         = "us-central1-a"
           service_account {
             scopes = ["userinfo-email", "compute-ro", "storage-ro"]
             email  =  "*****@*****.**"
           }
         }
             """)
     resource_conf = hcl_res['resource'][0]['google_compute_instance']['default']
     scan_result = check.scan_resource_conf(conf=resource_conf)
     self.assertEqual(CheckResult.FAILED, scan_result)