def test_singleton(self): """ Since it is a singleton, all instances should be the same. """ sys_u_1 = model.SystemUser() sys_u_2 = model.SystemUser() self.assertTrue(sys_u_1 is sys_u_2)
def is_system_principal(self): """ Determine if the current user is the default system user. @return: true if the current user is the system user, false otherwise @rtype: bool """ return self.get_principal() is model.SystemUser()
def set_principal(self, principal=None): """ Set the current user of the system to the provided principal, if no principal is provided, set the current user to the system user. @param principal: current user @type principal: User or None """ _PRINCIPAL_STORAGE.principal = principal or model.SystemUser()
def get_principal(self): """ Get the current user of the system, returning the default system user if there isn't one. @return: current user of the system @rtype: User or dict """ return getattr(_PRINCIPAL_STORAGE, 'principal', model.SystemUser())
def set_principal(self, principal=None): """ Set the current user of the system to the provided principal, if no principal is provided, set the current user to the system user. :param principal: current user :type principal: pulp.server.db.model.User or pulp.server.db.model.SystemUser """ _PRINCIPAL_STORAGE.principal = principal or model.SystemUser()
def get_principal(self): """ Get the current user of the system, returning the default system user if there isn't one. :return: current user of the system :rtype: pulp.server.db.model.User or pulp.server.db.model.SystemUser """ return getattr(_PRINCIPAL_STORAGE, 'principal', model.SystemUser())
def test_init(self): """ Make sure the SystemUser has the correct attributes. """ sys_user = model.SystemUser() self.assertEqual(sys_user.login, model.SYSTEM_LOGIN) self.assertEqual(sys_user.password, None) self.assertEqual(sys_user.name, model.SYSTEM_LOGIN) self.assertEqual(sys_user.roles, []) self.assertEqual(sys_user._id, model.SYSTEM_ID) self.assertEqual(sys_user.id, model.SYSTEM_ID)
def clear_principal(self): """ Clear the current user of the system. """ _PRINCIPAL_STORAGE.principal = model.SystemUser()