Beispiel #1
0
def test_create_auth_flow_st(pg_conn):
    create_auth_level(pg_conn, 'sys/app', auth_grant=False)
    create_auth_flow_st(pg_conn, 0, 'sys/app', False)
    rs = retrieve_auth_flow_sts_by_auth_flow_id(pg_conn, 0)
    assert len(rs) == 2
    assert rs[0]['st_name'] == 'sys/app'
    assert rs[0]['st_term'] is False
Beispiel #2
0
def test_retrieve_auth_flow_sts_by_auth_flow_id(pg_conn):
    create_auth_level(pg_conn, 'sys/1', auth_grant=False)
    create_auth_level(pg_conn, 'sys/2', auth_grant=False)
    create_auth_flow_st(pg_conn, 0, 'sys/1', False)
    create_auth_flow_st(pg_conn, 0, 'sys/2', True)
    rs = retrieve_auth_flow_sts_by_auth_flow_id(pg_conn, 0)
    assert rs[0] == {'st_name': 'sys/1', 'st_term': False}
    assert rs[1] == {'st_name': 'sys/2', 'st_term': True}
    assert rs[2] == {'st_name': 'sys/none', 'st_term': False}
Beispiel #3
0
def test_update_auth_flow_st_pk_should_err(pg_conn):
    create_auth_level(pg_conn, 'sys/app', auth_grant=False)
    create_auth_flow_st(pg_conn, 0, 'sys/app', False)
    flow_id = create_auth_flow(pg_conn, auth_flow_desc='Main Flow')
    with pytest.raises(Exception):
        pg_conn.execute(
            'update ac_auth_flow_sts set auth_flow_id=%(flow_id)s where auth_flow_id = %(pk)s',
            {
                'pk': 0,
                'flow_id': flow_id
            })
Beispiel #4
0
def test_delete_auth_levels_by_auth_names(pg_conn):
    created_name = dql_binds.create_auth_level(pg_conn,
                                               'sys/1',
                                               auth_grant=True)
    result = dql_binds.delete_auth_levels_by_auth_names(
        pg_conn, (created_name, ))
    assert result is None
def test_retrieve_auth_levels_by_auth_name(pg_conn):
    infos = [('app/special', True), ('app/special2', False),
             ('user/custom', False)]
    pks = [create_auth_level(pg_conn, *info) for info in infos]
    rs = retrieve_auth_levels_by_auth_name(pg_conn, tuple(pks))
    assert [r['auth_name'] for r in rs] == list(list(zip(*infos))[0])
    assert [r['auth_grant'] for r in rs] == list(list(zip(*infos))[1])
Beispiel #6
0
def test_retrieve_auth_levels_by_auth_name(pg_conn):
    created_name = dql_binds.create_auth_level(pg_conn,
                                               'sys/1',
                                               auth_grant=True)
    records = dql_binds.retrieve_auth_levels_by_auth_name(
        pg_conn, (created_name, ))
    assert len(records) == 1
    assert records[0]['auth_name'] == 'sys/1'
Beispiel #7
0
def test_update_auth_level(pg_conn):
    created_name = dql_binds.create_auth_level(pg_conn,
                                               'sys/1',
                                               auth_grant=True)
    result = dql_binds.update_auth_level(pg_conn,
                                         created_name,
                                         new_auth_name='level-2',
                                         auth_grant=False)
    assert result is None
Beispiel #8
0
def test_create_auth_flow_st(pg_conn):
    created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary')
    created_auth_name = dql_binds.create_auth_level(pg_conn,
                                                    'sys/1',
                                                    auth_grant=True)
    created_record = dql_binds.create_auth_flow_st(pg_conn,
                                                   created_flow_id,
                                                   created_auth_name,
                                                   st_term=False)
    assert created_record['auth_flow_id'] == created_flow_id
    assert created_record['st_name'] == created_auth_name
