mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
Fix injection
This commit is contained in:
@@ -111,9 +111,11 @@ public class AuthenticationResourceTest {
|
||||
"}"
|
||||
);
|
||||
|
||||
private AuthenticationResource authenticationResource;
|
||||
|
||||
@Before
|
||||
public void prepareEnvironment() {
|
||||
AuthenticationResource authenticationResource = new AuthenticationResource(accessTokenBuilderFactory, cookieIssuer, null);
|
||||
authenticationResource = new AuthenticationResource(accessTokenBuilderFactory, cookieIssuer);
|
||||
dispatcher.getRegistry().addSingletonResource(authenticationResource);
|
||||
|
||||
AccessToken accessToken = mock(AccessToken.class);
|
||||
@@ -200,7 +202,7 @@ public class AuthenticationResourceTest {
|
||||
|
||||
@Test
|
||||
public void shouldHandleLogoutRedirection() throws URISyntaxException, UnsupportedEncodingException {
|
||||
mockResourceWithLogoutRedirection(of(create("http://example.com/cas/logout")));
|
||||
authenticationResource.setLogoutRedirection(() -> of(create("http://example.com/cas/logout")));
|
||||
|
||||
MockHttpRequest request = MockHttpRequest.delete("/" + AuthenticationResource.PATH + "/access_token");
|
||||
|
||||
@@ -212,7 +214,7 @@ public class AuthenticationResourceTest {
|
||||
|
||||
@Test
|
||||
public void shouldHandleDisabledLogoutRedirection() throws URISyntaxException {
|
||||
mockResourceWithLogoutRedirection(empty());
|
||||
authenticationResource.setLogoutRedirection(Optional::empty);
|
||||
|
||||
MockHttpRequest request = MockHttpRequest.delete("/" + AuthenticationResource.PATH + "/access_token");
|
||||
|
||||
@@ -221,13 +223,6 @@ public class AuthenticationResourceTest {
|
||||
assertEquals(HttpServletResponse.SC_NO_CONTENT, response.getStatus());
|
||||
}
|
||||
|
||||
private void mockResourceWithLogoutRedirection(Optional<URI> target) {
|
||||
dispatcher.getRegistry().removeRegistrations(AuthenticationResource.class);
|
||||
AuthenticationResource authenticationResource =
|
||||
new AuthenticationResource(accessTokenBuilderFactory, cookieIssuer, () -> target);
|
||||
dispatcher.getRegistry().addSingletonResource(authenticationResource);
|
||||
}
|
||||
|
||||
private void shouldReturnBadRequest(String requestBody) throws URISyntaxException {
|
||||
MockHttpRequest request = getMockHttpRequest(requestBody);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user