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

[FEATURE REQ] Add unit testing for Azure AD samples #655

Open
2 tasks done
arranbartish opened this issue Jan 31, 2023 · 2 comments
Open
2 tasks done

[FEATURE REQ] Add unit testing for Azure AD samples #655

arranbartish opened this issue Jan 31, 2023 · 2 comments
Labels
azure-spring All azure-spring related issues

Comments

@arranbartish
Copy link

Is your feature request related to a problem? Please describe.
This is described as a complete example.

learn.microsft.com

For a complete sample demonstrating this scenario, see spring-cloud-azure-starter-active-directory sample: aad-resource-server.

however there is an aspect missing, unit testing. When using @WebMvcTest we discover that the AadResourceServerWebSecurityConfigurerAdapter needs a properties bean AadResourceServerProperties that doesn't seem to be initialized with the slim context.

Describe the solution you'd like

I would like a set of simple tests using @WebMvcTest that would exercise the mappings using the spring security test mechanisms of @WithMockUser, @WithUserDetails, and/or @WithSecurityContext

Describe alternatives you've considered
I am trying to write these now.

I also have a full integration version which exposes a random port and uses the TestRestTemplate to make a call with a custom SecurityContextRepository, however we should be able to easily apply the slim @WebMvcTest context as well.

Additional context
IMHO the appropriate approach to testing is a critical part of a complete example.

Information Checklist

  • Description Added
  • Expected solution specified
@arranbartish arranbartish added the azure-spring All azure-spring related issues label Jan 31, 2023
@fangjian0423 fangjian0423 changed the title [FEATURE REQ] [FEATURE REQ] Add unit testing for Azure AD samples Feb 1, 2023
@nb-git
Copy link

nb-git commented Feb 9, 2023

Thanks @arranbartish that is exactly what I was looking for.
Do you have sample code of how you setup the Integration tests? I am currently stuck at this point.

@arranbartish
Copy link
Author

I do.

I'll fork and PR back. The integration test was really a last resort for me. It would be better if we could get @WebMvcTest to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-spring All azure-spring related issues
Projects
None yet
Development

No branches or pull requests

2 participants