Beispiel #9
0
def test_retrieve_auth_flow_sts_by_auth_flow_id(pg_conn):
    created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary')
    created_auth_name = dql_binds.create_auth_level(pg_conn,
                                                    'sys/1',
                                                    auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  created_auth_name,
                                  st_term=False)
    records = dql_binds.retrieve_auth_flow_sts_by_auth_flow_id(
        pg_conn, created_flow_id)
    assert len(records) != 0
Beispiel #10
0
def test_delete_auth_flow_st_by_id(pg_conn):
    created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary')
    created_auth_name = dql_binds.create_auth_level(pg_conn,
                                                    'sys/1',
                                                    auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  created_auth_name,
                                  st_term=False)
    result = dql_binds.delete_auth_flow_st_by_id(pg_conn, created_flow_id,
                                                 created_auth_name)
    assert result is None
Beispiel #11
0
def test_retrieve_process_histories_by_ids(pg_conn):
    dql_binds.create_auth_level(pg_conn, 'sys/acc', auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn, 0, 'sys/acc', st_term=True)
    dql_binds.create_auth_flow_tr(pg_conn, 0, 'sys/acc', 'sys/none', 'sys/acc')

    created_proc_id = dql_binds.create_process(pg_conn)
    ctc = dql_binds.create_contact(pg_conn, 'Joe')
    loc_orig = dql_binds.create_location(pg_conn, 'Addr 1')
    loc_dest = dql_binds.create_location(pg_conn, 'Addr 2')
    ckp = dql_binds.create_checkpoint(pg_conn, 'Gate 1')
    dql_binds.update_process(pg_conn,
                             created_proc_id,
                             ctc=ctc,
                             loc_orig=loc_orig,
                             loc_dest=loc_dest,
                             ckp=ckp)
    dql_binds.create_process_auth_event(pg_conn, created_proc_id, ctc,
                                        'sys/acc')
    result = dql_binds.retrieve_process_histories_by_ids(
        pg_conn, (created_proc_id, ))
    assert result
Beispiel #12
0
def test_update_auth_flow_tr(pg_conn):
    created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary')
    dql_binds.create_auth_level(pg_conn, 'sys/1', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/2', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/3', auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/1',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/2',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/3',
                                  st_term=True)
    dql_binds.create_auth_flow_tr(pg_conn, created_flow_id, 'sys/1', 'sys/2',
                                  'sys/3')
    result = dql_binds.update_auth_flow_tr(pg_conn,
                                           created_flow_id,
                                           'sys/2',
                                           'sys/1',
                                           'sys/3',
                                           new_curr_st='sys/1',
                                           new_when_ev='sys/2',
                                           new_next_st='sys/3')
    assert result is None
Beispiel #13
0
def test_archive_finished_processes(pg_conn):
    dql_binds.create_auth_level(pg_conn, 'sys/acc', auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn, 0, 'sys/acc', st_term=True)
    dql_binds.create_auth_flow_tr(pg_conn, 0, 'sys/acc', 'sys/none', 'sys/acc')

    created_proc_id = dql_binds.create_process(pg_conn)
    ctc = dql_binds.create_contact(pg_conn, 'Joe')
    loc_orig = dql_binds.create_location(pg_conn, 'Addr 1')
    loc_dest = dql_binds.create_location(pg_conn, 'Addr 2')
    ckp = dql_binds.create_checkpoint(pg_conn, 'Gate 1')
    dql_binds.update_process(pg_conn,
                             created_proc_id,
                             ctc=ctc,
                             loc_orig=loc_orig,
                             loc_dest=loc_dest,
                             ckp=ckp)

    dql_binds.create_process_auth_event(pg_conn, created_proc_id, ctc,
                                        'sys/acc')
    time.sleep(0.1)
    dql_binds.terminate_process(pg_conn, created_proc_id)
    result = dql_binds.archive_finished_processes(pg_conn)
    assert result
