Skip to content

Commit

Permalink
api mpsk api more clients
Browse files Browse the repository at this point in the history
the api is now able to add more clients

Signed-off-by: Alex <robokatze182@gmx.de>
#744
  • Loading branch information
agmes4 committed Sep 19, 2024
1 parent f52b236 commit e281446
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions pycroft/lib/mpsk_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def mpsk_client_create(owner: User, name: str, mac: str, processor: User, api=Fa
:param processor: the user who initiated the mac address change.
:param api: whether to create an api client or not. If set Ture checks rather a user exceeds the maximum of clients (set to 10).
"""
if len(owner.mpsks) >= 10 and api:
if len(owner.mpsks) >= 30 and api:
raise AmountExceededError(

Check failure on line 48 in pycroft/lib/mpsk_client.py

View workflow job for this annotation

GitHub Actions / python-lint

Error

Call to untyped function "AmountExceededError" in typed context [no-untyped-call]
"the limit of added mpsks clients is exceeded", limit=10, actual=len(owner.mpsks)
"the limit of added mpsks clients is exceeded", limit=30, actual=len(owner.mpsks)
)

client = MPSKClient(name=name, owner_id=owner.id, mac=mac)
Expand Down
34 changes: 17 additions & 17 deletions tests/model/test_mpsk.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,27 @@ def test_names(self, session, user, name):
assert mpsk_client.name == name

def test_exceeds_max_api(self, session, user):
mac = "00:00:00:00:00:0"
for i in range(10):
mac_client = mac + hex(i)[2:]
c = mpsk_client_create(user, "Hallo", mac_client, user, api=True)
user.mpsks.append(c)
session.flush()
assert len(user.mpsks) == i + 1
mac = "00:00:00:00:00:"
for j in range(1, 4):
for i in range(10):
mac_client = mac + hex(j)[2:] + hex(i)[2:]
c = mpsk_client_create(user, "Hallo", mac_client, user, api=True)
user.mpsks.append(c)
session.flush()

for i in range(10, 15):
mac_client = mac + hex(i)[2:]
for i in range(15):
mac_client = mac + "0" + hex(i)[2:]
with pytest.raises(AmountExceededError):
c = mpsk_client_create(user, "Hallo", mac_client, user, api=True)
mpsk_client_create(user, "Hallo", mac_client, user, api=True)

def test_admin_exceeds(self, session, user):
mac = "00:00:00:00:00:0"
for i in range(15):
mac_client = mac + hex(i)[2:]
c = mpsk_client_create(user, "Hallo", mac_client, user, api=False)
user.mpsks.append(c)
session.flush()
assert len(user.mpsks) == i + 1
mac = "00:00:00:00:00:"
for j in range(0, 4):
for i in range(15):
mac_client = mac + hex(j)[2:] + hex(i)[2:]
c = mpsk_client_create(user, "Hallo", mac_client, user)
user.mpsks.append(c)
session.flush()

@pytest.fixture(scope="class")
def user(self, class_session):
Expand Down

0 comments on commit e281446

Please sign in to comment.