Skip to content

Fix AWS Console apps logins not being provided in all places#44992

Merged
gabrielcorado merged 1 commit intomasterfrom
gabrielcorado/fix-app-logins-enriched-resources
Aug 21, 2024
Merged

Fix AWS Console apps logins not being provided in all places#44992
gabrielcorado merged 1 commit intomasterfrom
gabrielcorado/fix-app-logins-enriched-resources

Conversation

@gabrielcorado
Copy link
Copy Markdown
Contributor

@gabrielcorado gabrielcorado commented Aug 2, 2024

Closes #45086

#44611 Changed the app resources to return the Logins field (from enriched resources) for AWS Console apps. However, the change needed to be completed, and the field needed to be added in some places.

TLDR: Tests weren't covering this scenario, so this PR also updates them.

Two tests cover those scenarios. However, none of them caught this issue:

  • TestListResources_WithLogins: AppServer wasn't added to the list of resources fetched by the test.
  • TestListUnifiedResources_WithLogins: This listing process was hard coded to fetch only a limited number of resources, meaning the resulting list would usually never return the apps. (The flakiness on this test was a case where the apps were included on the final list and returned). To improve it, we now consume all resources and assert the final number of resources, so if we add more resources, the test will fail. Hard coding the number of resources could be better. Still, a more scalable solution would require refactoring other tests, so I kept the changes scoped only for the affected tests.

@gabrielcorado gabrielcorado added the no-changelog Indicates that a PR does not require a changelog entry label Aug 2, 2024
@gabrielcorado gabrielcorado self-assigned this Aug 2, 2024
@github-actions github-actions Bot requested review from gzdunek and probakowski August 2, 2024 00:42
Copy link
Copy Markdown
Contributor

@greedy52 greedy52 left a comment

Choose a reason for hiding this comment

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

Is my understanding correct if this is fixed, then #44983 won't need to use the unified resource api?

Comment on lines +1780 to +1784
var checkableResource services.AccessCheckable = resource
if appServer, ok := resource.(types.AppServer); ok {
checkableResource = appServer.GetApp()
}

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.

should this be part of GetAllowedLoginsForResource?

if err != nil {
return nil, trace.Wrap(err)
}
if !req.IncludeLogins && (r.GetKind() != types.KindNode || r.GetKind() != types.KindWindowsDesktop || r.GetKind() != types.KindAppServer) {
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.

nit: not sure how i feel about this check. Do we have to keep expanding this when new types is added to GetAllowedLoginsForResource? Could we maybe always call GetAllowedLoginsForResource for req.IncludeLogins and skip certain errors like trace.NotImplemented

@gabrielcorado
Copy link
Copy Markdown
Contributor Author

gabrielcorado commented Aug 2, 2024

Is my understanding correct if this is fixed, then #44983 won't need to use the unified resource api?

It must use an endpoint that returns enriched resources (ListResources or ListUnifiedResources).

@greedy52
Copy link
Copy Markdown
Contributor

greedy52 commented Aug 2, 2024

Is my understanding correct if this is fixed, then #44983 won't need to use the unified resource api?

It must use an endpoint that returns enriched resources (ListResources or ListUnifiedResources).

I thought the current tc.ListApps calls ListResources

@gabrielcorado
Copy link
Copy Markdown
Contributor Author

I thought the current tc.ListApps calls ListResources

It does, but it does through the GetAllResources function which relies on GetResourcesPage and only returns the resource, not the logins. To get the logins, it should use the GetEnrichedResourcesPage which uses the same GetResourcesPage but maps to types.EnrichedResource.

@greedy52
Copy link
Copy Markdown
Contributor

greedy52 commented Aug 2, 2024

GetEnrichedResourcesPage

Seems to me a good opportunity to switch tc to use that. Well, let's discuss that on other PR.

@gabrielcorado gabrielcorado added this pull request to the merge queue Aug 21, 2024
Merged via the queue into master with commit c6f1396 Aug 21, 2024
@gabrielcorado gabrielcorado deleted the gabrielcorado/fix-app-logins-enriched-resources branch August 21, 2024 17:06
@public-teleport-github-review-bot
Copy link
Copy Markdown

@gabrielcorado See the table below for backport results.

Branch Result
branch/v16 Failed

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/sm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TestListUnifiedResources_WithLogins flakiness

3 participants