コード例 #1
0
 def test_compile_role_definition_with_date(self):
     """firerole - compiling date based role definitions"""
     self.failUnless(serialize(compile_role_definition("allow from '2010-11-11'")))
     self.failUnless(serialize(compile_role_definition("allow until '2010-11-11'")))
     self.assertRaises(
         InvenioWebAccessFireroleError, compile_role_definition, "allow from '2010-11-11','2010-11-23'"
     )
     self.assertRaises(InvenioWebAccessFireroleError, compile_role_definition, "allow from '2010-11'")
コード例 #2
0
 def test_compile_role_definition_with_date(self):
     """firerole - compiling date based role definitions"""
     self.failUnless(
         serialize(compile_role_definition("allow from '2010-11-11'")))
     self.failUnless(
         serialize(compile_role_definition("allow until '2010-11-11'")))
     self.assertRaises(InvenioWebAccessFireroleError,
                       compile_role_definition,
                       "allow from '2010-11-11','2010-11-23'")
     self.assertRaises(InvenioWebAccessFireroleError,
                       compile_role_definition, "allow from '2010-11'")
コード例 #3
0
 def test_compile_role_definition_literal_list(self):
     """firerole - compiling literal list role definitions"""
     self.failUnless(
         serialize(
             compile_role_definition(
                 "allow email '*****@*****.**', '*****@*****.**'"
             )))
コード例 #4
0
 def test_compile_role_definition_more_rows(self):
     """firerole - compiling more rows role definitions"""
     self.failUnless(
         serialize(
             compile_role_definition(
                 "allow email /.*@cern.ch/\nallow groups 'patata' "
                 "# a comment\ndeny any")))
コード例 #5
0
 def test_compile_role_definition_complex(self):
     """firerole - compiling complex role definitions"""
     self.failUnless(
         serialize(
             compile_role_definition(
                 "allow email /.*@cern.ch/\nallow groups 'patata' "
                 "# a comment\ndeny remote_ip '127.0.0.0/24'\ndeny any")))
コード例 #6
0
 def test_compile_role_definition_more_rows(self):
     """firerole - compiling more rows role definitions"""
     self.failUnless(
         serialize(
             compile_role_definition("allow email /.*@cern.ch/\nallow groups 'patata' " "# a comment\ndeny any")
         )
     )
コード例 #7
0
 def setUp(self):
     """Create a fake role."""
     self.role_name = 'test'
     self.role_description = 'test role'
     self.role_definition = 'allow email /.*@cern.ch/'
     self.role_id, dummy, dummy, dummy = acc_add_role(
         self.role_name, self.role_description,
         serialize(compile_role_definition(self.role_definition)),
         self.role_definition)
コード例 #8
0
 def setUp(self):
     """Create a fake role."""
     self.role_name = 'test'
     self.role_description = 'test role'
     self.role_definition = 'allow email /.*@cern.ch/'
     self.role_id, dummy, dummy, dummy = acc_add_role(self.role_name,
         self.role_description,
         serialize(compile_role_definition(self.role_definition)),
         self.role_definition)
コード例 #9
0
 def test_compile_role_definition_complex(self):
     """firerole - compiling complex role definitions"""
     self.failUnless(
         serialize(
             compile_role_definition(
                 "allow email /.*@cern.ch/\nallow groups 'patata' "
                 "# a comment\ndeny remote_ip '127.0.0.0/24'\ndeny any"
             )
         )
     )
コード例 #10
0
 def setUp(self):
     """Create a fake role."""
     from invenio.access_control_admin import acc_add_role
     from invenio.access_control_firerole import compile_role_definition, \
         serialize
     self.role_name = 'test'
     self.role_description = 'test role'
     self.role_definition = 'allow email /.*@cern.ch/'
     self.role_id, dummy, dummy, dummy = acc_add_role(
         self.role_name, self.role_description,
         serialize(compile_role_definition(self.role_definition)),
         self.role_definition)
コード例 #11
0
def create_needed_roles(restrictions, apache_group):
    """Create a role for the corresponding apache_group."""

    role_name = CFG_PROPOSED_ROLE_NAME % apache_group
    role_description = CFG_PROPOSED_ROLE_DESCRIPTION % ', '.join(get_collections_for_group(restrictions, apache_group))
    role_definition_src = 'allow apache_group "%s"' % apache_group
    print "Creating role '%s' ('%s') with firerole '%s'..." % (role_name, role_description, role_definition_src),
    res = acc_add_role(role_name, role_description, serialize(compile_role_definition(role_definition_src)), role_definition_src)
    if res == 0:
        print "Already existed!"
    else:
        print "OK!"
    return role_name
