#######################################################
#
# copy_from compare=>"digest" with server-side expansion of IP address
# (TLS protocol only) when file is there but differs - should copy
#
#######################################################

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

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

bundle agent init
{
}

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

bundle agent test
{
  files:
      "$(G.testdir)/destination_file"
        copy_from => copy_src_file,
        classes => if_repaired("repaired");
}

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

body copy_from copy_src_file
{
      # server-side special variable expansion
      # of "127.0.0.1" to "$(connection.ip)"
      source      => "$(G.testdir)/127.0.0.1.txt";

      # Special variable expansion only works with "latest" protocol.

      protocol_version => "latest";
      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");

  methods:
      "any" usebundle => dcs_if_diff_expected("$(G.testdir)/127.0.0.1.txt",
                                              "$(G.testdir)/destination_file",
                                              "no", "same_file", "differ_file");
  reports:

    same_file::
      "$(fn[1]) Pass";
    !same_file::
      "$(fn[1]) FAIL";

}