Beispiel #14
0
def test_delete_auth_flow_tr_by_id(pg_conn):
    create_auth_level(pg_conn, 'sys/1', auth_grant=False)
    create_auth_level(pg_conn, 'sys/2', auth_grant=False)
    create_auth_level(pg_conn, 'sys/3', auth_grant=False)
    create_auth_flow_st(pg_conn, 0, 'sys/1', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/2', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/3', st_term=False)
    create_auth_flow_tr(pg_conn, 0, 'sys/2', 'sys/1', 'sys/3')
    delete_auth_flow_tr_by_id(pg_conn, 0, 'sys/2', 'sys/1', 'sys/3')
    rs = retrieve_auth_flow_trs_by_auth_flow_id(pg_conn, 0)
    assert len(rs) == 0
Beispiel #15
0
def test_create_auth_flow_tr(pg_conn):
    create_auth_level(pg_conn, 'sys/1', auth_grant=False)
    create_auth_level(pg_conn, 'sys/2', auth_grant=False)
    create_auth_level(pg_conn, 'sys/3', auth_grant=False)
    create_auth_flow_st(pg_conn, 0, 'sys/1', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/2', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/3', st_term=False)
    create_auth_flow_tr(pg_conn, 0, 'sys/2', 'sys/1', 'sys/3')
    rs = retrieve_auth_flow_trs_by_auth_flow_id(pg_conn, 0)
    assert len(rs) == 1
    assert rs[0]['auth_flow_id'] == 0
    assert rs[0]['curr_st'] == 'sys/1'
    assert rs[0]['when_ev'] == 'sys/2'
    assert rs[0]['next_st'] == 'sys/3'
Beispiel #16
0
def test_create_auth_flow_tr(pg_conn):
    created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary')
    dql_binds.create_auth_level(pg_conn, 'sys/1', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/2', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/3', auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/1',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/2',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/3',
                                  st_term=True)
    dql_binds.create_auth_flow_tr(pg_conn, created_flow_id, 'sys/2', 'sys/1',
                                  'sys/3')
Beispiel #17
0
def test_delete_auth_flow_tr_by_id(pg_conn):
    created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary')
    dql_binds.create_auth_level(pg_conn, 'sys/1', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/2', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/3', auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/1',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/2',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/3',
                                  st_term=True)
    dql_binds.create_auth_flow_tr(pg_conn, created_flow_id, 'sys/2', 'sys/1',
                                  'sys/3')
    result = dql_binds.delete_auth_flow_tr_by_id(pg_conn, created_flow_id,
                                                 'sys/2', 'sys/1', 'sys/3')
    assert result is None
