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

bundle agent init
{
  methods:
    # Expected output in the exec_args.txt file
    "any" usebundle => file_make("$(G.testdir)/expected_args.txt", "-D role1");

    # Ensure execution output file is not there
    "any" usebundle => dcs_fini("$(G.testdir)/exec_args.txt");
    "any" usebundle => generate_key;
    "any" usebundle => trust_key;

    "any"
      usebundle => start_server(
        "$(this.promise_dirname)/role1_role2_root_allowed.22008.srv"
      );
}

bundle agent test
{
  meta:
    "test_soft_fail"
      string => "windows",
      meta => { "ENT-10404" };

  vars:
    "runagent_cf"
      string => "$(this.promise_dirname)/empty_config.runagent.cf.sub";

  methods:
    "any"
      # Port 22008 is role1_role2_root_allowed.22008.srv
      usebundle => run_runagent("-H 127.0.0.1:22008 -D role1 $(runagent_cf)");
}

bundle agent check
{
  methods:
    "any"
      usebundle => dcs_check_diff(
        "$(G.testdir)/expected_args.txt",
        "$(G.testdir)/exec_args.txt",
        "$(this.promise_filename)"
      );
}

bundle agent destroy
{
  methods:
    "any"
      usebundle => stop_server(
        "$(this.promise_dirname)/role1_role2_root_allowed.22008.srv"
      );
}
