List of usage examples for org.springframework.http HttpHeaders AUTHORIZATION
String AUTHORIZATION
To view the source code for org.springframework.http HttpHeaders AUTHORIZATION.
Click Source Link
From source file:org.openlmis.fulfillment.web.ShipmentControllerIntegrationTest.java
@Test public void shouldReturnBadRequestIfOrderIsNotFoundWhenGetShipments() { when(orderRepository.findOne(orderId)).thenReturn(null); restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()).contentType(APPLICATION_JSON_VALUE) .queryParam(ORDER_ID, orderId).when().get(RESOURCE_URL).then().statusCode(400) .body(MESSAGE_KEY, equalTo(MessageKeys.ORDER_NOT_FOUND)); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.openlmis.fulfillment.web.BaseTransferPropertiesControllerIntegrationTest.java
@Test public void shouldReturn403WhenUserHasNoRightsToSearchTransferProperties() { denyUserAllRights();//w w w . j av a 2 s . c o m restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()) .queryParam(FACILITY, UUID.randomUUID()).when().get(SEARCH).then().statusCode(403); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.openlmis.fulfillment.web.ShipmentDraftControllerIntegrationTest.java
@Test public void shouldGetShipmentDraft() { ShipmentDraftDto extracted = restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()) .contentType(APPLICATION_JSON_VALUE).pathParam(ID, shipmentDraftDtoExpected.getId()).when() .get(ID_RESOURCE_URL).then().statusCode(200).extract().as(ShipmentDraftDto.class); assertEquals(shipmentDraftDtoExpected, extracted); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.openlmis.fulfillment.web.ShipmentControllerIntegrationTest.java
@Test public void shouldReturnBadRequestIfOrderIsNotGivenWhenGetShipments() { restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()).contentType(APPLICATION_JSON_VALUE) .when().get(RESOURCE_URL).then().statusCode(400) .body(MESSAGE_KEY, equalTo(MessageKeys.SHIPMENT_ORDER_REQUIRED)); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.responseChecks()); }
From source file:it.reply.orchestrator.controller.DeploymentControllerTest.java
@Test public void deploymentHypermedia() throws Exception { String deploymentId = "mmd34483-d937-4578-bfdb-ebe196bf82dd"; Deployment deployment = ControllerTestUtils.createDeployment(deploymentId); Mockito.when(deploymentService.getDeployment(deploymentId)).thenReturn(deployment); mockMvc.perform(get("/deployments/" + deploymentId).header(HttpHeaders.AUTHORIZATION, OAuth2AccessToken.BEARER_TYPE + " <access token>")).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(document("deployment-hypermedia", preprocessResponse(prettyPrint()), links(atomLinks(), linkWithRel("self").description("Self-referencing hyperlink"), linkWithRel("template").description("Template reference hyperlink"), linkWithRel("resources").description("Resources reference hyperlink")), responseFields(// ww w . j a va2 s . com fieldWithPath("links[].rel").description( "means relationship. In this case, it's a self-referencing hyperlink." + "More complex systems might include other relationships."), fieldWithPath("links[].href") .description("Is a complete URL that uniquely defines the resource."), fieldWithPath("uuid").ignored(), fieldWithPath("creationTime").ignored(), fieldWithPath("updateTime").ignored(), fieldWithPath("status").ignored(), fieldWithPath("outputs").ignored(), fieldWithPath("task").ignored(), fieldWithPath("callback").ignored()))); }
From source file:org.openlmis.fulfillment.web.ShipmentDraftControllerIntegrationTest.java
@Test public void shouldReturnNotFoundIfShipmentDraftIsNotFound() { when(shipmentDraftRepository.findOne(shipmentDraftDtoExpected.getId())).thenReturn(null); restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()).contentType(APPLICATION_JSON_VALUE) .pathParam(ID, shipmentDraftDtoExpected.getId()).when().get(ID_RESOURCE_URL).then().statusCode(404) .body(MESSAGE_KEY, equalTo(MessageKeys.SHIPMENT_NOT_FOUND)); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.openlmis.fulfillment.web.ShipmentControllerIntegrationTest.java
@Test public void shouldReturnForbiddenIfUserHasNoRightsToGetShipments() { when(orderRepository.findOne(orderId)).thenReturn(shipment.getOrder()); doThrow(new MissingPermissionException("test")).when(permissionService) .canViewShipment(shipment.getOrder()); restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()).contentType(APPLICATION_JSON_VALUE) .queryParam(ORDER_ID, orderId).when().get(RESOURCE_URL).then().statusCode(403) .body(MESSAGE_KEY, equalTo(MessageKeys.PERMISSION_MISSING)); verify(shipmentDraftRepository, never()).findByOrder(any(Order.class), any(Pageable.class)); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.openlmis.fulfillment.web.ShipmentDraftControllerIntegrationTest.java
@Test public void shouldReturnForbiddenIfUserHasNoRightsToGetShipmentDraft() { doThrow(new MissingPermissionException("test")).when(permissionService).canViewShipmentDraft(shipmentDraft); restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()).contentType(APPLICATION_JSON_VALUE) .pathParam(ID, shipmentDraftDtoExpected.getId()).when().get(ID_RESOURCE_URL).then().statusCode(403) .body(MESSAGE_KEY, equalTo(MessageKeys.PERMISSION_MISSING)); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.openlmis.fulfillment.web.ShipmentControllerIntegrationTest.java
@Test public void shouldGetShipment() { ShipmentDto extracted = restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()) .contentType(APPLICATION_JSON_VALUE).pathParam(ID, shipmentDtoExpected.getId()).when() .get(ID_RESOURCE_URL).then().statusCode(200).extract().as(ShipmentDto.class); assertEquals(shipmentDtoExpected, extracted); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); }
From source file:org.openlmis.fulfillment.web.OrderControllerIntegrationTest.java
@Test public void shouldPrintOrderAsCsv() { String csvContent = restAssured.given().queryParam(FORMAT, CSV) .header(HttpHeaders.AUTHORIZATION, getTokenHeader()).pathParam("id", secondOrder.getId()).when() .get(PRINT_URL).then().statusCode(200).extract().body().asString(); assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations()); assertTrue(csvContent.contains("Product Code")); }