def handle(self, *args, **kwargs): r = get_redis_connection('default') for card_hash, rawdata in rfid_api.cards_read(): card = rfid_api.card_validate(card_hash) if not card: continue if not card.user_id: r.set('rfid_last_unpaired', card.id) notification_api.notify_subject( b'door_event', json.dumps({ 'event': 'CARD_UNPAIRED', 'card_id': card.id, 'rawdata': rawdata.hex(), })) continue # TODO: # - lookup user_name and send it to the door open hackman_api.door_open_if_paid( card.user_id, source="CARD", rawdata=rawdata, )
def test_card_validate_no_user(random_card): """Check access attempt without a user""" card = api.card_validate(random_card.rfid_hash) assert card.user_id is None c = models.RFIDCard.objects.get(rfid_hash=random_card.rfid_hash) assert c.id == random_card.id
def handle(self, *args, **kwargs): r = get_redis_connection('default') for card_hash in rfid_api.cards_read(): card = rfid_api.card_validate(card_hash) if not card: continue if not card.user_id: r.set('rfid_last_unpaired', card.id) notification_api.notify_subject(b'door_event', json.dumps({ 'event': 'CARD_UNPAIRED', 'card_id': card.id })) continue hackman_api.door_open_if_paid(card.user_id)
def test_card_validate_user(paired_card, card_user): """Check that validate returns correct user if user is associated""" user = api.card_validate(paired_card.rfid_hash) assert user.id == card_user.id
def test_card_validate_db_entry_created(): """Is a new card entry created on validation""" card_hash = hashlib.sha256(os.urandom(10)).hexdigest() api.card_validate(card_hash) assert len(models.RFIDCard.objects.all()) == 1