示例#1
0
    def test_ensure_admin_errors(self, client_mock, config_mock):
        client_mock.who_am_i.return_value = Principal(permissions=[])

        config_mock.web.username = None
        self.assertRaises(ConfigurationError, bg.ensure_admin)

        config_mock.web.username = "******"
        self.assertRaises(ConfigurationError, bg.ensure_admin)

        client_mock.who_am_i.side_effect = ValidationError
        self.assertRaises(ConfigurationError, bg.ensure_admin)
示例#2
0
def bg_principal(principal_dict, bg_role):
    dict_copy = copy.deepcopy(principal_dict)
    dict_copy['roles'] = [bg_role]
    return Principal(**dict_copy)
示例#3
0
 def principal(self):
     return Principal(username="******",
                      roles=["bg-admin"],
                      permissions=["bg-all"])
示例#4
0
 def principal(self):
     return Principal(username='******',
                      roles=['bg-admin'],
                      permissions=['bg-all'])
示例#5
0
 def test_ensure_admin(self, client_mock):
     client_mock.who_am_i.return_value = Principal(permissions=["bg-all"])
     bg.ensure_admin()