def create_factories(self): self.user = UserWithHostFactory.create() self.network_access_group = PropertyGroupFactory.create( name="Member", granted={'network_access'}, ) self.payment_in_default_group = PropertyGroupFactory.create( name="Blocked (finance)", granted={'payment_in_default'}, denied={'network_access'}, ) self.traffic_limit_exceeded_group = PropertyGroupFactory.create( name="Blocked (traffic)", granted={'traffic_limit_exceeded'}, denied={'network_access'}, ) # the user's room needs to be connected to provide `nasipaddress` and `nasportid` self.switch = SwitchFactory.create(host__owner=self.user) PatchPortFactory.create_batch(2, patched=True, switch_port__switch=self.switch, # This needs to be the HOSTS room! room=self.user.hosts[0].room) MembershipFactory.create(user=self.user, group=self.network_access_group, begins_at=datetime.now() + timedelta(-1), ends_at=datetime.now() + timedelta(1)) session.session.execute(hades.radius_property.insert(values=[ ('payment_in_default',), ('traffic_limit_exceeded',), ]))
def test_no_alternative_dns(self): cache_group = PropertyGroupFactory.create(name="Cache User", granted={'cache_access'}) MembershipFactory.create(user=self.user, group=cache_group, begins_at=datetime.now() + timedelta(-1), ends_at=datetime.now() + timedelta(1)) self.assertEqual(session.session.query(hades.alternative_dns.table).count(), 0)
def test_no_alternative_dns(self): cache_group = PropertyGroupFactory.create(name="Cache User", granted={'cache_access'}) MembershipFactory.create(user=self.user, group=cache_group, begins_at=datetime.now() + timedelta(-1), ends_at=datetime.now() + timedelta(1)) self.assertEqual( session.session.query(hades.alternative_dns.table).count(), 0)
def create_factories(self): super().create_factories() self.propgroup = PropertyGroupFactory.create( name="my propgroup", granted={self.PROPNAME, 'ldap_login_enabled'}) self.user = UserWithMembershipFactory.create( name="Hans Wurst", login="******", membership__group=self.propgroup, membership__includes_today=True, with_unix_account=True, )
def create_factories(self): super().create_factories() self.propgroup = PropertyGroupFactory.create( name="my property group", granted={'mail', 'ldap_login_enabled'}, ) self.user1, self.user2 = UserWithMembershipFactory.create_batch( 2, membership__group=self.propgroup, membership__includes_today=True, with_unix_account=True, )
def test_alternative_dns(self): # Nobody is cache user by default self.assertEqual(session.session.query(hades.alternative_dns.table).count(), 0) # add cache group cache_group = PropertyGroupFactory.create(name="Cache User", granted={'cache_access'}) MembershipFactory.create(user=self.user, group=cache_group, begins_at=datetime.now() + timedelta(-1), ends_at=datetime.now() + timedelta(1)) rows = session.session.query(hades.alternative_dns.table).all() ip = self.user.hosts[0].ips[0] self.assertEqual(rows, [(str(ip.address),)])
def create_factories(self): super().create_factories() u1, u2 = UserFactory.create_batch(2, with_unix_account=True) inconsistent = UserFactory.create(with_unix_account=True, email=None) p_dummy = PropertyGroupFactory.create(name='group_without_grants') pg_member = PropertyGroupFactory.create( name='member', granted={'mail', 'ldap_login_enabled'}) UserWithMembershipFactory.create(membership__group=p_dummy, with_unix_account=True) for user in [u1, u2, inconsistent]: MembershipFactory.create(group=pg_member, user=user) MembershipFactory.create( user=inconsistent, group=PropertyGroupFactory.create( name='some_weird_group', granted={ 'mail' }, # weird, because grants mail, but not ldap_login_enabled ), )
def test_alternative_dns(self): # Nobody is cache user by default self.assertEqual( session.session.query(hades.alternative_dns.table).count(), 0) # add cache group cache_group = PropertyGroupFactory.create(name="Cache User", granted={'cache_access'}) MembershipFactory.create(user=self.user, group=cache_group, begins_at=datetime.now() + timedelta(-1), ends_at=datetime.now() + timedelta(1)) rows = session.session.query(hades.alternative_dns.table).all() ip = self.user.hosts[0].ips[0] self.assertEqual(rows, [(str(ip.address), )])
def create_factories(self): self.user = UserWithHostFactory.create() self.network_access_group = PropertyGroupFactory.create( name="Member", granted={'network_access'}, ) self.payment_in_default_group = PropertyGroupFactory.create( name="Blocked (finance)", granted={'payment_in_default'}, denied={'network_access'}, ) self.traffic_limit_exceeded_group = PropertyGroupFactory.create( name="Blocked (traffic)", granted={'traffic_limit_exceeded'}, denied={'network_access'}, ) # the user's room needs to be connected to provide `nasipaddress` and `nasportid` self.switch = SwitchFactory.create(host__owner=self.user) PatchPortFactory.create_batch( 2, patched=True, switch_port__switch=self.switch, # This needs to be the HOSTS room! room=self.user.hosts[0].room) MembershipFactory.create(user=self.user, group=self.network_access_group, begins_at=datetime.now() + timedelta(-1), ends_at=datetime.now() + timedelta(1)) session.session.execute( hades.radius_property.insert(values=[ ('payment_in_default', ), ('traffic_limit_exceeded', ), ]))
def create_factories(self): super().create_factories() self.property_name = 'granted_property' self.group = PropertyGroupFactory(granted={self.property_name}, denied={'denied_property'})
def create_factories(self): super().create_factories() self.group = PropertyGroupFactory.create() self.user, self.processor = UserFactory.create_batch(2)
def create_factories(self): super().create_factories() PropertyGroupFactory.create(granted={'member', 'must_pay', 'network_access'}) PropertyGroupFactory.create(granted={'violation'}, denied={'network_access'})
def traffic_limit_exceeded_group(module_session): return PropertyGroupFactory.create( name="Blocked (traffic)", granted={'traffic_limit_exceeded'}, denied={'network_access'}, )
def payment_in_default_group(module_session): return PropertyGroupFactory.create( name="Blocked (finance)", granted={'payment_in_default'}, denied={'network_access'}, )
def network_access_group(module_session): return PropertyGroupFactory.create( name="Member", granted={'network_access'}, )