Skip to content

Commit

Permalink
fix: jans-linux-setup test client fixes (#3699)
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar committed Jan 26, 2023
1 parent 3494925 commit 72e2f3f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
11 changes: 7 additions & 4 deletions jans-linux-setup/jans_setup/setup_app/installers/jans.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,12 @@ def import_custom_ldif_dir(self, ldif_dir):

def create_test_client(self):
ldif_fn = self.clients_ldif_fn = os.path.join(Config.output_dir, 'test-client.ldif')
client_pw = base.argsp.test_client_secret or self.getPW()
client_id = Config.get('test_client_id') or base.argsp.test_client_id
client_pw = Config.get('test_client_pw') or base.argsp.test_client_secret or self.getPW()
encoded_pw = self.obscure(client_pw)
trusted_client = base.argsp.test_client_trusted or 'false'
trusted_client = Config.get('test_client_trusted_client')
if not trusted_client:
trusted_client = 'true' if base.argsp.test_client_trusted else 'false'

if base.argsp.test_client_redirect_uri:
redirect_uri = base.argsp.test_client_redirect_uri.split(',')
Expand All @@ -447,7 +450,7 @@ def create_test_client(self):

create_client_ldif(
ldif_fn=ldif_fn,
client_id=base.argsp.test_client_id,
client_id=client_id,
encoded_pw=encoded_pw,
scopes=scopes,
redirect_uri=redirect_uri,
Expand All @@ -466,7 +469,7 @@ def create_test_client(self):

def post_install_before_saving_properties(self):

if base.argsp.test_client_id:
if base.argsp.test_client_id or Config.test_client_id:
self.create_test_client()


Expand Down
12 changes: 6 additions & 6 deletions jans-linux-setup/jans_setup/setup_app/utils/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,12 @@ def search(self, search_base, search_filter='(objectClass=*)', search_scope=ldap

sql_cmd = 'SELECT * FROM {} WHERE ({}) {}'.format(s_table, dn_clause, where_clause)

retVal = self.spanner_client.get_dict_data(sql_cmd)
result = self.spanner_client.get_dict_data(sql_cmd)

if not fetchmany and retVal:
retVal = retVal[0]
if not fetchmany and result:
return result[0]

return retVal
return [ (ldif_utils.get_key_from(item['dn']), item) for item in retVal ]

sqlalchemy_table = self.Base.classes[s_table]
sqlalchemyQueryObject = self.session.query(sqlalchemy_table)
Expand All @@ -469,7 +469,7 @@ def search(self, search_base, search_filter='(objectClass=*)', search_scope=ldap

if fetchmany:
result = sqlalchemyQueryObject.all()
return [ item.__dict__ for item in result ]
return [ (ldif_utils.get_key_from(item.dn), item.__dict__) for item in result ]

else:
result = sqlalchemyQueryObject.first()
Expand Down Expand Up @@ -508,7 +508,7 @@ def search(self, search_base, search_filter='(objectClass=*)', search_scope=ldap
data = result.json()
if data.get('results'):
if fetchmany:
return [ item[bucket] for item in data['results'] ]
return [ (ldif_utils.get_key_from(item[bucket]['dn']), item[bucket]) for item in data['results'] ]
else:
return data['results'][0][bucket]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ def load_properties(self, prop_file, no_update=[]):
if p.get('enable-script'):
base.argsp.enable_script = p['enable-script'].split()

if p.get('rdbm_type') == 'pgsql' and not p.get('rdbm_port'):
p['rdbm_port'] = '5432'

properties_list = list(p.keys())

for prop in properties_list:
Expand Down Expand Up @@ -241,7 +244,7 @@ def load_properties(self, prop_file, no_update=[]):
elif p.get('installLdap','').lower() == 'true':
Config.opendj_install = InstallTypes.LOCAL
elif p.get('opendj_install'):
Config.opendj_install = p['opendj_install']
Config.opendj_install = p['opendj_install']
else:
Config.opendj_install = InstallTypes.NONE

Expand All @@ -264,7 +267,6 @@ def load_properties(self, prop_file, no_update=[]):
print("Couchbase package is not available exiting.")
sys.exit(1)


if ('cb_password' not in properties_list) and Config.cb_install:
Config.cb_password = p.get('ldapPass')

Expand Down

0 comments on commit 72e2f3f

Please sign in to comment.