/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */

apply plugin: 'elasticsearch.legacy-yaml-rest-test'

dependencies {
  yamlRestTestImplementation project(':x-pack:plugin:core')
  yamlRestTestImplementation project(path: xpackModule('watcher'))
}

String pagerDutyServiceKey = System.getenv('pagerduty_service_api_key')

restResources {
  restApi {
    include 'watcher'
  }
}

if (!pagerDutyServiceKey) {
  tasks.named("yamlRestTest").configure { enabled = false }
} else {
  testClusters.matching { it.name == "yamlRestTest" }.configureEach {
    testDistribution = 'DEFAULT'
    setting 'xpack.security.enabled', 'false'
    setting 'xpack.ml.enabled', 'false'
    setting 'xpack.license.self_generated.type', 'trial'
    setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG'
    keystore 'xpack.notification.pagerduty.account.test_account.secure_service_api_key', pagerDutyServiceKey
  }
}

if (buildParams.inFipsJvm){
  // Test clusters run with security disabled
  tasks.named("yamlRestTest").configure{enabled = false }
}
