Examples of MockHttpRequest


Examples of org.jboss.resteasy.mock.MockHttpRequest

        interceptor.preProcess(req, rmethod);
    }

    @Test(expected = BadRequestException.class)
    public void testDoesNotAllowPageZero() throws Exception {
        MockHttpRequest req = MockHttpRequest.create("GET",
            "http://localhost/candlepin/status?page=0&per_page=456");

        interceptor.preProcess(req, rmethod);
    }
View Full Code Here

Examples of org.jboss.resteasy.mock.MockHttpRequest

        interceptor.preProcess(req, rmethod);
    }

    @Test
    public void testNoPagingIfJustOrderAndSortBy() throws Exception {
        MockHttpRequest req = MockHttpRequest.create("GET",
            "http://localhost/candlepin/status?order=asc&sort_by=id");

        interceptor.preProcess(req, rmethod);

        PageRequest p = ResteasyProviderFactory.getContextData(PageRequest.class);
View Full Code Here

Examples of org.jboss.resteasy.mock.MockHttpRequest

        assertEquals("id", p.getSortBy());
    }

    @Test
    public void testUsesDefaultOrderIfNoOrderProvided() throws Exception {
        MockHttpRequest req = MockHttpRequest.create("GET",
            "http://localhost/candlepin/status?sort_by=id");

        interceptor.preProcess(req, rmethod);

        PageRequest p = ResteasyProviderFactory.getContextData(PageRequest.class);
View Full Code Here

Examples of org.jboss.resteasy.mock.MockHttpRequest

        assertEquals("id", p.getSortBy());
    }

    @Test
    public void testDescendingOrder() throws Exception {
        MockHttpRequest req = MockHttpRequest.create("GET",
            "http://localhost/candlepin/status?order=descending&sort_by=id");

        interceptor.preProcess(req, rmethod);

        PageRequest p = ResteasyProviderFactory.getContextData(PageRequest.class);
View Full Code Here

Examples of org.jboss.resteasy.mock.MockHttpRequest

    }

    @Test(expected = UnauthorizedException.class)
    public void noSecurityHoleNoPrincipal() throws Exception {
        Method method = FakeResource.class.getMethod("someMethod", String.class);
        MockHttpRequest req = MockHttpRequest.create("GET",
            "http://localhost/candlepin/status");
        ResourceMethod rmethod = mock(ResourceMethod.class);
        when(rmethod.getMethod()).thenReturn(method);
        Class clazz = FakeResource.class;
        when(rmethod.getResourceClass()).thenReturn(clazz);
View Full Code Here

Examples of org.jboss.resteasy.mock.MockHttpRequest

    }

    @Test
    public void noSecurityHole() throws Exception {
        Method method = FakeResource.class.getMethod("someMethod", String.class);
        MockHttpRequest req = MockHttpRequest.create("GET",
            "http://localhost/candlepin/status");
        req.header("Authorization", "BASIC QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
        ResourceMethod rmethod = mock(ResourceMethod.class);
        when(rmethod.getMethod()).thenReturn(method);
        Class clazz = FakeResource.class;
        when(rmethod.getResourceClass()).thenReturn(clazz);
View Full Code Here

Examples of org.jboss.resteasy.mock.MockHttpRequest

    }

    @Test
    public void securityHoleWithNoAuth() throws Exception {
        Method method = FakeResource.class.getMethod("noAuthMethod", String.class);
        MockHttpRequest req = MockHttpRequest.create("GET",
            "http://localhost/candlepin/status");
        ResourceMethod rmethod = mock(ResourceMethod.class);
        when(rmethod.getMethod()).thenReturn(method);
        Class clazz = FakeResource.class;
        when(rmethod.getResourceClass()).thenReturn(clazz);
View Full Code Here

Examples of org.jboss.resteasy.mock.MockHttpRequest

    }

    @Test
    public void securityHoleWithAuth() throws Exception {
        Method method = FakeResource.class.getMethod("annotatedMethod", String.class);
        MockHttpRequest req = MockHttpRequest.create("GET",
            "http://localhost/candlepin/status");
        req.header("Authorization", "BASIC QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
        ResourceMethod rmethod = mock(ResourceMethod.class);
        when(rmethod.getMethod()).thenReturn(method);
        Class clazz = FakeResource.class;
        when(rmethod.getResourceClass()).thenReturn(clazz);
View Full Code Here

Examples of org.jboss.resteasy.mock.MockHttpRequest

    @Test
    public void noSecurityHoleWithConsumer() throws Exception {
        Method method = FakeResource.class.getMethod(
            "someConsumerOnlyMethod", String.class);
        MockHttpRequest req = MockHttpRequest.create("GET",
            "http://localhost/candlepin/status");
        ResourceMethod rmethod = mock(ResourceMethod.class);
        when(rmethod.getMethod()).thenReturn(method);
        Class clazz = FakeResource.class;
        when(rmethod.getResourceClass()).thenReturn(clazz);

        Consumer c = createConsumer(createOwner());
        methodInjector.setArguments(new Object[] {c.getUuid()});
        when(consumerCurator.getConsumer(eq(c.getUuid()))).thenReturn(c);
        when(consumerCurator.findByUuid(eq(c.getUuid()))).thenReturn(c);

        // create mock certs to trigger SSLAuth provider
        X509Certificate[] certs = new X509Certificate[1];
        X509Certificate cert = mock(X509Certificate.class);
        certs[0] = cert;
        req.setAttribute("javax.servlet.request.X509Certificate", certs);

        java.security.Principal p = mock(java.security.Principal.class);
        when(p.getName()).thenReturn("CN=" + c.getUuid() + ", C=US, L=Raleigh");
        when(cert.getSubjectDN()).thenReturn(p);
View Full Code Here

Examples of org.jboss.resteasy.mock.MockHttpRequest

    @Test(expected = ForbiddenException.class)
    public void noAccessToOtherConsumer() throws Exception {
        Method method = FakeResource.class.getMethod(
            "someConsumerOnlyMethod", String.class);
        MockHttpRequest req = MockHttpRequest.create("GET",
            "http://localhost/candlepin/status");
        ResourceMethod rmethod = mock(ResourceMethod.class);
        when(rmethod.getMethod()).thenReturn(method);
        Class clazz = FakeResource.class;
        when(rmethod.getResourceClass()).thenReturn(clazz);

        Consumer c = createConsumer(createOwner());
        Consumer c2 = createConsumer(createOwner());
        methodInjector.setArguments(new Object[] {c2.getUuid()});
        when(consumerCurator.getConsumer(eq(c.getUuid()))).thenReturn(c);
        when(consumerCurator.findByUuid(eq(c2.getUuid()))).thenReturn(c2);

        // create mock certs to trigger SSLAuth provider
        X509Certificate[] certs = new X509Certificate[1];
        X509Certificate cert = mock(X509Certificate.class);
        certs[0] = cert;
        req.setAttribute("javax.servlet.request.X509Certificate", certs);

        java.security.Principal p = mock(java.security.Principal.class);
        when(p.getName()).thenReturn("CN=" + c.getUuid() + ", C=US, L=Raleigh");
        when(cert.getSubjectDN()).thenReturn(p);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.