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

bundle agent init
{
  methods:
      # 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_root_allowed.22005.srv");
}

bundle agent test
{
  vars:
      "runagent_cf" string =>
        "$(this.promise_dirname)/empty_config.runagent.cf.sub";
  methods:
      "any" usebundle =>
        # Port 22005 is role1_root_allowed.22005.srv
        # It allows "role1" but should disallow "role2"
        run_runagent("-H 127.0.0.1:22005 -D role2 $(runagent_cf)");
}

bundle agent check
{
  # Execution output file should still not be there.
  methods:
      "any"  usebundle => dcs_passif_file_absent("$(G.testdir)/exec_args.txt",
                                                 "$(this.promise_filename)");
}

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