示例#1
0
    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',),
        ]))
示例#2
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)
示例#3
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)
示例#4
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,
     )
示例#5
0
 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,
     )
示例#6
0
    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),)])
示例#7
0
    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
            ),
        )
示例#8
0
    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), )])
示例#9
0
    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', ),
            ]))
示例#10
0
 def create_factories(self):
     super().create_factories()
     self.property_name = 'granted_property'
     self.group = PropertyGroupFactory(granted={self.property_name},
                                       denied={'denied_property'})
示例#11
0
 def create_factories(self):
     super().create_factories()
     self.group = PropertyGroupFactory.create()
     self.user, self.processor = UserFactory.create_batch(2)
示例#12
0
 def create_factories(self):
     super().create_factories()
     PropertyGroupFactory.create(granted={'member', 'must_pay', 'network_access'})
     PropertyGroupFactory.create(granted={'violation'}, denied={'network_access'})
示例#13
0
def traffic_limit_exceeded_group(module_session):
    return PropertyGroupFactory.create(
        name="Blocked (traffic)",
        granted={'traffic_limit_exceeded'},
        denied={'network_access'},
    )
示例#14
0
def payment_in_default_group(module_session):
    return PropertyGroupFactory.create(
        name="Blocked (finance)",
        granted={'payment_in_default'},
        denied={'network_access'},
    )
示例#15
0
def network_access_group(module_session):
    return PropertyGroupFactory.create(
        name="Member",
        granted={'network_access'},
    )