Search in sources :

Example 21 with ResteasyUriInfo

use of org.jboss.resteasy.specimpl.ResteasyUriInfo in project stdlib by petergeneric.

the class WebQueryTest method testParseComplexQueryStringToWebQuery.

@Test
public void testParseComplexQueryStringToWebQuery() {
    WebQuery actual = new WebQuery().decode(new ResteasyUriInfo(URI.create("http://example.com/search?q=id+%3C+100+AND+id+%3E+200+AND+%28id+%3D+1+OR+id+%3D+2+OR+%28id+%3D+3+AND+id+%3D+4%29%29")));
    assertEquals("id < 100\nAND id > 200\nAND (id = 1 OR id = 2 OR (id = 3 AND id = 4))", actual.constraints.toQueryFragment());
}
Also used : WebQuery(com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery) ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) Test(org.junit.Test)

Example 22 with ResteasyUriInfo

use of org.jboss.resteasy.specimpl.ResteasyUriInfo in project stdlib by petergeneric.

the class WebQueryTest method testParseQueryStringToWebQuery.

@Test
public void testParseQueryStringToWebQuery() {
    WebQuery expected = new WebQuery().logSQL(true).eq("id", "123").offset(0).limit(200);
    WebQuery actual = new WebQuery().decode(new ResteasyUriInfo(URI.create("http://example.com?_log_sql=true&id=123")));
    assertEquals(expected.encode().toString(), actual.encode().toString());
}
Also used : WebQuery(com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery) ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) Test(org.junit.Test)

Example 23 with ResteasyUriInfo

use of org.jboss.resteasy.specimpl.ResteasyUriInfo in project platform by dashjoin.

the class ACLContainerRequestFilterTest method testQuery.

/**
 * authenticated requests pass the filter
 */
@Test
public void testQuery() throws Exception {
    ACLContainerRequestFilter f = new ACLContainerRequestFilter();
    f.filter(new ResponseContainerRequestContext(null) {

        @Override
        public SecurityContext getSecurityContext() {
            return new SecurityContext() {

                @Override
                public Principal getUserPrincipal() {
                    return new UnixPrincipal("root");
                }

                @Override
                public boolean isUserInRole(String role) {
                    return true;
                }

                @Override
                public boolean isSecure() {
                    return false;
                }

                @Override
                public String getAuthenticationScheme() {
                    return null;
                }
            };
        }

        @Override
        public UriInfo getUriInfo() {
            try {
                return new ResteasyUriInfo(new URI("/database/query/list"));
            } catch (URISyntaxException e) {
                throw new RuntimeException();
            }
        }
    });
}
Also used : ResponseContainerRequestContext(org.jboss.resteasy.core.interception.jaxrs.ResponseContainerRequestContext) ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) UnixPrincipal(com.sun.security.auth.UnixPrincipal) SecurityContext(javax.ws.rs.core.SecurityContext) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Principal(java.security.Principal) UnixPrincipal(com.sun.security.auth.UnixPrincipal) ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) UriInfo(javax.ws.rs.core.UriInfo) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 24 with ResteasyUriInfo

use of org.jboss.resteasy.specimpl.ResteasyUriInfo in project policies-ui-backend by RedHatInsights.

the class TagsFilterTest method filter2.

@Test
void filter2() throws URISyntaxException {
    UriInfo info = new ResteasyUriInfo(new URI("https://foo?filter[name]=VM&filter:op[name]=not_equal"));
    Pager pager = PagingUtils.extractPager(info);
    String query = PolicyHistoryTagFilterHelper.getTagsFilterFromPager(pager);
    assertEquals("tags.display_name != 'vm'", query);
}
Also used : ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) Pager(com.redhat.cloud.policies.app.model.pager.Pager) URI(java.net.URI) ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.jupiter.api.Test)

Example 25 with ResteasyUriInfo

use of org.jboss.resteasy.specimpl.ResteasyUriInfo in project policies-ui-backend by RedHatInsights.

the class TagsFilterTest method filter4.

@Test
void filter4() throws URISyntaxException {
    UriInfo info = new ResteasyUriInfo(new URI("https://foo?filter[name]=VM&filter[id]=123"));
    Pager pager = PagingUtils.extractPager(info);
    String query = PolicyHistoryTagFilterHelper.getTagsFilterFromPager(pager);
    assertEquals("tags.display_name = 'vm' AND tags.inventory_id = '123'", query);
}
Also used : ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) Pager(com.redhat.cloud.policies.app.model.pager.Pager) URI(java.net.URI) ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.jupiter.api.Test)

Aggregations

ResteasyUriInfo (org.jboss.resteasy.specimpl.ResteasyUriInfo)42 URI (java.net.URI)19 UriInfo (javax.ws.rs.core.UriInfo)14 Test (org.junit.jupiter.api.Test)14 Pager (com.redhat.cloud.policies.app.model.pager.Pager)8 Test (org.junit.Test)6 ResteasyHttpHeaders (org.jboss.resteasy.specimpl.ResteasyHttpHeaders)5 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)4 NotFoundException (jakarta.ws.rs.NotFoundException)4 IOException (java.io.IOException)3 WebQuery (com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery)2 Context (io.vertx.core.Context)2 HttpServerResponse (io.vertx.core.http.HttpServerResponse)2 PathSegment (jakarta.ws.rs.core.PathSegment)2 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 SecurityContext (javax.ws.rs.core.SecurityContext)2 HttpRequest (org.jboss.resteasy.spi.HttpRequest)2 HttpResponse (org.jboss.resteasy.spi.HttpResponse)2