Skip to content

server: enable TestServerControllerLoginLogout for secondary tenants#143354

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
shubhamdhama:fix-TestServerControllerLoginLogout
Apr 9, 2025
Merged

server: enable TestServerControllerLoginLogout for secondary tenants#143354
craig[bot] merged 1 commit intocockroachdb:masterfrom
shubhamdhama:fix-TestServerControllerLoginLogout

Conversation

@shubhamdhama
Copy link
Copy Markdown
Contributor

Fixes: #110002
Epic: CRDB-38970
Release note: none

@shubhamdhama shubhamdhama requested a review from a team as a code owner March 24, 2025 11:51
@shubhamdhama shubhamdhama requested review from Copilot and removed request for a team March 24, 2025 11:51
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the TestServerControllerLoginLogout test to accommodate secondary tenant behavior by modifying server startup parameters, adjusting the HTTP method for logout, and tailoring cookie expectations based on the deployment mode.

  • Removed the DefaultTestTenant parameter when starting the server.
  • Changed the logout request from POST to GET to reflect updated endpoint behavior.
  • Altered expected cookie names and values based on the external deployment mode.
Comments suppressed due to low confidence (1)

pkg/ccl/serverccl/server_controller_test.go:566

  • The removal of the DefaultTestTenant parameter affects how secondary tenant logic is initialized. Ensure that this change still properly verifies login/logout behavior for secondary tenants as intended.
srv := serverutils.StartServerOnly(t, base.TestServerArgs{})

@shubhamdhama shubhamdhama requested review from a team and cthumuluru-crdb March 24, 2025 16:08
@shubhamdhama shubhamdhama requested a review from dhartunian April 8, 2025 06:27
Copy link
Copy Markdown
Collaborator

@dhartunian dhartunian left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @copilot-pull-request-reviewer[bot], @cthumuluru-crdb, and @shubhamdhama)


pkg/ccl/serverccl/server_controller_test.go line 587 at r1 (raw file):

		// TODO: Not sure why 'Secure' isn't set for logout in external mode,
		// even though it's set in other cases. This isn't just a test issue —
		// it happens outside of tests too.

I think this is because there's different code for logging out in single and multi-tenant setups:

multi-tenant logout: https://github.com/cockroachdb/cockroach/blob/master/pkg/server/server_controller_http.go#L334-L336

single-tenant logout: https://github.com/cockroachdb/cockroach/blob/master/pkg/server/authserver/authentication.go#L416-L419

I wrote these changes and if I want to remember why I did this, I think it was likely because when I added the forHTTPSOnly flag I didn't want to break existing cookie callsites so I defaulted to false. It seemed OK not to force the logout cookie to be secure. Also, it seems like during logout we don't have the context of whether our original cookie was secure, although I'm sure we can retrieve that somehow. My thinking was that forcing logout in more scenarios than not (by not making the cookie secure) was a good tradeoff.

Copy link
Copy Markdown
Contributor

@cthumuluru-crdb cthumuluru-crdb left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @copilot-pull-request-reviewer[bot], @dhartunian, and @shubhamdhama)


pkg/ccl/serverccl/server_controller_test.go line 587 at r1 (raw file):

Previously, dhartunian (David Hartunian) wrote…

I think this is because there's different code for logging out in single and multi-tenant setups:

multi-tenant logout: https://github.com/cockroachdb/cockroach/blob/master/pkg/server/server_controller_http.go#L334-L336

single-tenant logout: https://github.com/cockroachdb/cockroach/blob/master/pkg/server/authserver/authentication.go#L416-L419

I wrote these changes and if I want to remember why I did this, I think it was likely because when I added the forHTTPSOnly flag I didn't want to break existing cookie callsites so I defaulted to false. It seemed OK not to force the logout cookie to be secure. Also, it seems like during logout we don't have the context of whether our original cookie was secure, although I'm sure we can retrieve that somehow. My thinking was that forcing logout in more scenarios than not (by not making the cookie secure) was a good tradeoff.

Thanks, @dhartunian. @shubhamdhama, can you please summarize this context and replace the comment.

@shubhamdhama shubhamdhama force-pushed the fix-TestServerControllerLoginLogout branch from 68b3608 to 5fedd3e Compare April 9, 2025 09:17
@shubhamdhama shubhamdhama force-pushed the fix-TestServerControllerLoginLogout branch from 5fedd3e to bb339e1 Compare April 9, 2025 09:20
@shubhamdhama
Copy link
Copy Markdown
Contributor Author

Thanks for the complete context, David. And thanks y'all for the review.

bors r=dhartunian,cthumuluru-crdb

@craig craig bot merged commit 974ef4a into cockroachdb:master Apr 9, 2025
24 checks passed
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Apr 9, 2025

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.

serverccl: TestServerControllerLoginLogout misbehaves when pointed to a secondary tenant

5 participants