#######################################################
#
# copy_from compare=>"digest" with server-side shortcut expansion (TLS
# protocol only) when file is already there - should not copy
#
#######################################################

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

#######################################################

bundle agent init
{
}

#######################################################

bundle agent test
{
  files:
      "$(G.testdir)/destfile_classic"
        copy_from => copy_src_file("classic"),
        classes => if_repaired("copied_classic");
      "$(G.testdir)/destfile_latest"
        copy_from => copy_src_file("latest"),
        classes => if_repaired("copied_latest");
}

#########################################################

body copy_from copy_src_file(protocol_version)
{
      protocol_version => "$(protocol_version)";

      # server-side expansion of shortcut
      source      => "simple_source";

      servers     => { "127.0.0.1" };
      compare     => "digest";
      copy_backup => "false";
      trustkey    => "true";
      portnumber  => "9876"; # localhost_open
}

#######################################################

bundle agent check
{
  classes:
      "dummy" expression => regextract("(.*)\.sub", $(this.promise_filename), "fn");

  reports:

    !copied_classic.!copied_latest::
      "$(fn[1]) Pass";
    copied_classic|copied_latest::
      "$(fn[1]) FAIL";

}
