Пример #1
0
    def create_factories(self):
        self.user = UserWithHostFactory()
        self.ip = self.user.hosts[0].interfaces[0].ips[0]
        for delta in range(14):
            TrafficCreditFactory.create(timestamp=self.now + timedelta(-delta),
                                        amount=3*1024**3, user=self.user)
            TrafficVolumeFactory.create(timestamp=self.now + timedelta(-delta),
                                        amount=1*1024**3, user=self.user, ip=self.ip)

        # Unrelated events should not be included in the sum
        other_user = UserWithHostFactory()
        other_ip = other_user.hosts[0].interfaces[0].ips[0]
        TrafficCreditFactory.create_batch(20, user=other_user)
        TrafficVolumeFactory.create_batch(20, user=other_user, ip=other_ip)
Пример #2
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',),
        ]))
Пример #3
0
 def create_factories(self):
     # We want a user who lives somewhere with a membership!
     super().create_factories()
     self.user = UserWithHostFactory.create(
         with_membership=True,
         membership__group=self.config.member_group,
     )
Пример #4
0
    def test_user_host_annexation(self):
        mac = "00:de:ad:be:ef:00"
        other_user = UserWithHostFactory(host__interface__mac=mac)
        session.session.commit()
        self.assertEqual(len(other_user.hosts), 1)

        move_in_formdata = {
            'now': True,
            'name': "Test User",
            'building': str(self.room.building.id),
            'level': str(self.room.level),
            'room_number': self.room.number,
            'login': "******",
            'mac': mac,
            'email': "",
            'birthdate': "1990-01-01",
            'property_group': config.member_group.id
        }
        response = self.client.post(url_for('user.create'),
                                    data=move_in_formdata)
        self.assertStatus(response, 400)
        self.assertIsNone(response.location)

        move_in_formdata.update(annex="y")
        response = self.client.post(url_for('user.create'),
                                    data=move_in_formdata)
        self.assert_user_moved_in(response)
Пример #5
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()
Пример #6
0
 def create_factories(self):
     super().create_factories()
     self.relevant_user = UserWithHostFactory(patched=True)
     self.other_user = UserFactory.create()
     self.room_log_entry = RoomLogEntryFactory(author=self.admin,
                                               room=self.relevant_user.room)
     self.user_log_entry = UserLogEntryFactory(author=self.admin,
                                               user=self.relevant_user)
Пример #7
0
 def create_factories(self):
     super().create_factories()
     # we just create the subnet to ensure it stays the same when in the same building
     subnet = factories.SubnetFactory()
     self.user = UserWithHostFactory(
         room__patched_with_subnet=True,
         room__patch_ports__switch_port__default_vlans__subnets=[subnet])
     self.processing_user = UserFactory()
     self.old_room = self.user.room
     assert all(h.room == self.old_room for h in self.user.hosts)
     self.new_room_other_building = factories.RoomFactory(
         patched_with_subnet=True)
     self.new_room_same_building = factories.RoomFactory(
         building=self.old_room.building,
         patched_with_subnet=True,
         patch_ports__switch_port__default_vlans__subnets=[subnet],
     )
Пример #8
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', ),
            ]))
Пример #9
0
 def create_factories(self):
     self.user = UserWithHostFactory(host__interface__ip__str_address=self.ip)
Пример #10
0
 def test_user_without_entries_has_zero_credit(self):
     user = UserWithHostFactory()
     session.session.commit()
     self.assertEqual(user.current_credit, 0)
Пример #11
0
def user(module_session):
    return UserWithHostFactory(host__interface__ip__str_address=ip)
Пример #12
0
 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
Пример #13
0
 def create_factories(self):
     super().create_factories()
     self.interface = InterfaceFactory.create()
     UserWithHostFactory.create(host__interface=self.interface)
     self.processor = UserFactory.create()
Пример #14
0
def user(module_session):
    return UserWithHostFactory()
Пример #15
0
 def create_factories(self):
     super().create_factories()
     self.user = UserWithHostFactory()
     TrafficVolumeLastWeekFactory.create_batch(
         7, ip=self.user.hosts[0].interfaces[0].ips[0], user=self.user)