Beispiel #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',),
        ]))
Beispiel #2
0
 def create_factories(self):
     self.login = '******'
     self.password = '******'
     self.admin = UserFactory(login=self.login, password=self.password)
     admin_group = AdminPropertyGroupFactory()
     MembershipFactory.create(user=self.admin, group=admin_group)
     self.config = ConfigFactory()
Beispiel #3
0
 def create_factories(self):
     self.login = '******'
     self.password = '******'
     self.admin = UserFactory(login=self.login, password=self.password)
     admin_group = AdminPropertyGroupFactory()
     MembershipFactory.create(user=self.admin, group=admin_group)
     self.config = ConfigFactory()
Beispiel #4
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)
Beispiel #5
0
 def create_user(self, traffic_groups):
     with self.session.begin(subtransactions=True):
         user = UserFactory()
         if traffic_groups is None:
             traffic_groups = tuple()
         for group in traffic_groups:
             MembershipFactory.create(group=group, user=user)
     return user
Beispiel #6
0
 def create_user(self, traffic_groups):
     with self.session.begin(subtransactions=True):
         user = UserFactory()
         if traffic_groups is None:
             traffic_groups = tuple()
         for group in traffic_groups:
             MembershipFactory.create(group=group, user=user)
     return user
Beispiel #7
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)
Beispiel #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),)])
Beispiel #9
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), )])
Beispiel #10
0
 def create_factories(self):
     # We want a user who lives somewhere with a membership!
     super().create_factories()
     self.processor = UserFactory.create()
     self.user = UserWithHostFactory.create()
     self.membership = MembershipFactory.create(user=self.user,
                                                group=self.config.member_group)
     self.other_room = RoomFactory.create()
Beispiel #11
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
            ),
        )
Beispiel #12
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', ),
            ]))
Beispiel #13
0
    def create_factories(self):
        ConfigFactory.create()

        self.user = UserFactory.create()

        self.user_membership = MembershipFactory.create(
            active_during=closedopen(session.utcnow() - timedelta(weeks=52),
                                     None),
            user=self.user,
            group=config.member_group)

        last_month_last = session.utcnow().date().replace(day=1) - timedelta(1)

        self.membership_fee_current = MembershipFeeFactory.create()
        self.membership_fee_last = MembershipFeeFactory.create(
            begins_on=last_month_last.replace(day=1), ends_on=last_month_last)
Beispiel #14
0
 def create_factories(self):
     super().create_factories()
     MembershipFactory.create(user=self.user, group=self.payment_in_default_group,
                              begins_at=datetime.now() + timedelta(-1),
                              ends_at=datetime.now() + timedelta(1))
Beispiel #15
0
 def create_factories(self):
     super().create_factories()
     MembershipFactory.create(user=self.user,
                              group=self.payment_in_default_group,
                              begins_at=datetime.now() + timedelta(-1),
                              ends_at=datetime.now() + timedelta(1))
Beispiel #16
0
 def payment_in_default_membership(self, now, class_session, user,
                                   payment_in_default_group):
     return MembershipFactory.create(user=user,
                                     group=payment_in_default_group,
                                     begins_at=now + timedelta(-1),
                                     ends_at=now + timedelta(1))
Beispiel #17
0
def membership(module_session, user, network_access_group, now):
    return MembershipFactory.create(user=user,
                                    group=network_access_group,
                                    active_during=closedopen(
                                        now + timedelta(-1),
                                        now + timedelta(1)))
 def create_factories(self):
     super().create_factories()
     self.user = UserWithHostFactory.create()
     MembershipFactory.create(user=self.user,
                              group=self.config.member_group)
     self.test_user_id = self.user.id