Skip to content

Remove unused imports and fixes some compile time errors for some tests #4934

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

Conversation

adolfoweloy
Copy link
Contributor

  • Remove invalid imports referencing org.springframework.security.config.annotation.authentication.AuthenticationManagerBuilder.

  • Change the way to use contains method from Asssertions class from Assertj. When checking
    for a concrete class against a generic collection, Eclipse and IntelliJ were presenting compiling time errors. There is an issue regarding the usage of generic types on contains method from Assertions class as follows:

assertj/assertj#772

  • Change DelegatingOAuth2UserServiceTests to start using concrete types to create the ArrayList of services that are needed to create an instance of DelegatingOAuth2UserService.

when:
UserDetails userDetails = new UserDetailsManagerConfigurer<InMemoryUserDetailsManager,UserDetailsManagerConfigurer<InMemoryUserDetailsManager>>(userDetailsManager)
Copy link
Member

Choose a reason for hiding this comment

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

These tests are suppose to be validating UserDetailsManagerConfigurer not InMemoryUserDetailsManagerConfigurer. Is there a reason you switched this?

Copy link
Contributor Author

@adolfoweloy adolfoweloy Jan 4, 2018

Choose a reason for hiding this comment

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

In fact I did a mistake here. But rather than parameterizing UserDetailsManagerConfigurer with InMemoryUserDetailsManager I think it should be better to use AuthenticationManagerBuilder as follows (for the first parameter):

UserDetails userDetails = new UserDetailsManagerConfigurer<AuthenticationManagerBuilder,
    InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder>>(userDetailsManager)

That's because as the first generic parameter type for UserDetailsManagerConfigurer which is B extends ProviderManagerBuilder, I realized that it should make sense to use AuthenticationManagerBuilder.

If I keep using InMemoryUserDetailsManager for the first generic parameter type, I got the following error on STS:

Groovy:The type InMemoryUserDetailsManager is not a valid substitute 
for the bounded parameter 
<B extends org.springframework.security.config
.annotation.authentication.ProviderManagerBuilder<B>>

I made the changes to use AuthenticationManagerBuilder as proposed but did not pushed yet just to preserve our conversation here. If you think it makes sense to be applied I can submit the changes.

@rwinch rwinch self-assigned this Jan 3, 2018
@rwinch rwinch added the status: waiting-for-feedback We need additional information before we can continue label Jan 3, 2018
public void loadUserWhenUserRequestIsNullThenThrowIllegalArgumentException() {
DelegatingOAuth2UserService<OAuth2UserRequest, OAuth2User> delegatingUserService =
new DelegatingOAuth2UserService<>(
Arrays.asList(mock(OAuth2UserService.class), mock(OAuth2UserService.class)));
Arrays.asList(mock(DefaultOAuth2UserService.class), mock(DefaultOAuth2UserService.class)));
Copy link
Contributor

Choose a reason for hiding this comment

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

The purpose of this test is to ensure that the OAuth2UserRequest passed into loadUser is not null else throw IllegalArgumentException. Changing the List of OAuth2UserService mocks to DefaultOAuth2UserService doesn't really apply to what is being tested here. Please revert this. Thank you.

@rwinch
Copy link
Member

rwinch commented Jan 10, 2018

Closing in favor of #4949

@rwinch rwinch closed this Jan 10, 2018
@rwinch rwinch removed the status: waiting-for-feedback We need additional information before we can continue label Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants