def post(self, user_id, interface_id): parser = reqparse.RequestParser() parser.add_argument('password', dest='password', required=True) parser.add_argument('mac', dest='mac', required=True) parser.add_argument('host_name', dest='host_name', required=False) args = parser.parse_args() user = get_authenticated_user(user_id, args.password) interface = get_interface_or_404(interface_id) if interface.host.owner != user: abort( 404, message=f"User {user_id} does not have a host with interface {interface_id}" ) try: if args.host_name: host_edit(interface.host, interface.host.owner, interface.host.room, args.host_name, user) change_mac(interface, args.mac, user) session.session.add(interface) session.session.commit() except InvalidMACAddressException: abort(400, message='Invalid mac address.') except IntegrityError: abort(400, message='Mac address is already in use.') return "Mac address has been changed."
def test_0010_change_mac(self): new_mac = "20:00:00:00:00:00" interface = Interface.q.filter_by( mac=InterfaceData.dummy.mac).one() change_mac(interface, new_mac, self.user) self.assertEqual(interface.mac, new_mac)
def test_0010_change_mac(self): new_mac = "20:00:00:00:00:00" change_mac(self.dummy_device, new_mac, self.processing_user) self.assertEqual(self.dummy_device.mac, new_mac)
def test_0010_change_mac(self): new_mac = "20:00:00:00:00:00" netdev = UserNetDevice.q.get(UserNetDeviceData.dummy_user_device1.id) user = User.q.get(UserData.dummy_user1.id) change_mac(netdev, new_mac, user) self.assertEqual(netdev.mac, new_mac)
def test_0010_change_mac(self): new_mac = "20:00:00:00:00:00" interface = Interface.q.filter_by(mac=InterfaceData.dummy.mac).one() change_mac(interface, new_mac, self.user) self.assertEqual(interface.mac, new_mac)
def test_0010_change_mac(self): new_mac = "20:00:00:00:00:00" change_mac(self.interface, new_mac, self.processing_user) self.assertEqual(self.interface.mac, new_mac)