示例#1
0
 def test_unknown_1(self):
     hcl_res = hcl2.loads("""
         resource "google_compute_instance_from_template" "default" {
           name         = "test"
           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)
示例#2
0
 def test_success_3(self):
     hcl_res = hcl2.loads("""
         resource "google_compute_instance_template" "default" {
           name         = "test"
           machine_type = "n1-standard-1"
           zone         = "us-central1-a"
           boot_disk {}
         }
             """)
     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)
示例#3
0
 def test_failure_2(self):
     hcl_res = hcl2.loads("""
         resource "google_compute_instance_from_template" "default" {
           name         = "test"
           source_instance_template = google_compute_instance_template.default.id
           metadata = {
              enable-oslogin = false
           }
         }
             """)
     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)
示例#4
0
 def test_failure_1(self):
     hcl_res = hcl2.loads("""
         resource "google_compute_instance_template" "default" {
           name         = "test"
           machine_type = "n1-standard-1"
           zone         = "us-central1-a"
           metadata = {
              enable-oslogin = false
           }
         }
             """)
     resource_conf = hcl_res['resource'][0][
         'google_compute_instance_template']['default']
     scan_result = check.scan_resource_conf(conf=resource_conf)
     self.assertEqual(CheckResult.FAILED, scan_result)