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

Enable security manager for active directory tests #112411

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Aug 31, 2024

When active directory tests switched to using test rules for manager docker fixtures, the security manager was disabled. This commit re-enables the security manager, and isolates the docker setup/start to not run under security manager.

When active directory tests switched to using test rules for manager
docker fixtures, the security manager was disabled. This commit
re-enables the security manager, and isolates the docker setup/start to
not run under security manager.
@rjernst rjernst added >test Issues or PRs that are addressing/adding tests :Core/Infra/Core Core issues without another label :Security/Security Security issues without another label labels Aug 31, 2024
@rjernst rjernst requested a review from a team as a code owner August 31, 2024 12:59
@elasticsearchmachine elasticsearchmachine added Team:Core/Infra Meta label for core/infra team Team:Security Meta label for security team v8.16.0 labels Aug 31, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

*
* @return A closeable object which restores the test security manager
*/
@SuppressWarnings("removal")
public static Closeable disableTestSecurityManager() {
var caller = Thread.currentThread().getStackTrace()[2];
if (ESTestCase.class.getName().equals(caller.getClassName()) == false) {
throw new SecurityException("Cannot disable test SecurityManager directly. Use @NoSecurityManager to disable on a test suite");
Copy link
Member Author

Choose a reason for hiding this comment

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

Note for core/infra: I've relaxed this requirement to enable broader use of disabling security manager for parts of testing. The most important thing is to ensure security manager is not disabled and forgotten. We already return a releasable object, and additional validation ensures we haven't forgotten to re-enable security manager between tests.

Copy link
Contributor

@ldematte ldematte left a comment

Choose a reason for hiding this comment

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

LGTM (after checking why tests fail)

* Temporarily dsiables security manager for a test.
*
* <p> This method is only callable by {@link org.elasticsearch.test.ESTestCase}.
* Temporarily disables security manager for a test.
*
* @return A closeable object which restores the test security manager
*/
@SuppressWarnings("removal")
public static Closeable disableTestSecurityManager() {
Copy link
Member

Choose a reason for hiding this comment

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

We could change this to return Releaseable so we don't need to catch IOException in the methods below?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label :Security/Security Security issues without another label Team:Core/Infra Meta label for core/infra team Team:Security Meta label for security team >test Issues or PRs that are addressing/adding tests v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants