Skip to content

Test: GrantsForUser for Accounts for various user to role relationships #5631

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

Open
wants to merge 3 commits into
base: llb-normalized-grants-tests-only
Choose a base branch
from

Conversation

dkanney
Copy link
Collaborator

@dkanney dkanney commented Mar 27, 2025

Refactored the existing GrantsForUser tests from #5443. The logic between these tests is mostly the same -- the only variables are:

  1. The resource being tested
  2. The method of association (direct vs group vs managed group)

As a result, it made sense to refactor the existing three tests into one. Now passing in a principal (the thing being associated to roles), and a role association function (tells us how to associate the principal to its roles)


Note: The tests for resource.Account will not pass until the GrantsForUser refactor is complete. In its current state, GrantsForUser() returns all grants for a user. After the refactor, it'll return a subset of grants based on some new parameters (i.e. resource type, request scope, recursive option). Until then, tests for resource.Account will return roles for all scopes even though resource.Account can only exist at the Global and Org scopes.

@dkanney dkanney self-assigned this Mar 27, 2025
@dkanney dkanney force-pushed the dkanney-test-grants-for-user-accounts branch 2 times, most recently from a1f09df to d173538 Compare April 1, 2025 14:20
dkanney added 3 commits April 1, 2025 11:27
This could be useful across the app as a generic array Map function, so I'm moving it to a helper package.
Note: These tests will fail until GrantsForUser is refactored to return only grants whose scopes are applicable to this resource
@dkanney dkanney force-pushed the dkanney-test-grants-for-user-accounts branch from d173538 to 3504df7 Compare April 1, 2025 15:42
@dkanney dkanney marked this pull request as ready for review April 1, 2025 15:42
@dkanney dkanney requested a review from a team as a code owner April 1, 2025 15:42

// Map maps a slice of one type into a slice of another using the provided map
// function
func Map[T, U any](in []T, f func(T) U) []U {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a need to move this into a separate package? Are we planning on using this elsewhere? If not I would rather leave this in the test package. If we do expect to use this in other places, lets put this in a more descriptive package name and avoid using util.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants