body common control
{
  inputs => { "../../default.sub.cf", "../../run_with_server.cf.sub" };
  bundlesequence => { default("$(this.promise_filename)") };
  version => "1.0";
}

bundle agent test
{
  meta:
    "test_suppress_fail"
      string => "windows",
      meta => { "redmine6405", "ENT-2480" };

    # Ubuntu 20 (at least our build machines) doesn't know how to resolve
    # 127.0.0.1/::1 to localhost, the reverse lookup fails and so
    # 'deny => { "localhost" };' and 'deny_hostnames => { "localhost" };'
    # are not enough to deny access for this test.
    # Test fails on SLES / OpenSUSE 15, pending investigation.
    "test_skip_unsupported"
      string => "(ubuntu_20|ubuntu_22|debian_12|sles_15|opensuse_leap_15)",
      meta => { "ENT-2480", "ENT-7362", "ENT-9055" };

  methods:
    # source file
    "any"
      usebundle => file_make(
        "$(G.testdir)/source_file",
        "This is the source file to copy $(sys.date) - always fresh"
      );

    # destination files
    "any" usebundle => dcs_fini("$(G.testdir)/server1_classic");
    "any" usebundle => dcs_fini("$(G.testdir)/server1_latest");
    "any" usebundle => dcs_fini("$(G.testdir)/server2_classic");
    "any" usebundle => dcs_fini("$(G.testdir)/server2_latest");
    "any" usebundle => generate_key;

    "any"
      usebundle => start_server(
        "$(this.promise_dirname)/localhost_closed_hostname.srv"
      );

    "any"
      usebundle => start_server(
        "$(this.promise_dirname)/localhost_closed_deny_hostnames.srv"
      );

    "any" usebundle => run_test("$(this.promise_filename).sub");

    "any"
      usebundle => stop_server(
        "$(this.promise_dirname)/localhost_closed_hostname.srv"
      );

    "any"
      usebundle => stop_server(
        "$(this.promise_dirname)/localhost_closed_deny_hostnames.srv"
      );
}
