Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for query ldap groups links#1612

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

andrewlarssen
Copy link

You can currently add or delete ldap links but you can't query existing links

@andrewlarssen
Copy link
Author

For issue#1609

@andrewlarssen
Copy link
Author

Have tested this manually on a real gitlab instance. I could not see any automated tests for gitlab -> ldap features

@codecov-commenter
Copy link

codecov-commenter commentedSep 26, 2021
edited by codecovbot
Loading

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.61%. Comparing base (7ea4ddc) to head (772e79a).
⚠️ Report is 1433 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@##             main    #1612      +/-   ##==========================================+ Coverage   91.59%   91.61%   +0.01%==========================================  Files          74       74                Lines        4272     4279       +7     ==========================================+ Hits         3913     3920       +7  Misses        359      359
FlagCoverage Δ
cli_func_v481.63% <100.00%> (+0.03%)⬆️
py_func_v480.64% <100.00%> (+0.03%)⬆️
unit83.40% <100.00%> (+0.02%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

Files with missing linesCoverage Δ
gitlab/v4/objects/groups.py87.87% <100.00%> (+0.67%)⬆️
🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andrewlarssen
Copy link
Author

Fixed 2 linting issues. One was commit message so had to force push

Copy link
Member

@nejchnejch left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks a lot@andrewlarssen! Just a comment on naming consistency. If you're able to add some unit tests to this, would also be great! Herehttps://github.com/python-gitlab/python-gitlab/blob/master/tests/unit/objects/test_groups.py or you could create a newtest_ldap_links.py if it's getting too crowded there. Unit tests mock the responses so we can test EE features there.

While reviewing this I noticed our existing method for deletion uses deprecated API endpoints:https://docs.gitlab.com/ee/api/groups.html#delete-ldap-group-link

So as a bonus if you find time, I think these methods actually could be removed and you can add the CreateMixin/DeleteMixin to the manager, and ObjectDeleteMixin to the object. Then we could remove the custom methods here:

@cli.register_custom_action("Group", ("cn","group_access","provider"))
@exc.on_http_error(exc.GitlabCreateError)
defadd_ldap_group_link(self,cn,group_access,provider,**kwargs):
"""Add an LDAP group link.
Args:
cn (str): CN of the LDAP group
group_access (int): Minimum access level for members of the LDAP
group
provider (str): LDAP provider for the LDAP group
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server cannot perform the request
"""
path="/groups/%s/ldap_group_links"%self.get_id()
data= {"cn":cn,"group_access":group_access,"provider":provider}
self.manager.gitlab.http_post(path,post_data=data,**kwargs)
@cli.register_custom_action("Group", ("cn",), ("provider",))
@exc.on_http_error(exc.GitlabDeleteError)
defdelete_ldap_group_link(self,cn,provider=None,**kwargs):
"""Delete an LDAP group link.
Args:
cn (str): CN of the LDAP group
provider (str): LDAP provider for the LDAP group
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabDeleteError: If the server cannot perform the request
"""
path="/groups/%s/ldap_group_links"%self.get_id()
ifproviderisnotNone:
path+="/%s"%provider
path+="/%s"%cn
self.manager.gitlab.http_delete(path)
)

This would be a breaking change, but we have a major release coming up anyway. Let me know if this makes sense or you need help. Also, you'll just need to amend your message again as commitlint does not like capitalized sentences :)

Comment on lines +41 to +42
"GroupLdapLinks",
"GroupLdapLinksManager",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For consistency with other objects, we should use the single (the API also supports adding a single link)

Suggested change
"GroupLdapLinks",
"GroupLdapLinksManager",
"GroupLdapLink",
"GroupLdapLinkManager",

subgroups:"GroupSubgroupManager"
variables:GroupVariableManager
wikis:GroupWikiManager
ldap_group_links:"GroupLdapLinksManager"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
ldap_group_links:"GroupLdapLinksManager"
ldap_group_links:"GroupLdapLinkManager"

_types= {"skip_groups":types.ListAttribute}


classGroupLdapLinks(RESTObject):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
classGroupLdapLinks(RESTObject):
classGroupLdapLink(RESTObject):

Comment on lines +330 to +332
classGroupLdapLinksManager(ListMixin,RESTManager):
_path="/groups/%(group_id)s/ldap_group_links"
_obj_cls=GroupLdapLinks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
classGroupLdapLinksManager(ListMixin,RESTManager):
_path="/groups/%(group_id)s/ldap_group_links"
_obj_cls=GroupLdapLinks
classGroupLdapLinkManager(ListMixin,RESTManager):
_path="/groups/%(group_id)s/ldap_group_links"
_obj_cls=GroupLdapLink

@github-actions
Copy link

This Pull Request (PR) was marked stale because it has been open 90 days with no activity. Please remove the stale label or comment on this PR. Otherwise, it will be closed in 15 days.

@github-actions
Copy link

This PR was closed because it has been marked stale for 15 days with no activity. If this PR is still valid, please re-open.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nejchnejchnejch requested changes

Assignees

@andrewlarssenandrewlarssen

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@andrewlarssen@codecov-commenter@nejch

[8]ページ先頭

©2009-2025 Movatter.jp