Examples of UnauthorizedStubResponse


Examples of by.stub.yaml.stubs.UnauthorizedStubResponse

         return new NotFoundStubResponse();
      }

      final StubResponse stubResponse = matchedLifecycle.getResponse();
      if (matchedLifecycle.isRestricted() && matchedLifecycle.hasNotAuthorized(assertingLifecycle)) {
         return new UnauthorizedStubResponse();
      }

      if (stubResponse.hasHeaderLocation()) {
         return RedirectStubResponse.newRedirectStubResponse(stubResponse);
      }
View Full Code Here

Examples of by.stub.yaml.stubs.UnauthorizedStubResponse

      resourceStats.putIfAbsent(resourceId, new AtomicLong(0));
      resourceStats.get(resourceId).incrementAndGet();

      final StubResponse stubResponse = matchedLifecycle.getResponse(true);
      if (matchedLifecycle.isRestricted() && matchedLifecycle.hasNotAuthorized(assertingLifecycle)) {
         return new UnauthorizedStubResponse();
      }

      if (stubResponse.hasHeaderLocation()) {
         return RedirectStubResponse.newRedirectStubResponse(stubResponse);
      }
View Full Code Here

Examples of by.stub.yaml.stubs.UnauthorizedStubResponse

   @Test
   public void verifyBehaviourDuringHandleGetRequestWithNoAuthorizationHeaderSet() throws Exception {

      final String requestPathInfo = "/path/1";

      final UnauthorizedStubResponse mockStubResponse = Mockito.mock(UnauthorizedStubResponse.class);

      when(mockHttpServletResponse.getWriter()).thenReturn(mockPrintWriter);
      when(mockHttpServletRequest.getMethod()).thenReturn(HttpMethods.GET);
      when(mockHttpServletRequest.getPathInfo()).thenReturn(requestPathInfo);
      when(mockStubbedDataManager.findStubResponseFor(Mockito.any(StubRequest.class))).thenReturn(mockStubResponse);
      when(mockStubResponse.getStubResponseType()).thenReturn(StubResponseTypes.UNAUTHORIZED);
      when(mockStubResponse.getStatus()).thenReturn("200");
      when(mockStubResponse.getBody()).thenReturn(someResultsMessage);

      final StubsPortalHandler stubsPortalHandler = new StubsPortalHandler(mockStubbedDataManager);
      stubsPortalHandler.handle(requestPathInfo, mockRequest, mockHttpServletRequest, mockHttpServletResponse);

      verify(mockHttpServletResponse, times(1)).setStatus(HttpStatus.UNAUTHORIZED_401);
View Full Code Here

Examples of by.stub.yaml.stubs.UnauthorizedStubResponse

   public void verifyBehaviourDuringHandleGetRequestWithEmptyAuthorizationHeaderSet() throws Exception {

      final String requestPathInfo = "/path/1";

      // We already found that it was unauthorized
      final UnauthorizedStubResponse mockStubResponse = Mockito.mock(UnauthorizedStubResponse.class);

      when(mockHttpServletRequest.getMethod()).thenReturn(HttpMethods.GET);
      when(mockHttpServletRequest.getHeader(StubRequest.AUTH_HEADER)).thenReturn("");
      when(mockHttpServletRequest.getPathInfo()).thenReturn(requestPathInfo);

      final StubRequest assertionStubRequest = StubRequest.createFromHttpServletRequest(mockHttpServletRequest);
      when(mockStubbedDataManager.findStubResponseFor(assertionStubRequest)).thenReturn(mockStubResponse);

      when(mockStubResponse.getStubResponseType()).thenReturn(StubResponseTypes.UNAUTHORIZED);
      when(mockStubResponse.getStatus()).thenReturn("200");

      final StubsPortalHandler stubsPortalHandler = new StubsPortalHandler(mockStubbedDataManager);
      stubsPortalHandler.handle(requestPathInfo, mockRequest, mockHttpServletRequest, mockHttpServletResponse);

      verify(mockHttpServletResponse, times(1)).setStatus(HttpStatus.UNAUTHORIZED_401);
View Full Code Here

Examples of by.stub.yaml.stubs.UnauthorizedStubResponse

      assertThat(stubResponseHandlingStrategy).isInstanceOf(NotFoundResponseHandlingStrategy.class);
   }

   @Test
   public void shouldIdentifyResponseStrategyForUnauthorizedResponse() throws Exception {
      final StubResponse stubResponse = new UnauthorizedStubResponse();

      final StubResponseHandlingStrategy stubResponseHandlingStrategy = StubsResponseHandlingStrategyFactory.getStrategy(stubResponse);
      assertThat(stubResponseHandlingStrategy).isInstanceOf(UnauthorizedResponseHandlingStrategy.class);
   }
View Full Code Here

Examples of by.stub.yaml.stubs.UnauthorizedStubResponse

         return new NotFoundStubResponse();
      }

      final StubResponse stubResponse = matchedLifecycle.getResponse();
      if (matchedLifecycle.isRestricted() && matchedLifecycle.hasNotAuthorized(assertingLifecycle)) {
         return new UnauthorizedStubResponse();
      }

      if (stubResponse.hasHeaderLocation()) {
         return RedirectStubResponse.newRedirectStubResponse(stubResponse);
      }
View Full Code Here

Examples of by.stub.yaml.stubs.UnauthorizedStubResponse

      final StubHttpLifecycle matchedLifecycle = stubHttpLifecycles.get(listIndex);
      final StubResponse stubResponse = matchedLifecycle.getResponse();

      if (matchedLifecycle.isRestricted() && matchedLifecycle.hasNotAuthorized(assertingLifecycle)) {
         return new UnauthorizedStubResponse();
      }

      if (stubResponse.hasHeader("location")) {
         return new RedirectStubResponse().configure(stubResponse);
      }
View Full Code Here

Examples of by.stub.yaml.stubs.UnauthorizedStubResponse

      resourceStats.putIfAbsent(resourceId, new AtomicLong(0));
      resourceStats.get(resourceId).incrementAndGet();

      final StubResponse stubResponse = matchedLifecycle.getResponse();
      if (matchedLifecycle.isRestricted() && matchedLifecycle.hasNotAuthorized(assertingLifecycle)) {
         return new UnauthorizedStubResponse();
      }

      if (stubResponse.hasHeaderLocation()) {
         return RedirectStubResponse.newRedirectStubResponse(stubResponse);
      }
View Full Code Here

Examples of by.stub.yaml.stubs.UnauthorizedStubResponse

         if (headers.containsKey(StubRequest.AUTH_HEADER)) {
            final String foundBasicAuthorization = headers.get(StubRequest.AUTH_HEADER);
            final String givenBasicAuthorization = assertionStubHttpLifecycle.getRequest().getHeaders().get(StubRequest.AUTH_HEADER);

            if (!foundBasicAuthorization.equals(givenBasicAuthorization)) {
               return new UnauthorizedStubResponse();
            }
         }

         if (foundStubHttpLifecycle.getResponse().getHeaders().containsKey("location")) {
            final RedirectStubResponse redirectStubResponse = new RedirectStubResponse();
View Full Code Here

Examples of by.stub.yaml.stubs.UnauthorizedStubResponse

         return new NotFoundStubResponse();
      }

      final StubResponse stubResponse = matchedLifecycle.getResponse();
      if (matchedLifecycle.isRestricted() && matchedLifecycle.hasNotAuthorized(assertingLifecycle)) {
         return new UnauthorizedStubResponse();
      }

      if (stubResponse.hasHeaderLocation()) {
         return RedirectStubResponse.newRedirectStubResponse(stubResponse);
      }
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.