-
Notifications
You must be signed in to change notification settings - Fork 0
Add: RenameRequest for entry (LDAP object) #918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds an API endpoint to rename an LDAP entry by running ModifyDN first and then Modify, including a rollback path when Modify fails.
Changes:
- Introduced
RenameRequestschema that orchestrates ModifyDN → Modify with rollback on Modify failure - Added
/entry/renameroute wired to the new request handler - Added API tests plus a fixture to create a computer entry for rollback testing
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_api/test_main/test_router/test_rename.py | Adds happy-path rename test and rollback-on-failure test |
| tests/test_api/test_main/conftest.py | Adds fixture to create a test “computer” LDAP entry |
| app/api/main/schema.py | Implements RenameRequest combining ModifyDN + Modify and rollback logic |
| app/api/main/router.py | Exposes the new /entry/rename endpoint |
| interface | Updates submodule pointer (interface dependency) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/api/main/schema.py
Outdated
| return await modify_dn_request.handle_api(container) | ||
|
|
||
| async def _clear_session_cache(self, container: AsyncContainer) -> None: | ||
| session = await container.get(AsyncSession) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
мб логировать?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не пон, зачем?
название еще не совсем удачное мне показалось, сделал так: _expire_session_objects
| assert data["resultCode"] == LDAPCodes.SUCCESS | ||
| assert data["search_result"][0]["object_name"] == "cn=admin2,dc=md,dc=test" | ||
|
|
||
| for attr in data["search_result"][0]["partial_attributes"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут тоже можно сжать. либо собрать в 1 цикл, либо сделать функцию проверки и снизу тоже заюзать
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
выписал это и отдельным пр сделаю по всем тестам
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
из вариантов такое могу предложить, вролде должно работать
sAMAccountName_found = False
displayName_found = False
for attr in data["search_result"][0]["partial_attributes"]:
if attr["type"] == "sAMAccountName":
assert attr["vals"][0] == "admin2"
sAMAccountName_found = True
elif attr["type"] == "displayName":
assert attr["vals"][0] == "Administrator"
displayName_found = True
if sAMAccountName_found and displayName_found:
break
if not sAMAccountName_found:
raise Exception("User without sAMAccountName")
if not displayName_found:
raise Exception("User without displayName")
#----------------------------
attrs_dict = {attr["type"]: attr["vals"][0]
for attr in data["search_result"][0]["partial_attributes"]}
assert attrs_dict.get("sAMAccountName") == "admin2"
assert attrs_dict.get("displayName") == "Administrator"
app/api/main/schema.py
Outdated
| Combines ModifyDN and Modify operations. | ||
| """ | ||
|
|
||
| object: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
сделай _object, чтобы не трогать зарезервированное
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вообще, в ModifyDNRequest аналогичное поле называется entry. Мб сделать более менее едино?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
делал по аналогии с modify + делал по схеме как в ТЗ
нам бы везде поменять нейминг у реквестов, сейчас предлагаю везде делать по одному неидеальному шаблону
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это надо в общий рефакторинг реквестов уносить, сейчас мы это красиво не обыграем, только разменом костыль на костыль
Сделал ручку для rename директории: в ручке совмещена логика Modify + ModifyDN.
Сначала делаем ModifyDN, а затем Modify.
Именно такой порядок потому что если сделать rollback изменений (в случае падения в Modify) для ModifyDN сделать проще, чем наоборот.
"Проще" из-за того, что для ModifyDN мы можем узнать и старое значение и новое значение. Для Modify мы это так просто не узнаем.
Задача: 1110