def teardown_module(): # clean up all the mess we made with app.app_context(): models.AuthorizationCode.query.filter_by(tenant_id=TEST_TENANT_ID, client_id=TEST_CLIENT_ID, client_key=TEST_CLIENT_KEY).delete() models.db.session.commit()
def init_db(): with app.app_context(): # add a test client to be used in all the tests data = {'tenant_id': TEST_TENANT_ID, "username": "******", 'client_id': TEST_CLIENT_ID, 'client_key': TEST_CLIENT_KEY, "display_name": "Tapis Authenticator Testsuite", "callback_url": TEST_CLIENT_REDIRECT_URI, 'create_time': datetime.datetime.utcnow(), 'last_update_time': datetime.datetime.utcnow(), 'active': True } models.delete_tenant_from_db(TEST_TENANT_ID) config = { "tenant_id":TEST_TENANT_ID, "allowable_grant_types":json.dumps(["password", "implicit", "authorization_code", "refresh_token", "device_code"]), "use_ldap":True, "use_token_webapp":True, "mfa_config":json.dumps({ "tacc": { "privacy_idea_url": "https://pidea01.tacc.utexas.edu", "privacy_idea_client_id": "p_client", "privacy_idea_client_key": "p_key", "grant_types": [ "authorization_code", "implicit" ] } }), # 4 hours "default_access_token_ttl":14400, # 1 year "default_refresh_token_ttl":31536000, "max_access_token_ttl":31536000, # 2 years "max_refresh_token_ttl":63072000, "custom_idp_configuration":json.dumps({}), "token_url": "", "impers_oauth_client_id": "", "impers_oauth_client_secret": "", "impersadmin_username": "", "impersadmin_password": "" } models.add_tenant_to_db(config) models.add_client_to_db(data) client = models.Client.query.filter_by( tenant_id=data['tenant_id'], client_id=data['client_id'], client_key=data['client_key'] ).first() tenant = models.TenantConfig.query.filter_by( tenant_id=config['tenant_id'] ).first() # if it is somehow not there, we are in real trouble; just bail out. if not tenant: assert False if not client: assert False
def init_db(): with app.app_context(): # add a test client to be used in all the tests data = { 'tenant_id': TEST_TENANT_ID, "username": "******", 'client_id': TEST_CLIENT_ID, 'client_key': TEST_CLIENT_KEY, "display_name": "Tapis Authenticator Testsuite", "callback_url": TEST_CLIENT_REDIRECT_URI, 'create_time': datetime.datetime.utcnow(), 'last_update_time': datetime.datetime.utcnow() } models.add_client_to_db(data) client = models.Client.query.filter_by( tenant_id=data['tenant_id'], client_id=data['client_id'], client_key=data['client_key']).first() # if it is somehow not there, we are in real trouble; just bail out. if not client: assert False
def init_db(): with app.app_context(): models.db.drop_all() models.db.create_all() tenant_owner = models.TenantOwner(id='888', email='*****@*****.**', name='Looney', institution='TACC', create_time=datetime.datetime.now()) models.db.session.add(tenant_owner) models.db.session.commit() tenant_owner = models.TenantOwner(id='999', email='*****@*****.**', name='CIC Support', institution='TACC', create_time=datetime.datetime.now()) models.db.session.add(tenant_owner) models.db.session.commit() tacc_site = models.Site(site_id='tacc', primary=False, base_url='tacc.utexas.edu', tenant_base_url_template='test', site_admin_tenant_id='test', services=['test'], create_time=datetime.datetime.now(), last_update_time=datetime.datetime.now(), created_by='tenants@admin', last_updated_by='tenants@admin') models.db.session.add(tacc_site) models.db.session.commit() ldap_conn1 = models.LDAPConnection( id=111, ldap_id='tacc.test.service', url='ldaps://tapisldap.tacc.utexas.edu', port=636, use_ssl=False, user_dn='ou=tacc.prod.service,dc=tapisapi', bind_dn='uid=ldapbind,ou=People,dc=tacc,dc=utexas,dc=edu', bind_credential='/tapis/tacc.prod.ldapbind', account_type=models.LDAPAccountTypes.service, create_time=datetime.datetime.now()) models.db.session.add(ldap_conn1) models.db.session.commit() ldap_conn2 = models.LDAPConnection( id=999, ldap_id='tacc.test.user', url='ldaps://tapisldap.tacc.utexas.edu', port=636, use_ssl=False, user_dn='ou=tacc.prod.service,dc=tapisapi', bind_dn='uid=ldapbind,ou=People,dc=tacc,dc=utexas,dc=edu', bind_credential='/tapis/tacc.prod.ldapbind', account_type=models.LDAPAccountTypes.user, create_time=datetime.datetime.now()) models.db.session.add(ldap_conn2) models.db.session.commit() tenant = models.Tenant( id=888, tenant_id='dev', base_url='https://dev.develop.tapis.io', admin_user='******', token_gen_services=["test"], site_id='tacc', token_service='https://dev.develop.tapis.io/v3/tokens', authenticator='test-authenticator', security_kernel='https://dev.develop.tapis.io/v3/security', owner='*****@*****.**', service_ldap_connection_id='tacc.test.service', user_ldap_connection_id='tacc.test.user', description='testing', status='active', create_time=datetime.datetime.now(), public_key=conf.dev_jwt_public_key, last_update_time=datetime.datetime.now(), created_by='tenants@admin', last_updated_by='tenants@admin') models.db.session.add(tenant) models.db.session.commit() tenant = models.Tenant( id=999, tenant_id='admin', base_url='https://admin.develop.tapis.io', admin_user='******', site_id='tacc', token_gen_services=['test'], token_service='https://admin.develop.tapis.io/v3/tokens', authenticator='test-authenticator', security_kernel='https://admin.develop.tapis.io/v3/security', owner='*****@*****.**', description='testing', create_time=datetime.datetime.now(), status='active', public_key=conf.dev_jwt_public_key, last_update_time=datetime.datetime.now(), created_by='tenants@admin', last_updated_by='tenants@admin') models.db.session.add(tenant) models.db.session.commit() yield models.db models.db.session.close() models.db.drop_all()