示例#1
0
文件: sso_init.py 项目: rafoul/pytest
def sso_roles(conn):
    tenant_key = db2.unique(conn, 'select * from SSO_TENANTS where name = ?', 'default')['TENANT_KEY']
    
    roles = db2.query(conn, '''
        select * from roles
    ''')    
    
    for role in roles:
        yield(role['ROLE_KEY'], role['NAME'], 1, role['DESC'], tenant_key, datetime.datetime.now())
示例#2
0
文件: sso_init.py 项目: rafoul/pytest
def sso_users(conn):
    tenant_key = db2.unique(conn, 'select * from SSO_TENANTS where name = ?', 'default')['TENANT_KEY']
    
    users = db2.query(conn, '''
        select * from users
    ''')
    
    for user in users:
        yield (user['USER_KEY'], user['PASSWORD'], user['USER_NAME'], user['USER_NAME'], tenant_key,
               user['CREATE_TS'], user['MODIFY_TS'])    
示例#3
0
def initialize_test_data(conn):

    
    import random      
    
    all_resource_keys = list(db2.query(conn, 'select resource_key from resources'))
    random.shuffle(all_resource_keys)
    
    def random_resource_for_authority(auth, count):
        for i in range(0, count):
            yield (auth, all_resource_keys[i]['RESOURCE_KEY'])
    
    populate_authority_resource(conn, random_resource_for_authority(-1, 4))
    populate_authority_resource(conn, random_resource_for_authority(-2, 3))
示例#4
0
def get_authority_resource(conn, app):
    authorities = ['AUTH_TEST']
    for auth in authorities:
        auth = db2.unique(conn, 'select authority_key from authorities where code = ?', auth)
        for resource_key in db2.query(conn, 'select resource_key from resources'):
            yield (auth['AUTHORITY_KEY'], resource_key['RESOURCE_KEY'])
示例#5
0
def get_metadatas(conn):
    for m in db2.query(conn, 'select * from metadatas'):
        yield (m['METADATA_KEY'], m['METADATA_TYPE_CODE'], m['METADATA_TYPE_DESC'],
               m['METADATA_CODE'], m['METADATA_DESC'], m['DISABLE'], m['PARENT_KEY'])
示例#6
0
文件: sso_init.py 项目: rafoul/pytest
def sso_user_role(conn):
    for user_role in db2.query(conn, 'select * from user_role'):
        yield (user_role['USER_KEY'], user_role['ROLE_KEY'])
示例#7
0
文件: sso_init.py 项目: rafoul/pytest
def sso_tenants(conn):
    for tenant in db2.query(conn, 'select * from sso_tenants'):
        yield (tenant['TENANT_KEY'], tenant['NAME'], tenant['DESC'], tenant['ENABLED'], 'TEST_TENANT', tenant['CREATE_TIME'], tenant['MODIFY_TIME'])