fixed failing unit test

This commit is contained in:
Sebastian Sdorra
2018-07-24 12:56:58 +02:00
parent 947b9497d7
commit 1f60d76f7c
3 changed files with 25 additions and 10 deletions

View File

@@ -70,11 +70,6 @@ public class SecurityFilter extends HttpFilter
@VisibleForTesting
static final String ATTRIBUTE_REMOTE_USER = "principal";
/** Field description */
public static final String URL_AUTHENTICATION = "/api/rest/auth";
public static final String URLV2_AUTHENTICATION = "/api/rest/v2/auth";
private final ScmConfiguration configuration;
@Inject

View File

@@ -100,14 +100,29 @@ public class SecurityFilterTest {
}
/**
* Tests filter on authentication endpoint.
*
* Tests filter on authentication endpoint v1.
*
* @throws IOException
* @throws ServletException
*/
@Test
public void testDoOnAuthenticationUrl() throws IOException, ServletException {
when(request.getRequestURI()).thenReturn("/scm/api/rest/authentication");
public void testDoOnAuthenticationUrlV1() throws IOException, ServletException {
checkIfAuthenticationUrlIsPassedThrough("/scm/api/rest/auth/access_token");
}
/**
* Tests filter on authentication endpoint v2.
*
* @throws IOException
* @throws ServletException
*/
@Test
public void testDoOnAuthenticationUrlV2() throws IOException, ServletException {
checkIfAuthenticationUrlIsPassedThrough("/scm/api/rest/v2/auth/access_token");
}
private void checkIfAuthenticationUrlIsPassedThrough(String uri) throws IOException, ServletException {
when(request.getRequestURI()).thenReturn(uri);
securityFilter.doFilter(request, response, chain);
verify(request, never()).setAttribute(Mockito.anyString(), Mockito.any());
verify(chain).doFilter(request, response);
@@ -235,4 +250,4 @@ public class SecurityFilterTest {
}
}
}

View File

@@ -12,5 +12,10 @@
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-all:1.10.19" level="project" />
<orderEntry type="library" name="Maven: com.github.cloudogu:ces-build-lib:9aadeeb" level="project" />
<orderEntry type="library" name="Maven: com.cloudbees:groovy-cps:1.21" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:11.0.1" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.groovy:groovy-all:2.4.11" level="project" />
</component>
</module>