Fix #28
This commit is contained in:
@@ -173,4 +173,47 @@ def test_check_access_with_inactive_card(db_session):
|
||||
|
||||
db_session.commit()
|
||||
|
||||
assert checkAccess("test-key-123", db_session) == False
|
||||
assert checkAccess("test-key-123", db_session) == False
|
||||
|
||||
def test_regression_check_access_issue_28(db_session):
|
||||
# Having a active aa after a inactive/invalid one denies access
|
||||
group = GroupDB(name="Test Group")
|
||||
db_session.add(group)
|
||||
db_session.commit()
|
||||
|
||||
card = Card(
|
||||
key="test-key-123",
|
||||
group_id=group.id,
|
||||
enabled=True,
|
||||
name="test_card",
|
||||
card_serial="00:00:00:00:00:00:00",
|
||||
)
|
||||
db_session.add(card)
|
||||
|
||||
#Creating timetable with inactive AA
|
||||
timetable1 = Timetable(
|
||||
weekday=datetime.datetime.weekday(datetime.date.today()),
|
||||
starttime=datetime.datetime.now().time(),
|
||||
duration=120, # 2 hours
|
||||
)
|
||||
db_session.add(timetable1)
|
||||
aa1 = AccessAuthorizationDB(name="First AA", is_active=False, type="timetable")
|
||||
db_session.add(aa1)
|
||||
aa1.timetables = [timetable1]
|
||||
|
||||
#Creating timetable with active AA
|
||||
timetable2 = Timetable(
|
||||
weekday=datetime.datetime.weekday(datetime.date.today()),
|
||||
starttime=datetime.datetime.now().time(),
|
||||
duration=120, # 2 hours
|
||||
)
|
||||
db_session.add(timetable2)
|
||||
aa2 = AccessAuthorizationDB(name="Second AA", is_active=True, type="timetable")
|
||||
db_session.add(aa2)
|
||||
aa2.timetables = [timetable2]
|
||||
|
||||
group.accessauths = [aa1, aa2]
|
||||
|
||||
db_session.commit()
|
||||
|
||||
assert checkAccess("test-key-123", db_session) == True
|
||||
Reference in New Issue
Block a user