コード例 #12
0
def create_needed_roles(restrictions, apache_group):
    """Create a role for the corresponding apache_group."""

    role_name = CFG_PROPOSED_ROLE_NAME % apache_group
    role_description = CFG_PROPOSED_ROLE_DESCRIPTION % ', '.join(
        get_collections_for_group(restrictions, apache_group))
    role_definition_src = 'allow apache_group "%s"' % apache_group
    print "Creating role '%s' ('%s') with firerole '%s'..." % (
        role_name, role_description, role_definition_src),
    res = acc_add_role(role_name, role_description,
                       serialize(compile_role_definition(role_definition_src)),
                       role_definition_src)
    if res == 0:
        print "Already existed!"
    else:
        print "OK!"
    return role_name
コード例 #13
0
 def test_compile_role_definition_guest_field(self):
     """firerole - compiling guest field role definitions"""
     self.failUnless(serialize(compile_role_definition(
         "allow guest '1'")))
コード例 #14
0
 def test_compile_role_definition_literal_list(self):
     """firerole - compiling literal list role definitions"""
     self.failUnless(serialize(compile_role_definition(
         "allow email '*****@*****.**', '*****@*****.**'")))
コード例 #15
0
 def test_compile_role_definition_regexp_field(self):
     """firerole - compiling regexp field role definitions"""
     self.failUnless(serialize(compile_role_definition(
         "allow email /.*@cern.ch/")))
コード例 #16
0
 def test_compile_role_definition_group_field(self):
     """firerole - compiling group field role definitions"""
     self.failUnless(serialize(compile_role_definition(
         "allow groups 'patata'")))
コード例 #17
0
 def test_compile_role_definition_not(self):
     """firerole - compiling not role definitions"""
     self.failUnless(serialize(compile_role_definition(
         "allow not email '*****@*****.**'")))
コード例 #18
0
 def test_compile_role_definition_literal_field(self):
     """firerole - compiling literal field role definitions"""
     self.failUnless(serialize(compile_role_definition(
         "allow email '*****@*****.**'")))
コード例 #19
0
 def test_compile_role_definition_not(self):
     """firerole - compiling not role definitions"""
     self.failUnless(
         serialize(
             compile_role_definition(
                 "allow not email '*****@*****.**'")))
コード例 #20
0
 def test_compile_role_definition_allow_any(self):
     """firerole - compiling allow any role definitions"""
     self.failUnless(serialize(compile_role_definition("allow any")))
コード例 #21
0
 def test_compile_role_definition_guest_field(self):
     """firerole - compiling guest field role definitions"""
     self.failUnless(serialize(compile_role_definition("allow guest '1'")))
コード例 #22
0
 def test_compile_role_definition_not(self):
     """firerole - compiling not role definitions"""
     self.failUnless(serialize(compile_role_definition(
         "allow not email '*****@*****.**'")))
コード例 #23
0
 def test_compile_role_definition_literal_list(self):
     """firerole - compiling literal list role definitions"""
     self.failUnless(serialize(compile_role_definition(
         "allow email '*****@*****.**', '*****@*****.**'")))
コード例 #24
0
 def test_compile_role_definition_allow_any(self):
     """firerole - compiling allow any role definitions"""
     self.failUnless(serialize(compile_role_definition("allow any")))
コード例 #25
0
 def test_compile_role_definition_deny_any(self):
     """firerole - compiling deny any role definitions"""
     self.failIf(serialize(compile_role_definition("deny any")))
コード例 #26
0
 def test_compile_role_definition_group_field(self):
     """firerole - compiling group field role definitions"""
     self.failUnless(
         serialize(compile_role_definition("allow groups 'patata'")))
コード例 #27
0
 def test_compile_role_definition_deny_any(self):
     """firerole - compiling deny any role definitions"""
     self.failIf(serialize(compile_role_definition("deny any")))
コード例 #28
0
 def test_compile_role_definition_regexp_field(self):
     """firerole - compiling regexp field role definitions"""
     self.failUnless(
         serialize(compile_role_definition("allow email /.*@cern.ch/")))
コード例 #29
0
 def test_compile_role_definition_literal_field(self):
     """firerole - compiling literal field role definitions"""
     self.failUnless(
         serialize(
             compile_role_definition(
                 "allow email '*****@*****.**'")))