Exemplo n.º 1
0
    def write_row(self, row, out):
        if self._include_badge_nums:
            # add in the barcodes here
            badge_num = row[0]
            barcode = generate_barcode_from_badge_num(badge_num)
            row.append(barcode)

        out.writerow(row)
Exemplo n.º 2
0
    def write_row(self, row, out):
        if self._include_badge_nums:
            # add in the barcodes here
            badge_num = row[1]
            barcode = generate_barcode_from_badge_num(badge_num)
            row.append(barcode)

        out.writerow(row)
Exemplo n.º 3
0
def test_dontfail_wrong_event_id(cfg):
    badge_num = 78946
    barcode = generate_barcode_from_badge_num(badge_num=badge_num)
    decrytped = get_badge_num_from_barcode(barcode_num=barcode,
                                           event_id=2,
                                           verify_event_id_matches=False)
    assert decrytped['badge_num'] == badge_num
    assert decrytped['event_id'] == c.BARCODE_EVENT_ID
Exemplo n.º 4
0
def test_encrypt_decrypt(cfg):
    badge_num = 3
    encrypted = generate_barcode_from_badge_num(badge_num=badge_num)

    assert len(encrypted) == 7
    decrypted = get_badge_num_from_barcode(barcode_num=encrypted)

    assert decrypted['badge_num'] == badge_num
    assert decrypted['event_id'] == c.BARCODE_EVENT_ID
Exemplo n.º 5
0
def test_encrypt_decrypt(cfg):
    badge_num = 3
    encrypted = generate_barcode_from_badge_num(badge_num=badge_num)

    assert len(encrypted) == 7
    decrypted = get_badge_num_from_barcode(barcode_num=encrypted)

    assert decrypted['badge_num'] == badge_num
    assert decrypted['event_id'] == c.BARCODE_EVENT_ID
Exemplo n.º 6
0
def test_dontfail_wrong_event_id(cfg):
    badge_num = 78946
    barcode = generate_barcode_from_badge_num(badge_num=badge_num)
    decrypted = get_badge_num_from_barcode(barcode_num=barcode, event_id=2, verify_event_id_matches=False)
    assert decrypted['badge_num'] == badge_num
    assert decrypted['event_id'] == c.BARCODE_EVENT_ID
Exemplo n.º 7
0
def test_fail_wrong_event_id(cfg, monkeypatch):
    with pytest.raises(ValueError) as ex:
        barcode = generate_barcode_from_badge_num(badge_num=1, event_id=1)
        get_badge_num_from_barcode(barcode_num=barcode, event_id=2)
    assert 'unrecognized event id' in str(ex.value)
Exemplo n.º 8
0
def test_fail_key_length(cfg, monkeypatch):
    monkeypatch.setattr(c, 'BARCODE_KEY', 'X')
    with pytest.raises(ValueError) as ex:
        assert generate_barcode_from_badge_num(badge_num=1)
    assert 'key length should be exactly' in str(ex.value)
Exemplo n.º 9
0
def test_fail_too_high_badges(cfg):
    with pytest.raises(ValueError) as ex:
        assert generate_barcode_from_badge_num(badge_num=0xFFFFFF+1)
    assert 'either badge_number or salt is too large' in str(ex.value)
Exemplo n.º 10
0
def test_fail_wrong_event_id(cfg, monkeypatch):
    with pytest.raises(ValueError) as ex:
        barcode = generate_barcode_from_badge_num(badge_num=1, event_id=1)
        get_badge_num_from_barcode(barcode_num=barcode, event_id=2)
    assert "doesn't match our event ID" in str(ex.value)
Exemplo n.º 11
0
def test_fail_key_length(cfg, monkeypatch):
    monkeypatch.setattr(c, 'BARCODE_KEY', 'X')
    with pytest.raises(ValueError) as ex:
        assert generate_barcode_from_badge_num(badge_num=1)
    assert 'key length should be exactly' in str(ex.value)
Exemplo n.º 12
0
def test_fail_too_high_badges(cfg):
    with pytest.raises(ValueError) as ex:
        assert generate_barcode_from_badge_num(badge_num=0xFFFFFF + 1)
    assert 'either badge_number or salt is too large' in str(ex.value)
Exemplo n.º 13
0
def test_fail_wrong_event_id(cfg, monkeypatch):
    with pytest.raises(ValueError) as ex:
        barcode = generate_barcode_from_badge_num(badge_num=1, event_id=1)
        get_badge_num_from_barcode(barcode_num=barcode, event_id=2)
    assert 'unrecognized event id' in str(ex.value)