sync ldap into names #202
Annotations
9 errors and 1 warning
Run tests:
site/tests/ldap/test_ldap.py#L182
test_update_users
KeyError: 'sn'
|
Run tests:
site/cds_rdm/oidc.py#L1
isort-check
"""OIDC settings."""
from flask import current_app, g
+from invenio_access.permissions import system_identity
from invenio_db import db
from invenio_oauthclient import current_oauthclient, oauth_link_external_id
from invenio_oauthclient.contrib.keycloak.handlers import get_user_info
+from invenio_records_resources.proxies import current_service_registry
from invenio_userprofiles.forms import confirm_register_form_preferences_factory
from werkzeug.local import LocalProxy
-from invenio_records_resources.proxies import current_service_registry
-from invenio_access.permissions import system_identity
_security = LocalProxy(lambda: current_app.extensions["security"])
|
Run tests:
site/cds_rdm/ldap/api.py#L1
isort-check
from invenio_users_resources.services.users.tasks import reindex_users
from cds_rdm.ldap.client import LdapClient
-from cds_rdm.ldap.user_importer import LdapUserImporter, update_or_create_names_vocabularies
+from cds_rdm.ldap.user_importer import (
+ LdapUserImporter,
+ update_or_create_names_vocabularies,
+)
from cds_rdm.ldap.utils import InvenioUser, serialize_ldap_user, user_exists
|
Run tests:
site/cds_rdm/ldap/api.py#L1
Black format check
--- /home/runner/work/cds-rdm/cds-rdm/site/cds_rdm/ldap/api.py 2024-09-19 14:35:09.727924+00:00
+++ /home/runner/work/cds-rdm/cds-rdm/site/cds_rdm/ldap/api.py 2024-09-19 14:39:53.519741+00:00
@@ -16,11 +16,14 @@
from invenio_db import db
from invenio_oauthclient.models import RemoteAccount
from invenio_users_resources.services.users.tasks import reindex_users
from cds_rdm.ldap.client import LdapClient
-from cds_rdm.ldap.user_importer import LdapUserImporter, update_or_create_names_vocabularies
+from cds_rdm.ldap.user_importer import (
+ LdapUserImporter,
+ update_or_create_names_vocabularies,
+)
from cds_rdm.ldap.utils import InvenioUser, serialize_ldap_user, user_exists
def get_ldap_users(log_func):
"""Create and return a map of all LDAP users."""
|
Run tests:
site/cds_rdm/ldap/user_importer.py#L1
isort-check
from flask import current_app
from flask_security.confirmable import confirm_user
+from invenio_access.permissions import system_identity
from invenio_accounts.models import User
from invenio_db import db
from invenio_oauthclient.models import RemoteAccount, UserIdentity
+from invenio_records_resources.proxies import current_service_registry
from invenio_userprofiles.models import UserProfile
-from invenio_records_resources.proxies import current_service_registry
-from invenio_access.permissions import system_identity
from sqlalchemy.orm.exc import NoResultFound
|
Run tests:
site/cds_rdm/ldap/user_importer.py#L1
Black format check
--- /home/runner/work/cds-rdm/cds-rdm/site/cds_rdm/ldap/user_importer.py 2024-09-19 14:35:09.727924+00:00
+++ /home/runner/work/cds-rdm/cds-rdm/site/cds_rdm/ldap/user_importer.py 2024-09-19 14:39:54.340952+00:00
@@ -34,11 +34,13 @@
},
"affiliations": [{"name": "CERN"}],
}
try:
- fetched_name = names_service.read(system_identity, ldap_user["remote_account_person_id"])
+ fetched_name = names_service.read(
+ system_identity, ldap_user["remote_account_person_id"]
+ )
# Determine if any updates are necessary
fetched_name_dict = fetched_name.to_dict()
update_needed = False
for key, value in name_data.items():
if key not in fetched_name_dict or fetched_name_dict[key] != value:
@@ -50,10 +52,11 @@
name = names_service.update(system_identity, fetched_name.id, name_data)
except NoResultFound:
name = names_service.create(system_identity, name_data)
return name
+
class LdapUserImporter:
"""Import ldap users to Invenio RDM records.
Expected input format for ldap users:
@@ -106,11 +109,11 @@
user_id=user_id,
extra_data=dict(
keycloak_id=keycloak_id, person_id=employee_id, department=department
),
)
-
+
def import_user(self, ldap_user):
"""Create Invenio users from LDAP export."""
user = self.create_invenio_user(ldap_user)
user_id = user.id
|
Run tests:
site/cds_rdm/ldap/utils.py#L1
isort-check
"""CDS-RDM ldap serializers."""
+import hashlib
from functools import partial
from invenio_accounts.models import User
from invenio_userprofiles import UserProfile
from cds_rdm.ldap.errors import InvalidLdapUser
-import hashlib
def serialize_ldap_user(ldap_user_data, log_func=None):
|
Run tests:
site/cds_rdm/ldap/utils.py#L1
Black format check
--- /home/runner/work/cds-rdm/cds-rdm/site/cds_rdm/ldap/utils.py 2024-09-19 14:35:09.727924+00:00
+++ /home/runner/work/cds-rdm/cds-rdm/site/cds_rdm/ldap/utils.py 2024-09-19 14:39:54.667855+00:00
@@ -131,11 +131,11 @@
def hash_value(value, length=16):
"""Return a hashed version of the value."""
# TODO: we should use a secret to encrypt the value (the repo is public)
- value_bytes = value.encode('utf-8')
+ value_bytes = value.encode("utf-8")
hash_object = hashlib.sha256()
hash_object.update(value_bytes)
hashed_id = hash_object.hexdigest()[:length]
-
- return hashed_id
\ No newline at end of file
+
+ return hashed_id
|
Run tests
Process completed with exit code 1.
|
The following actions use a deprecated Node.js version and will be forced to run on node20: actions/checkout@v3, actions/setup-node@v3. For more info: https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/
|
Loading