Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
k-burt-uch committed Jan 22, 2025
1 parent 87d4649 commit e45640a
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions fence/sync/sync_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,13 @@ def _parse_csv(self, file_dict, sess, dbgap_config={}, encrypted=True):
tags["pi"] = row["downloader for names"]

user_info[username] = {
"email": row.get("email") or user_info[username].get('email') or "",
"email": row.get("email")
or user_info[username].get("email")
or "",
"display_name": display_name,
"phone_number": row.get("phone") or user_info[username].get('phone_number') or "",
"phone_number": row.get("phone")
or user_info[username].get("phone_number")
or "",
"tags": tags,
}

Expand Down Expand Up @@ -967,10 +971,10 @@ def sync_to_storage_backend(self, user_project, user_info, sess, expires):
google_group_user_mapping = {}
get_or_create_proxy_group_id(
expires=expires,
user_id=user_info['user_id'],
username=user_info['username'],
user_id=user_info["user_id"],
username=user_info["username"],
session=sess,
storage_manager=self.storage_manager
storage_manager=self.storage_manager,
)

# TODO: eventually it'd be nice to remove this step but it's required
Expand All @@ -987,14 +991,11 @@ def sync_to_storage_backend(self, user_project, user_info, sess, expires):
for project, _ in projects.items():
syncing_user_project_list.add((username.lower(), project))


to_add = set(syncing_user_project_list)

# when updating users we want to maintain case sensitivity in the username so
# pass the original, non-lowered user_info dict
self._upsert_userinfo(sess, {
user_info['username'].lower(): user_info
})
self._upsert_userinfo(sess, {user_info["username"].lower(): user_info})

self._grant_from_storage(
to_add,
Expand Down Expand Up @@ -1473,6 +1474,7 @@ def _process_user_projects(
dbgap_config,
sess,
):
user_projects_to_modify = copy.deepcopy(user_projects)
for username in user_projects.keys():
for project in user_projects[username].keys():
phsid = project.split(".")
Expand Down Expand Up @@ -1509,7 +1511,7 @@ def _process_user_projects(
privileges,
username,
sess,
user_projects,
user_projects_to_modify,
dbgap_config,
)

Expand All @@ -1520,9 +1522,12 @@ def _process_user_projects(
privileges,
username,
sess,
user_projects,
user_projects_to_modify,
dbgap_config,
)
for k, v in user_projects.items():
if v != user_projects_to_modify[k]:
user_projects[k] = user_projects_to_modify[k]

def sync(self):
if self.session:
Expand Down Expand Up @@ -2485,8 +2490,8 @@ def sync_single_user_visas(self, user, ga4gh_visas, sess=None, expires=None):
projects = {**projects, **project}
parsed_visas.append(visa)

info['user_id'] = user.id
info['username'] = user.username
info["user_id"] = user.id
info["username"] = user.username
user_projects[user.username] = projects

user_projects = self.parse_projects(user_projects)
Expand All @@ -2511,9 +2516,7 @@ def sync_single_user_visas(self, user, ga4gh_visas, sess=None, expires=None):

if user_projects:
self.logger.info("Sync to storage backend [sync_single_user_visas]")
self.sync_to_storage_backend(
user_projects, info, sess, expires=expires
)
self.sync_to_storage_backend(user_projects, info, sess, expires=expires)
else:
self.logger.info("No users for syncing")

Expand Down

0 comments on commit e45640a

Please sign in to comment.