← All Spring Framework Flashcard Decks

Spring Security & Testing Flashcards

6 cards from real Spring Framework practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 6 Spring Security & Testing flashcards as text
  1. What does CSRF stand for in Spring Security?

    Answer: Cross-Site Request Forgery

    CSRF (Cross-Site Request Forgery) is an attack where a malicious site tricks an authenticated user's browser into making unwanted requests to another site.

  2. How do you write a Spring MVC controller unit test that bypasses the full security filter chain?

    Answer: @WebMvcTest with @WithMockUser

    @WebMvcTest loads only the web layer and @WithMockUser (from Spring Security Test) injects a mock authenticated user into the SecurityContext.

  3. What is the purpose of Spring Security's SecurityContextHolder?

    Answer: Stores the currently authenticated user's details throughout a request

    SecurityContextHolder stores the SecurityContext (which contains the Authentication object) for the current thread, making the user's identity available throughout the request lifecycle.

  4. Which Spring Security filter is responsible for processing form-based username/password login?

    Answer: UsernamePasswordAuthenticationFilter

    UsernamePasswordAuthenticationFilter intercepts login form submissions, extracts credentials, and delegates to an AuthenticationManager for validation.

  5. What annotation in Spring Security Test gives a test method a custom user with specific roles?

    Answer: @WithMockUser

    @WithMockUser populates the SecurityContext with a mock user, configurable with username, roles, and authorities, without requiring actual authentication.

  6. What is the role of UserDetailsService in Spring Security?

    Answer: Loads user-specific data from a data source during authentication

    UserDetailsService is a core interface with a single loadUserByUsername() method that retrieves a UserDetails object from the application's data source.

How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. Exam facts are checked against the official sources listed below. Not reviewed by a subject-matter expert. Editorial policy

Sources & references

Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy

  1. docs.broadcom.com — Test delivery, retake policy, exam information · verified Oct 2026
  2. spring-academy.broadcom.com — Eligibility · verified Oct 2026
  3. broadcom.com — Fees, exam format, passing score, time limit · verified Oct 2026