Exemplo n.º 1
0
def create_user_groups():
	
	new_group = usergroup(GROUPID = "admin", DESCRIPTION = "HQ Admin users", ACTIONS  = EDIT, SCHEDULES = EDIT, JOBS = EDIT, SERVERS = EDIT, USERGROUPS = EDIT, LOGS = VIEW, 
			USERS = EDIT, EVENTDEFS = EDIT, LOG_VIEWS = EDIT, EVENT_VIEWS = EDIT, JOB_VIEWS = EDIT, EVENTS = VIEW) 
	session.add(new_group)
	session.flush()

	new_user = user(USERID = "admin", PASSWORD = encrypt("hux"))
	session.add(new_user)
	session.flush()

	session.merge(new_user)

	new_uig = useringroup(USERID = new_user.USERID, GROUPID = new_group.GROUPID)
	session.add(new_uig)	
	session.flush()
Exemplo n.º 2
0
	def testusers(self):
		sess = getsession()
		u = user(USERID = "Dan")
		sess.add(u)
		sess.flush()

		ug = usergroup(GROUPID="test")
		sess.add(ug)
		sess.flush()

		uig = useringroup(USERID=u.USERID,GROUPID=ug.GROUPID) 
		sess.add(uig)
		sess.flush()
		u = sess.merge(u)
		self.assert_(u.actions(VIEW))
		self.assert_(u.schedules(VIEW))
		self.assert_(u.jobs(VIEW))
		self.assert_(u.servers(VIEW))
		self.assert_(u.usergroups(VIEW))
		self.assert_(u.users(VIEW))
		self.assert_(u.logs(NONE))

		ug.ACTIONS = EDIT
		ug.SCHEDULES = EDIT
		ug.JOBS = EDIT
		ug.SERVERS = EDIT
		ug.USERGROUPS = EDIT
		ug.USERS = EDIT
		ug.LOGS = VIEW

		sess.flush()
		u = sess.query(user).filter(user.USERID == u.USERID).one()
		self.assert_(u.actions(EDIT))
		self.assert_(u.schedules(EDIT))
		self.assert_(u.jobs(EDIT))
		self.assert_(u.servers(EDIT))
		self.assert_(u.usergroups(EDIT))
		self.assert_(u.users(EDIT))
		self.assert_(u.logs(VIEW))