body contain myshell
{
    !windows::
        useshell => "useshell";
    windows::
        useshell => "powershell";
}

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

bundle agent init
{
    methods:
        "any" usebundle => dcs_fini("$(G.testfile)");

        "any" usebundle => generate_key;
        "any" usebundle => trust_key;

        "any" usebundle => start_server("$(this.promise_dirname)/serverd_admit_localhost_15000.cf.srv");
    commands:
        "echo"
            args => "\"Could not stat: '$(this.promise_dirname)/cf-net_connect.cf'\" > $(G.testfile).expected",
            contain => myshell;
}

bundle agent test
{
    commands:
        "$(sys.cf_net)"
            args => "--log-level ERROR -H 127.0.0.1:15000 stat $(this.promise_dirname)/cf-net_connect.cf > $(G.testfile)  2>&1",
            contain => myshell;
    meta:
        "description" string => "Attempt to stat file without permission";
        "test_soft_fail" string => "windows",
          meta => { "ENT-10254" };
}

bundle agent check
{
    methods:
        "check" usebundle => dcs_check_diff("$(G.testfile)",
                                            "$(G.testfile).expected",
                                            "$(this.promise_filename)");
    vars:
        DEBUG|EXTRA::
            "actual_output"   string => readfile("$(G.testfile)");
            "expected_output" string => readfile("$(G.testfile).expected");
    reports:
        DEBUG|EXTRA::
            "expected_output: $(expected_output)";
            "actual_output:   $(actual_output)";
}

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