Skip to content
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

Fix broken auth Access Request creation tests #49258

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

kopiczko
Copy link
Contributor

This got exposed while working on Access Request reason required PR: #49124

This got exposed while working on Access Request reason required PR:
#49124
@kopiczko kopiczko added the no-changelog Indicates that a PR does not require a changelog entry label Nov 20, 2024
Comment on lines -8066 to 8076
requestRole, err := types.NewRole("requestRole", types.RoleSpecV6{})
requestRole, err := types.NewRole("requestRole", types.RoleSpecV6{
Allow: types.RoleConditions{
GroupLabels: types.Labels{
types.Wildcard: []string{types.Wildcard},
},
NodeLabels: types.Labels{
types.Wildcard: []string{types.Wildcard},
},
},
})
require.NoError(t, err)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This role wasn't created before, because searchRole above had the same name ("requestRole") and srv.Auth().CreateRole(ctx, requestRole) call (below) wasn't checked for error.

@kopiczko kopiczko marked this pull request as ready for review November 20, 2024 13:29
)
require.NoError(t, err)

_, err = srv.Auth().UpsertNode(ctx, nodeAllowedByRequestRole)
Copy link
Member

@ravicious ravicious Nov 20, 2024

Choose a reason for hiding this comment

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

Are we able to avoid doing upserts here? I know that due to how our cache works, it's safe in tests to create a resource and then not wait for the change to propagate. This isn't true when performing an update, so you run into a risk of having a flaky test. The rest of the code in the test might execute without observing the change to nodeAllowedByRequestRole.

See the question I asked about this on Slack some time ago.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing out. AFAICT there is nothing like CreateNode. Only upsert. Also in this particular case cache is not set in the auth server.

@kopiczko kopiczko added this pull request to the merge queue Nov 20, 2024
Merged via the queue into master with commit 79c69d5 Nov 20, 2024
44 checks passed
@kopiczko kopiczko deleted the kopiczko/fix-broken-access-request-creation-tests branch November 20, 2024 22:17
@kopiczko kopiczko restored the kopiczko/fix-broken-access-request-creation-tests branch November 26, 2024 20:28
@public-teleport-github-review-bot

@kopiczko See the table below for backport results.

Branch Result
branch/v17 Create PR

@kopiczko kopiczko deleted the kopiczko/fix-broken-access-request-creation-tests branch November 26, 2024 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/sm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants