2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.aai.rest;
23 import static org.hamcrest.Matchers.containsString;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertThat;
27 import java.util.UUID;
29 import org.junit.Test;
30 import org.springframework.http.HttpEntity;
31 import org.springframework.http.HttpHeaders;
32 import org.springframework.http.HttpMethod;
33 import org.springframework.http.HttpStatus;
34 import org.springframework.http.ResponseEntity;
36 public class PserverWrongHeaderTest extends AbstractSpringRestTest {
39 public void testWhenNoHeadersItFailsWithBadRequestAndReturnsXml() {
41 HttpHeaders httpHeaders = new HttpHeaders();
43 httpEntity = new HttpEntity<String>(httpHeaders);
45 String endpoint = "/aai/v11/cloud-infrastructure/pservers/pserver/test" + UUID.randomUUID().toString();
47 ResponseEntity<String> responseEntity;
48 responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class);
50 String body = responseEntity.getBody().toString();
52 assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
53 assertThat(body, containsString("<Fault>"));
54 assertThat(body, containsString("Invalid X-FromAppId in header"));