|
| 1 | +############################################################################## |
| 2 | +# |
| 3 | +# Test that agent can override the immutable bit when using transformer |
| 4 | +# attribute |
| 5 | +# |
| 6 | +############################################################################## |
| 7 | + |
| 8 | +body common control |
| 9 | +{ |
| 10 | + inputs => { "../../default.cf.sub" }; |
| 11 | + bundlesequence => { default("$(this.promise_filename)") }; |
| 12 | + version => "1.0"; |
| 13 | +} |
| 14 | + |
| 15 | +body fsattrs set_immutable |
| 16 | +{ |
| 17 | + immutable => "true"; |
| 18 | +} |
| 19 | + |
| 20 | +bundle agent init |
| 21 | +{ |
| 22 | + files: |
| 23 | + "/tmp/immutable_11.txt" |
| 24 | + create => "true"; |
| 25 | + |
| 26 | + commands: |
| 27 | + "chattr +i /tmp/immutable_11.txt" |
| 28 | + contain => in_shell; |
| 29 | +} |
| 30 | + |
| 31 | +bundle agent test |
| 32 | +{ |
| 33 | + meta: |
| 34 | + "description" -> { "CFE-1840", "ENT-10961" } |
| 35 | + string => "Test that agent can override the immutable bit on a file while using the transformer attribute"; |
| 36 | + |
| 37 | + "test_soft_fail" |
| 38 | + string => "hpux|aix|windows", |
| 39 | + meta => { "CFE-1840", "ENT-10961" }; |
| 40 | + |
| 41 | + vars: |
| 42 | + "gzip_path" |
| 43 | + string => ifelse( |
| 44 | + isexecutable("/bin/gzip"), |
| 45 | + "/bin/gzip", |
| 46 | + "/usr/bin/gzip" |
| 47 | + ); |
| 48 | + |
| 49 | + files: |
| 50 | + "/tmp/immutable_11.txt" |
| 51 | + fsattrs => set_immutable, |
| 52 | + transformer => "$(gzip_path) $(this.promiser)"; |
| 53 | + |
| 54 | +} |
| 55 | + |
| 56 | +bundle agent check |
| 57 | +{ |
| 58 | + classes: |
| 59 | + "original_exists" |
| 60 | + expression => fileexists("/tmp/immutable_11.txt"); |
| 61 | + "transformed_exists" |
| 62 | + expression => fileexists("/tmp/immutable_11.txt.gz"); |
| 63 | + "ok" |
| 64 | + expression => "!original_exists&transformed_exists"; |
| 65 | + |
| 66 | + reports: |
| 67 | + ok:: |
| 68 | + "$(this.promise_filename) Pass"; |
| 69 | + !ok:: |
| 70 | + "$(this.promise_filename) FAIL"; |
| 71 | + any:: |
| 72 | + "Expected file '/tmp/immutable_11.txt' to not exists $(with)" |
| 73 | + with => ifelse("!original_exists", "and it does not", "but it does"); |
| 74 | + "Expected file '/tmp/immutable_11.txt.gz' to exists $(with)" |
| 75 | + with => ifelse("transformed_exists", "and it does", "but it does not"); |
| 76 | +} |
| 77 | + |
| 78 | +bundle agent destroy |
| 79 | +{ |
| 80 | + commands: |
| 81 | + "chattr -i /tmp/immutable_11.txt" |
| 82 | + contain => in_shell, |
| 83 | + handle => "is mutable"; |
| 84 | + |
| 85 | + files: |
| 86 | + "/tmp/immutable_11.txt" |
| 87 | + delete => tidy, |
| 88 | + depends_on => { "is mutable" }; |
| 89 | + files: |
| 90 | + "/tmp/immutable_11.txt.gz" |
| 91 | + delete => tidy; |
| 92 | +} |
0 commit comments