Skip to content

Add nested AL tests + change IsAccessListMember behaviour#60271

Merged
hugoShaka merged 5 commits intomasterfrom
hugo/nested-al-test-coverage
Oct 22, 2025
Merged

Add nested AL tests + change IsAccessListMember behaviour#60271
hugoShaka merged 5 commits intomasterfrom
hugo/nested-al-test-coverage

Conversation

@hugoShaka
Copy link
Copy Markdown
Contributor

@hugoShaka hugoShaka commented Oct 15, 2025

This PR upstreams some part of #60034 to reduce the size of the PR.

It contains:

  • the IsAccessListMember behaviour change to always return an error if the user is not a member (reduced footgun risk)
  • the IsAccessListOwner behaviour change to always return an error if the user is not an owner (reduced footgun risk)
  • test coverage for nested access lists and cyclic graphs (cycles are skipped as they don't pass today)

The related e PR is :https://github.com/gravitational/teleport.e/pull/7423

This change slightly affects the semantics of returned errors. This doesn't affect the code in the OSS repo but one function in e had to be adapted. The semantic change will also be required for the visitor PR.

@hugoShaka hugoShaka added the no-changelog Indicates that a PR does not require a changelog entry label Oct 15, 2025
@hugoShaka hugoShaka changed the title Add nested AL tests + change IsAccessListMember signature Add nested AL tests + change IsAccessListMember behaviour Oct 16, 2025
@hugoShaka hugoShaka requested a review from smallinsky October 16, 2025 15:06

ownershipType, err := IsAccessListOwner(ctx, stubUserNoRequires, acl4, accessListAndMembersGetter, nil, clock)
require.Error(t, err)
require.ErrorIs(t, err, trace.AccessDenied("User '%s' does not meet the membership requirements for Access List '%s'", member1, acl1.Spec.Title))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not verify those error messages?

Copy link
Copy Markdown
Contributor Author

@hugoShaka hugoShaka Oct 16, 2025

Choose a reason for hiding this comment

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

Because they will change with the visitor PR (it doesn't traverse the graph the same way and cannot produce the same errors). I want the tests to pass for both implementations, without changes


typ, err := IsAccessListMember(ctx, user, firstList, aclGetter, locks, clock)
require.NoError(t, err)
require.Equal(t, accesslistv1.AccessListUserAssignmentType_ACCESS_LIST_USER_ASSIGNMENT_TYPE_INHERITED, typ)
Copy link
Copy Markdown
Contributor

@kopiczko kopiczko Oct 16, 2025

Choose a reason for hiding this comment

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

I think it wouldn't hurt to check IsAccessListMember for all lists in the cycle. Same for the test above.

hugoShaka and others added 2 commits October 16, 2025 15:08
Co-authored-by: Pawel Kopiczko <pawel.kopiczko@goteleport.com>
@hugoShaka
Copy link
Copy Markdown
Contributor Author

@hugoShaka hugoShaka added this pull request to the merge queue Oct 22, 2025
Merged via the queue into master with commit f483fbe Oct 22, 2025
41 checks passed
@hugoShaka hugoShaka deleted the hugo/nested-al-test-coverage branch October 22, 2025 20:42
smallinsky pushed a commit that referenced this pull request Oct 23, 2025
* Add nested AL tests + change IsAccessListMember signature

* address marek's feedback

* fixup! address marek's feedback

* Apply suggestions from code review

Co-authored-by: Pawel Kopiczko <pawel.kopiczko@goteleport.com>

* address pawel's feedback

---------

Co-authored-by: Pawel Kopiczko <pawel.kopiczko@goteleport.com>
mmcallister pushed a commit that referenced this pull request Nov 6, 2025
* Add nested AL tests + change IsAccessListMember signature

* address marek's feedback

* fixup! address marek's feedback

* Apply suggestions from code review

Co-authored-by: Pawel Kopiczko <pawel.kopiczko@goteleport.com>

* address pawel's feedback

---------

Co-authored-by: Pawel Kopiczko <pawel.kopiczko@goteleport.com>
mmcallister pushed a commit that referenced this pull request Nov 19, 2025
* Add nested AL tests + change IsAccessListMember signature

* address marek's feedback

* fixup! address marek's feedback

* Apply suggestions from code review

Co-authored-by: Pawel Kopiczko <pawel.kopiczko@goteleport.com>

* address pawel's feedback

---------

Co-authored-by: Pawel Kopiczko <pawel.kopiczko@goteleport.com>
hugoShaka added a commit that referenced this pull request Nov 20, 2025
* Add nested AL tests + change IsAccessListMember signature

* address marek's feedback

* fixup! address marek's feedback

* Apply suggestions from code review

Co-authored-by: Pawel Kopiczko <pawel.kopiczko@goteleport.com>

* address pawel's feedback

---------

Co-authored-by: Pawel Kopiczko <pawel.kopiczko@goteleport.com>
mmcallister pushed a commit that referenced this pull request Nov 20, 2025
* Add nested AL tests + change IsAccessListMember signature

* address marek's feedback

* fixup! address marek's feedback

* Apply suggestions from code review

Co-authored-by: Pawel Kopiczko <pawel.kopiczko@goteleport.com>

* address pawel's feedback

---------

Co-authored-by: Pawel Kopiczko <pawel.kopiczko@goteleport.com>
github-merge-queue bot pushed a commit that referenced this pull request Nov 21, 2025
…61623)

* Add nested AL tests + change IsAccessListMember signature

* address marek's feedback

* fixup! address marek's feedback

* Apply suggestions from code review



* address pawel's feedback

---------

Co-authored-by: Pawel Kopiczko <pawel.kopiczko@goteleport.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a PR does not require a changelog entry size/md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants