|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2023 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.security.cas.web;
|
18 | 18 |
|
| 19 | +import java.io.IOException; |
| 20 | + |
19 | 21 | import jakarta.servlet.FilterChain;
|
| 22 | +import jakarta.servlet.ServletException; |
20 | 23 | import org.apereo.cas.client.proxy.ProxyGrantingTicketStorage;
|
21 | 24 | import org.junit.jupiter.api.AfterEach;
|
22 | 25 | import org.junit.jupiter.api.Test;
|
@@ -219,4 +222,14 @@ public void successfulAuthenticationWhenProxyRequestThenSavesSecurityContext() t
|
219 | 222 | verify(securityContextRepository).saveContext(any(SecurityContext.class), eq(request), eq(response));
|
220 | 223 | }
|
221 | 224 |
|
| 225 | + @Test |
| 226 | + void successfulAuthenticationWhenSecurityContextRepositorySetThenUses() throws ServletException, IOException { |
| 227 | + SecurityContextRepository securityContextRepository = mock(SecurityContextRepository.class); |
| 228 | + CasAuthenticationFilter filter = new CasAuthenticationFilter(); |
| 229 | + filter.setSecurityContextRepository(securityContextRepository); |
| 230 | + filter.successfulAuthentication(new MockHttpServletRequest(), new MockHttpServletResponse(), |
| 231 | + new MockFilterChain(), mock(Authentication.class)); |
| 232 | + verify(securityContextRepository).saveContext(any(SecurityContext.class), any(), any()); |
| 233 | + } |
| 234 | + |
222 | 235 | }
|
0 commit comments