Beispiel #18
0
def test_retrieve_auth_flow_trs_by_auth_flow_id(pg_conn):
    created_flow_id = dql_binds.create_auth_flow(pg_conn, 'primary')
    dql_binds.create_auth_level(pg_conn, 'sys/1', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/2', auth_grant=True)
    dql_binds.create_auth_level(pg_conn, 'sys/3', auth_grant=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/1',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/2',
                                  st_term=True)
    dql_binds.create_auth_flow_st(pg_conn,
                                  created_flow_id,
                                  'sys/3',
                                  st_term=True)
    dql_binds.create_auth_flow_tr(pg_conn, created_flow_id, 'sys/2', 'sys/1',
                                  'sys/3')
    records = dql_binds.retrieve_auth_flow_trs_by_auth_flow_id(
        pg_conn, created_flow_id)
    assert len(records) == 1
Beispiel #19
0
def basic_flow(pg_conn):
    create_auth_level(pg_conn, 'sys/acc', auth_grant=True)
    create_auth_flow_st(pg_conn, 0, 'sys/acc', st_term=True)
    create_auth_flow_tr(pg_conn, 0, 'sys/acc', 'sys/none', 'sys/acc')
    return 0
Beispiel #20
0
def test_delete_auth_flow_st_by_id(pg_conn):
    create_auth_level(pg_conn, 'sys/app', auth_grant=False)
    create_auth_flow_st(pg_conn, 0, 'sys/app', False)
    delete_auth_flow_st_by_id(pg_conn, 0, 'sys/app')
    rs = retrieve_auth_flow_sts_by_auth_flow_id(pg_conn, 0)
    assert len(rs) == 1
def test_update_auth_level(pg_conn):
    pk = create_auth_level(pg_conn, 'app/special', auth_grant=True)
    update_auth_level(pg_conn, pk, new_auth_name='app/201', auth_grant=False)
    rs = retrieve_auth_levels_by_auth_name(pg_conn, ('app/201', ))
    assert rs[0]['auth_name'] == 'app/201'
    assert rs[0]['auth_grant'] is False
def test_delete_auth_levels_by_auth_names(pg_conn):
    pk = create_auth_level(pg_conn, 'app/special', auth_grant=True)
    delete_auth_levels_by_auth_names(pg_conn, (pk, ))
    rs = retrieve_auth_levels_by_auth_name(pg_conn, (pk, ))
    assert len(rs) == 0
def test_create_auth_level(pg_conn):
    pk = create_auth_level(pg_conn, 'app/special', auth_grant=True)
    rs = retrieve_auth_levels_by_auth_name(pg_conn, (pk, ))
    assert len(rs) == 1
    assert rs[0]['auth_name'] == pk
    assert rs[0]['auth_grant'] is True
Beispiel #24
0
def test_update_auth_flow_tr(pg_conn):
    create_auth_level(pg_conn, 'sys/1', auth_grant=False)
    create_auth_level(pg_conn, 'sys/2', auth_grant=False)
    create_auth_level(pg_conn, 'sys/3', auth_grant=False)
    create_auth_level(pg_conn, 'sys/10', auth_grant=False)
    create_auth_level(pg_conn, 'sys/20', auth_grant=False)
    create_auth_level(pg_conn, 'sys/30', auth_grant=False)
    create_auth_flow_st(pg_conn, 0, 'sys/1', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/2', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/3', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/10', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/20', st_term=False)
    create_auth_flow_st(pg_conn, 0, 'sys/30', st_term=False)
    create_auth_flow_tr(pg_conn, 0, 'sys/2', 'sys/1', 'sys/3')
    update_auth_flow_tr(pg_conn,
                        0,
                        'sys/2',
                        'sys/1',
                        'sys/3',
                        new_when_ev='sys/20',
                        new_curr_st='sys/10',
                        new_next_st='sys/30')
    rs = retrieve_auth_flow_trs_by_auth_flow_id(pg_conn, 0)
    assert rs[0]['auth_flow_id'] == 0
    assert rs[0]['curr_st'] == 'sys/10'
    assert rs[0]['when_ev'] == 'sys/20'
    assert rs[0]['next_st'] == 'sys/30'
Beispiel #25
0
def test_create_auth_level(pg_conn):
    created_name = dql_binds.create_auth_level(pg_conn,
                                               'sys/1',
                                               auth_grant=True)
    assert isinstance(created_name, str)
Beispiel #26
0
def basic_levels(pg_conn):
    create_auth_level(pg_conn, 'sys/0001', auth_grant=False)
    create_auth_level(pg_conn, 'sys/0002', auth_grant=False)
    create_auth_level(pg_conn, 'sys/0003', auth_grant=False)
    create_auth_level(pg_conn, 'sys/0004', auth_grant=False)
    create_auth_level(pg_conn, 'sys/0005', auth_grant=True)
Beispiel #27
0
def test_update_auth_flow_st(pg_conn):
    create_auth_level(pg_conn, 'sys/app', auth_grant=False)
    create_auth_flow_st(pg_conn, 0, 'sys/app', False)
    update_auth_flow_st(pg_conn, 0, 'sys/app', True)
    rs = retrieve_auth_flow_sts_by_auth_flow_id(pg_conn, 0)
    assert rs[0]['st_term'] is True