[apparmor] [patch] test new parameters of write_header()
Christian Boltz
apparmor at cboltz.de
Sat Mar 14 01:26:07 UTC 2015
Hallo,
this patch changes the write_header tests so that the 'profile_keyword'
and 'header_comment' parameters can be (and are) tested:
- add a None for both to the existing tests
- add some tests that come with the profile keyword and/or a comment
[ 20-write-header-test-new-parameters.diff ]
=== modified file utils/test/test-aa.py
--- utils/test/test-aa.py 2015-03-14 02:16:34.770280565 +0100
+++ utils/test/test-aa.py 2015-03-14 02:15:39.268573693 +0100
@@ -309,25 +310,31 @@
class AaTest_write_header(AATest):
tests = [
- # name embedded_hat write_flags depth flags attachment expected
- (['/foo', False, True, 1, 'complain', None ], ' /foo flags=(complain) {'),
- (['/foo', True, True, 1, 'complain', None ], ' profile /foo flags=(complain) {'),
- (['/foo sp', False, False, 2, 'complain', None ], ' "/foo sp" {'),
- (['/foo' ,False, False, 2, 'complain', None ], ' /foo {'),
- (['/foo', True, False, 2, 'complain', None ], ' profile /foo {'),
- (['/foo', False, True, 0, None, None ], '/foo {'),
- (['/foo', True, True, 0, None, None ], 'profile /foo {'),
- (['/foo', False, False, 0, None, None ], '/foo {'),
- (['/foo', True, False, 0, None, None ], 'profile /foo {'),
- (['bar', False, True, 1, 'complain', None, ], ' profile bar flags=(complain) {'),
- (['bar', False, True, 1, 'complain', '/foo' ], ' profile bar /foo flags=(complain) {'),
- (['bar', True, True, 1, 'complain', '/foo' ], ' profile bar /foo flags=(complain) {'),
- (['bar baz', False, True, 1, None, '/foo' ], ' profile "bar baz" /foo {'),
- (['bar', True, True, 1, None, '/foo' ], ' profile bar /foo {'),
- (['bar baz', False, True, 1, 'complain', '/foo sp' ], ' profile "bar baz" "/foo sp" flags=(complain) {'),
- (['^foo', False, True, 1, 'complain', None ], ' profile ^foo flags=(complain) {'),
- (['^foo', True, True, 1, 'complain', None ], ' ^foo flags=(complain) {'),
- (['^foo', True, True, 1.5, 'complain', None ], ' ^foo flags=(complain) {'),
+ # name embedded_hat write_flags depth flags attachment prof.keyw. comment expected
+ (['/foo', False, True, 1, 'complain', None, None, None ], ' /foo flags=(complain) {'),
+ (['/foo', True, True, 1, 'complain', None, None, None ], ' profile /foo flags=(complain) {'),
+ (['/foo sp', False, False, 2, 'complain', None, None, None ], ' "/foo sp" {'),
+ (['/foo' ,False, False, 2, 'complain', None, None, None ], ' /foo {'),
+ (['/foo', True, False, 2, 'complain', None, None, None ], ' profile /foo {'),
+ (['/foo', False, True, 0, None, None, None, None ], '/foo {'),
+ (['/foo', True, True, 0, None, None, None, None ], 'profile /foo {'),
+ (['/foo', False, False, 0, None, None, None, None ], '/foo {'),
+ (['/foo', True, False, 0, None, None, None, None ], 'profile /foo {'),
+ (['bar', False, True, 1, 'complain', None, None, None ], ' profile bar flags=(complain) {'),
+ (['bar', False, True, 1, 'complain', '/foo', None, None ], ' profile bar /foo flags=(complain) {'),
+ (['bar', True, True, 1, 'complain', '/foo', None, None ], ' profile bar /foo flags=(complain) {'),
+ (['bar baz', False, True, 1, None, '/foo', None, None ], ' profile "bar baz" /foo {'),
+ (['bar', True, True, 1, None, '/foo', None, None ], ' profile bar /foo {'),
+ (['bar baz', False, True, 1, 'complain', '/foo sp', None, None ], ' profile "bar baz" "/foo sp" flags=(complain) {'),
+ (['^foo', False, True, 1, 'complain', None, None, None ], ' profile ^foo flags=(complain) {'),
+ (['^foo', True, True, 1, 'complain', None, None, None ], ' ^foo flags=(complain) {'),
+ (['^foo', True, True, 1.5, 'complain', None, None, None ], ' ^foo flags=(complain) {'),
+ (['/foo', False, True, 1, 'complain', None, 'profile', None ], ' profile /foo flags=(complain) {'),
+ (['/foo', True, True, 1, 'complain', None, 'profile', None ], ' profile /foo flags=(complain) {'),
+ (['/foo', False, True, 1, 'complain', None, None, '# x' ], ' /foo flags=(complain) { # x'),
+ (['/foo', True, True, 1, None, None, None, '# x' ], ' profile /foo { # x'),
+ (['/foo', False, True, 1, None, None, 'profile', '# x' ], ' profile /foo { # x'),
+ (['/foo', True, True, 1, 'complain', None, 'profile', '# x' ], ' profile /foo flags=(complain) { # x'),
]
def _run_test(self, params, expected):
@@ -335,7 +342,7 @@
embedded_hat = params[1]
write_flags = params[2]
depth = params[3]
- prof_data = { 'flags': params[4], 'attachment': params[5], 'profile_keyword': None, 'header_comment': None }
+ prof_data = { 'flags': params[4], 'attachment': params[5], 'profile_keyword': params[6], 'header_comment': params[7] }
result = write_header(prof_data, depth, name, embedded_hat, write_flags)
self.assertEqual(result, [expected])
Regards,
Christian Boltz
--
Der IE darf bei uns auf Produktivsystem nicht verwendet werden.
Malware gehört in VMs für die Analyse, nicht auf den Host.
[thomas zu http://www.hostblogger.de/blog/archives/5748-Too-Close.html]
More information about the AppArmor
mailing list