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

Added config interceptor for in-memory server #1000

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

etrandafir93
Copy link

Closes #938

Copy link
Collaborator

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

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

Thanks, @etrandafir93! It's nice to have you contributing.

I've left some feedback inline. Also as a general note, will you please add JavaDoc to any new methods or classes that you create and in those JavaDoc ensure that you have the following:

@since 3.3

return newEmbeddedServer(defaultPartitionName, defaultPartitionSuffix, port, ConfigInterceptor.doNothing());
}

public static EmbeddedLdapServer newEmbeddedServer(String defaultPartitionName, String defaultPartitionSuffix,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer to not continue extending the list of parameters for this method. In fact, I think the existing static approach should likely be deprecated at some point.

Instead, let's create a Builder class that constructs an EmbeddedLdapServer. This will allow some reasonable defaults for the port (0) and partition name (the first dc) that the builder can take on, ultimately simplifying construction, e.g.:

Name suffix = LdapUtils.newLdapName("dc=jayway,dc=se");
EmbeddedLdapServer ldap = EmbeddedLdapServer
    .withPartitionSuffix(suffix)
    .config((config) -> config.setCodeLogDetails(...)).build();

Separating this concern allows the instance to be started up more strategically.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In going this route, will you please in a separate commit add a start method? It should wrap any UnboundID exceptions and rethrow a RuntimeException.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the feedback @jzheaux, I'll start working on these comments.

Since we're add the start() method, what do you think about implementing AutoClosable as well (and call the already existing shotdown() ) ?
For those who create the server programmatically using the builder, this will allow them to create it in a try-with-resources block.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I think this is a good idea, @etrandafir93. Will you please open a ticket to add the start() and AutoCloseable and then reference that ticket in this separate commit?

Copy link
Author

Choose a reason for hiding this comment

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

@jzheaux sure, I created #1025. I can also do it in 2 different PRs - or do you prefer commits in the same PR?

@@ -97,8 +100,13 @@ public void setContextSource(ContextSource contextSource) {
this.contextSource = contextSource;
}

public void setConfigInterceptor(ConfigInterceptor configInterceptor) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's please leave this out of the TestContextSourceFactoryBean class for now. I'd prefer that folks configure the server and the LdifPopulator separately.

@@ -225,3 +225,54 @@ To use it, create a bean similar to the following:
====

Also, `org.springframework.ldap.test.unboundid.LdapTestUtils` provide methods to programmatically work with an embedded LDAP server.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you move this to earlier in the doc and demonstrate it through the EmbeddedLdapServerFactoryBean class?


[source,java]
----
LdapTestUtils.startEmbeddedServer(1888, "dc=jayway,dc=se", "jayway",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better to focus on using EmbeddedLdapServer directly. Also, please consider wrapping this in a @Bean definition so that it's equivalent to the XML snippet.

@jzheaux
Copy link
Collaborator

jzheaux commented Feb 12, 2025

Sorry about the DCO failure. I'll ping @rwinch and see if it is something on our side.

@jzheaux jzheaux added this to the 3.3.x milestone Feb 12, 2025
@jzheaux
Copy link
Collaborator

jzheaux commented Feb 12, 2025

@etrandafir93, I wonder if it is because the identifiers don't agree.

On your commit, it shows the email as:

Author: emanueltrandafir1993 <[email protected]>

But the Signed-Off-By is:

Signed-off-by: Emanuel Trandafir <[email protected]>

@jzheaux
Copy link
Collaborator

jzheaux commented Feb 12, 2025

Here is the error message when clicking the Details link:

Commit sha: [0760e19](https://github.com/spring-projects/spring-ldap/pull/1000/commits/0760e1941d75993b81db828bc8b661427ba7f67f), Author: emanueltrandafir1993, Committer: emanueltrandafir1993; Expected "emanueltrandafir1993 [[email protected]](mailto:[email protected])", but got "Emanuel Trandafir [[email protected]](mailto:[email protected])".

So I believe that may be the case.

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

Successfully merging this pull request may close these issues.

Simplify Configuring Operational Attributes in Embedded Test Servers
2 participants