#######################################################
#
# We request a path from disallowed path, it should fail
#
#######################################################

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

bundle agent init
{
}

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

body copy_from copy_from_port(port, protocol_version)

{
      portnumber       => "$(port)";
      protocol_version => "$(protocol_version)";

      # testroot dir is admitted on the server, while G.testdir is denied
      source      => "$(G.testdir)/source_file";
      servers     => { "127.0.0.1" };
      trustkey    => "true";
}

bundle agent test
{
  files:
      # localhost_deny_one_directory
      "$(G.testdir)/server1_classic"
        copy_from => copy_from_port("9881", "classic"),
        classes => if_repaired("copied1_classic");
      "$(G.testdir)/server1_latest"
        copy_from => copy_from_port("9881", "latest"),
        classes => if_repaired("copied1_latest");
      # localhost_deny_one_directory_with_regex
      "$(G.testdir)/server2_classic"
        copy_from => copy_from_port("9882", "classic"),
        classes => if_repaired("copied2_classic");
      "$(G.testdir)/server2_latest"
        copy_from => copy_from_port("9882", "latest"),
        classes => if_repaired("copied2_latest");
}

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

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

  reports:

    # All copies must fail
    !copied1_classic.!copied1_latest.!copied2_classic.!copied2_latest::
      "$(fn[1]) Pass";
    copied1_classic|copied1_latest|copied2_classic|copied2_latest::
      "$(fn[1]) FAIL";
}
