-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the loginProcessingUrl configurable for saml2Login()
- Loading branch information
Showing
6 changed files
with
125 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
.../security/saml2/provider/service/servlet/filter/Saml2WebSsoAuthenticationFilterTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright 2002-2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.security.saml2.provider.service.servlet.filter; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
import org.springframework.mock.web.MockHttpServletRequest; | ||
import org.springframework.mock.web.MockHttpServletResponse; | ||
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository; | ||
|
||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import static org.mockito.Mockito.mock; | ||
|
||
public class Saml2WebSsoAuthenticationFilterTests { | ||
|
||
private Saml2WebSsoAuthenticationFilter filter; | ||
private RelyingPartyRegistrationRepository repository = mock(RelyingPartyRegistrationRepository.class); | ||
private MockHttpServletRequest request = new MockHttpServletRequest(); | ||
private HttpServletResponse response = new MockHttpServletResponse(); | ||
|
||
@Rule | ||
public ExpectedException exception = ExpectedException.none(); | ||
|
||
@Before | ||
public void setup() { | ||
filter = new Saml2WebSsoAuthenticationFilter(repository); | ||
request.setPathInfo("/login/saml2/sso/idp-registration-id"); | ||
request.setParameter("SAMLResponse", "xml-data-goes-here"); | ||
} | ||
|
||
@Test | ||
public void constructingFilterWithMissingRegistrationIdVariableThenThrowsException() { | ||
exception.expect(IllegalArgumentException.class); | ||
exception.expectMessage("filterProcessesUrl must contain a {registrationId} match variable"); | ||
filter = new Saml2WebSsoAuthenticationFilter(repository, "/url/missing/variable"); | ||
} | ||
|
||
@Test | ||
public void constructingFilterWithValidRegistrationIdVariableThenSucceeds() { | ||
filter = new Saml2WebSsoAuthenticationFilter(repository, "/url/variable/is/present/{registrationId}"); | ||
} | ||
|
||
@Test | ||
public void requiresAuthenticationWhenHappyPathThenReturnsTrue() { | ||
Assert.assertTrue(filter.requiresAuthentication(request, response)); | ||
} | ||
|
||
@Test | ||
public void requiresAuthenticationWhenCustomProcessingUrlThenReturnsTrue() { | ||
filter = new Saml2WebSsoAuthenticationFilter(repository, "/some/other/path/{registrationId}"); | ||
request.setPathInfo("/some/other/path/idp-registration-id"); | ||
request.setParameter("SAMLResponse", "xml-data-goes-here"); | ||
Assert.assertTrue(filter.requiresAuthentication(request, response)); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters