added svcapi ui and camunda code
[it/otf.git] / otf-service-api / src / test / java / org / oran / otf / api / tests / integration / services / StrategyServiceRouteIT.java
1 /*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
2 #                                                                              #\r
3 #   Licensed under the Apache License, Version 2.0 (the "License");            #\r
4 #   you may not use this file except in compliance with the License.           #\r
5 #   You may obtain a copy of the License at                                    #\r
6 #                                                                              #\r
7 #       http://www.apache.org/licenses/LICENSE-2.0                             #\r
8 #                                                                              #\r
9 #   Unless required by applicable law or agreed to in writing, software        #\r
10 #   distributed under the License is distributed on an "AS IS" BASIS,          #\r
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
12 #   See the License for the specific language governing permissions and        #\r
13 #   limitations under the License.                                             #\r
14 ##############################################################################*/\r
15 \r
16 \r
17 package org.oran.otf.api.tests.integration.services;\r
18 \r
19 import org.oran.otf.api.Application;\r
20 import org.oran.otf.api.tests.shared.MemoryDatabase;\r
21 import io.restassured.RestAssured;\r
22 import org.junit.AfterClass;\r
23 import org.junit.Before;\r
24 import org.junit.BeforeClass;\r
25 import org.junit.Test;\r
26 import org.junit.runner.RunWith;\r
27 import org.springframework.boot.test.context.SpringBootTest;\r
28 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;\r
29 import org.springframework.boot.web.server.LocalServerPort;\r
30 import org.springframework.test.context.ActiveProfiles;\r
31 import org.springframework.test.context.TestPropertySource;\r
32 import org.springframework.test.context.junit4.SpringRunner;\r
33 \r
34 @RunWith(SpringRunner.class)\r
35 @SpringBootTest(\r
36     webEnvironment = WebEnvironment.RANDOM_PORT,\r
37     classes = {Application.class}\r
38 )\r
39 @TestPropertySource("classpath:application-test.properties")\r
40 @ActiveProfiles("test")\r
41 public class StrategyServiceRouteIT {\r
42   @LocalServerPort\r
43   private int port;\r
44   @BeforeClass\r
45   public static void setup() throws Exception{\r
46     MemoryDatabase.setup();\r
47   }\r
48   @AfterClass\r
49   public static void cleanup(){\r
50     MemoryDatabase.cleanup();\r
51   }\r
52   @Before\r
53   public void setupRestAssured(){\r
54     RestAssured.port = port;\r
55     RestAssured.baseURI="https://localhost";\r
56     RestAssured.basePath="/otf/api/testStrategy";\r
57     RestAssured.urlEncodingEnabled=false;\r
58     RestAssured.useRelaxedHTTPSValidation();\r
59   }\r
60 \r
61   @Test\r
62   public void testStrategyServiceRouteDeployRespondsWith401OnNoAuth(){\r
63     RestAssured.given().log().all().header("Accept", "application/json").post("/deploy/v1").then().assertThat().statusCode(401);\r
64   }\r
65   @Test\r
66   public void testStrategyServiceRouteDeleteByTestDefinitionIdRespondsWith401OnNoAuth(){\r
67     RestAssured.given().log().all().header("Accept", "application/json").delete("/delete/v1/testDefinitionId/56565656").then().assertThat().statusCode(401);\r
68   }\r
69   @Test\r
70   public void testStrategyServiceRouteDeleteByDeploymentIdRespondsWith401OnNoAuth(){\r
71     RestAssured.given().log().all().header("Accept", "application/json").delete("/delete/v1/deploymentId/54545454").then().assertThat().statusCode(401);\r
72   }\r
73 \r
74 }\r