Skip to content

Commit

Permalink
Merge remote-tracking branch 'steven/boostedCoverage' into boostedCov…
Browse files Browse the repository at this point in the history
…erage
  • Loading branch information
peternied committed Aug 22, 2023
2 parents 8bb213c + acb23d2 commit 522de7c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;

public class RestPathMatchesTest {
public class RestPathMatchesTests {
Method restPathMatches;
SecurityRestFilter securityRestFilter;

Expand Down Expand Up @@ -63,4 +63,25 @@ public void testDifferentPathSegments() throws InvocationTargetException, Illega
String handlerPath = "_plugins/security/api/x/y";
assertFalse((Boolean) restPathMatches.invoke(securityRestFilter, requestPath, handlerPath));
}

@Test
public void testRequestPathWithNamedParam() throws InvocationTargetException, IllegalAccessException {
String requestPath = "_plugins/security/api/123/y";
String handlerPath = "_plugins/security/api/{id}/z";
assertFalse((Boolean) restPathMatches.invoke(securityRestFilter, requestPath, handlerPath));
}

@Test
public void testRequestPathMismatch() throws InvocationTargetException, IllegalAccessException {
String requestPath = "_plugins/security/api/x/y";
String handlerPath = "_plugins/security/api/z/y";
assertFalse((Boolean) restPathMatches.invoke(securityRestFilter, requestPath, handlerPath));
}

@Test
public void testRequestPathWithExtraSegments() throws InvocationTargetException, IllegalAccessException {
String requestPath = "_plugins/security/api/x/y/z";
String handlerPath = "_plugins/security/api/x/y";
assertFalse((Boolean) restPathMatches.invoke(securityRestFilter, requestPath, handlerPath));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
import static org.mockito.Mockito.when;

@RunWith(Parameterized.class)
public class SecurityFilterTest {
public class SecurityFilterTests {

private final Settings settings;
private final WildcardMatcher expected;

public SecurityFilterTest(Settings settings, WildcardMatcher expected) {
public SecurityFilterTests(Settings settings, WildcardMatcher expected) {
this.settings = settings;
this.expected = expected;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* Currently tests that the whitelisting functionality works correctly.
* Uses the test/resources/restapi folder for setup.
*/
public class SecurityRestFilterTest extends AbstractRestApiUnitTest {
public class SecurityRestFilterTests extends AbstractRestApiUnitTest {

private RestHelper.HttpResponse response;

Expand Down

0 comments on commit 522de7c

Please sign in to comment.