#! /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 re import unittest from copy import deepcopy from apparmor.common import AppArmorBug, AppArmorException, convert_regexp from apparmor.aare import AARE, convert_expression_to_aare from common_test import AATest, setup_all_loops 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$'), (r'/x\y', r'^/x\y$'), (r'/x\[y', r'^/x\[y$'), ('/x\\y', '^/x\\y$'), ('/fo?', '^/fo[^/\000]$'), ('/foo/*', '^/foo/(((?<=/)[^/\000]+)|((?