TEST(HealthCheckProto, Validation) {
  {
    const std::string yaml = R"EOF(
    timeout: 1s
    interval: 1s
    healthy_threshold: 1
    unhealthy_threshold: 1
    no_traffic_interval: 0s
    http_health_check:
      service_name_matcher:
        prefix: locations
      path: /healthcheck
    )EOF";
    envoy::config::core::v3::HealthCheck health_check_proto;
    EXPECT_THROW_WITH_REGEX(TestUtility::validate(parseHealthCheckFromV3Yaml(yaml)), EnvoyException,
                            "Proto constraint validation failed.*value must be greater than.*");
  }
  {
    const std::string yaml = R"EOF(
    timeout: 1s
    interval: 1s
    healthy_threshold: 1
    unhealthy_threshold: 1
    unhealthy_interval: 0s
    http_health_check:
      service_name_matcher:
        prefix: locations
      path: /healthcheck
    )EOF";
    envoy::config::core::v3::HealthCheck health_check_proto;
    EXPECT_THROW_WITH_REGEX(TestUtility::validate(parseHealthCheckFromV3Yaml(yaml)), EnvoyException,
                            "Proto constraint validation failed.*value must be greater than.*");
  }
  {
    const std::string yaml = R"EOF(
    timeout: 1s
    interval: 1s
    healthy_threshold: 1
    unhealthy_threshold: 1
    unhealthy_edge_interval: 0s
    http_health_check:
      service_name_matcher:
        prefix: locations
      path: /healthcheck
    )EOF";
    envoy::config::core::v3::HealthCheck health_check_proto;
    EXPECT_THROW_WITH_REGEX(TestUtility::validate(parseHealthCheckFromV3Yaml(yaml)), EnvoyException,
                            "Proto constraint validation failed.*value must be greater than.*");
  }
  {
    const std::string yaml = R"EOF(
    timeout: 1s
    interval: 1s
    healthy_threshold: 1
    unhealthy_threshold: 1
    healthy_edge_interval: 0s
    http_health_check:
      service_name_matcher:
        prefix: locations
      path: /healthcheck
    )EOF";
    envoy::config::core::v3::HealthCheck health_check_proto;
    EXPECT_THROW_WITH_REGEX(TestUtility::validate(parseHealthCheckFromV3Yaml(yaml)), EnvoyException,
                            "Proto constraint validation failed.*value must be greater than.*");
  }
  {
    const std::string yaml = R"EOF(
    timeout: 1s
    interval: 1s
    unhealthy_threshold: 1
    http_health_check:
      service_name_matcher:
        prefix: locations
      path: /healthcheck
    )EOF";
    envoy::config::core::v3::HealthCheck health_check_proto;
    EXPECT_THROW_WITH_REGEX(TestUtility::validate(parseHealthCheckFromV3Yaml(yaml)), EnvoyException,
                            "Proto constraint validation failed.*value is required.*");
  }
  {
    const std::string yaml = R"EOF(
    timeout: 1s
    interval: 1s
    healthy_threshold: 1
    http_health_check:
      service_name_matcher:
        prefix: locations
      path: /healthcheck
    )EOF";
    envoy::config::core::v3::HealthCheck health_check_proto;
    EXPECT_THROW_WITH_REGEX(TestUtility::validate(parseHealthCheckFromV3Yaml(yaml)), EnvoyException,
                            "Proto constraint validation failed.*value is required.*");
  }
}
TEST(HealthCheckProto, Validation) {
  {
    const std::string yaml = R"EOF(
    timeout: 1s
    interval: 1s
    healthy_threshold: 1
    unhealthy_threshold: 1
    no_traffic_interval: 0s
    http_health_check:
      service_name_matcher:
        prefix: locations
      path: /healthcheck
    )EOF";
    envoy::config::core::v3::HealthCheck health_check_proto;
    EXPECT_THROW_WITH_REGEX(TestUtility::validate(parseHealthCheckFromV3Yaml(yaml)), EnvoyException,
                            "Proto constraint validation failed.*value must be greater than.*");
  }
  {
    const std::string yaml = R"EOF(
    timeout: 1s
    interval: 1s
    healthy_threshold: 1
    unhealthy_threshold: 1
    unhealthy_interval: 0s
    http_health_check:
      service_name_matcher:
        prefix: locations
      path: /healthcheck
    )EOF";
    envoy::config::core::v3::HealthCheck health_check_proto;
    EXPECT_THROW_WITH_REGEX(TestUtility::validate(parseHealthCheckFromV3Yaml(yaml)), EnvoyException,
                            "Proto constraint validation failed.*value must be greater than.*");
  }
  {
    const std::string yaml = R"EOF(
    timeout: 1s
    interval: 1s
    healthy_threshold: 1
    unhealthy_threshold: 1
    unhealthy_edge_interval: 0s
    http_health_check:
      service_name_matcher:
        prefix: locations
      path: /healthcheck
    )EOF";
    envoy::config::core::v3::HealthCheck health_check_proto;
    EXPECT_THROW_WITH_REGEX(TestUtility::validate(parseHealthCheckFromV3Yaml(yaml)), EnvoyException,
                            "Proto constraint validation failed.*value must be greater than.*");
  }
  {
    const std::string yaml = R"EOF(
    timeout: 1s
    interval: 1s
    healthy_threshold: 1
    unhealthy_threshold: 1
    healthy_edge_interval: 0s
    http_health_check:
      service_name_matcher:
        prefix: locations
      path: /healthcheck
    )EOF";
    envoy::config::core::v3::HealthCheck health_check_proto;
    EXPECT_THROW_WITH_REGEX(TestUtility::validate(parseHealthCheckFromV3Yaml(yaml)), EnvoyException,
                            "Proto constraint validation failed.*value must be greater than.*");
  }
  {
    const std::string yaml = R"EOF(
    timeout: 1s
    interval: 1s
    unhealthy_threshold: 1
    http_health_check:
      service_name_matcher:
        prefix: locations
      path: /healthcheck
    )EOF";
    envoy::config::core::v3::HealthCheck health_check_proto;
    EXPECT_THROW_WITH_REGEX(TestUtility::validate(parseHealthCheckFromV3Yaml(yaml)), EnvoyException,
                            "Proto constraint validation failed.*value is required.*");
  }
  {
    const std::string yaml = R"EOF(
    timeout: 1s
    interval: 1s
    healthy_threshold: 1
    http_health_check:
      service_name_matcher:
        prefix: locations
      path: /healthcheck
    )EOF";
    envoy::config::core::v3::HealthCheck health_check_proto;
    EXPECT_THROW_WITH_REGEX(TestUtility::validate(parseHealthCheckFromV3Yaml(yaml)), EnvoyException,
                            "Proto constraint validation failed.*value is required.*");
  }
}