#! /usr/bin/python3 # ------------------------------------------------------------------ # # Copyright (C) 2013 Kshitij Gupta # Copyright (C) 2015 Christian Boltz # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General Public # License published by the Free Software Foundation. # # ------------------------------------------------------------------ import unittest from common_test import AATest, setup_all_loops from copy import deepcopy import re from apparmor.common import convert_regexp, AppArmorBug, AppArmorException from apparmor.aare import AARE, convert_expression_to_aare class TestConvert_regexp(AATest): tests = [ ('/foo', '^/foo$'), ('/{foo,bar}', '^/(foo|bar)$'), # ('/\{foo,bar}', '^/\{foo,bar}$'), # XXX gets converted to ^/\(foo|bar)$ ('/fo[abc]', '^/fo[abc]$'), ('/foo bar', '^/foo bar$'), ('/x\y', '^/x\y$'), ('/x\[y', '^/x\[y$'), ('/x\\y', '^/x\\y$'), ('/fo?', '^/fo[^/\000]$'), ('/foo/*', '^/foo/(((?<=/)[^/\000]+)|((?