2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2024 Nordix Foundation
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the 'License');
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an 'AS IS' BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.cps.integration.functional.ncmp
23 import org.onap.cps.integration.base.CpsIntegrationSpecBase
24 import org.springframework.http.HttpHeaders
25 import org.springframework.http.MediaType
27 import static org.springframework.http.HttpMethod.POST
28 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.request
30 class PolicyExecutorIntegrationSpec extends CpsIntegrationSpecBase {
33 // Enable mocked policy executor logic
34 policyDispatcher.allowAll = false;
35 //minimum setup for 2 cm handles with alternate ids
36 dmiDispatcher1.moduleNamesPerCmHandleId = ['ch-1': [], 'ch-2': []]
37 registerCmHandle(DMI1_URL, 'ch-1', NO_MODULE_SET_TAG, 'fdn1')
38 registerCmHandle(DMI1_URL, 'ch-2', NO_MODULE_SET_TAG, 'fdn2')
42 deregisterCmHandle(DMI1_URL, 'ch-1')
43 deregisterCmHandle(DMI1_URL, 'ch-2')
46 def 'Policy Executor create request with #scenario.'() {
47 when: 'a pass-through write request is sent to NCMP'
48 def response = mvc.perform(request(POST, "/ncmp/v1/ch/$cmHandle/data/ds/ncmp-datastore:passthrough-running")
49 .queryParam('resourceIdentifier', 'my-resource-id')
50 .contentType(MediaType.APPLICATION_JSON)
51 .content('{ "some-json": "data" }')
52 .header(HttpHeaders.AUTHORIZATION, authorization))
54 then: 'the expected status code is returned'
55 response.getStatus() == execpectedStatusCode
56 where: 'following parameters are used'
57 scenario | cmHandle | authorization || execpectedStatusCode
58 'accepted cm handle' | 'ch-1' | 'mock expects "ABC"' || 201
59 'un-accepted cm handle' | 'ch-2' | 'mock expects "ABC"' || 409
60 'invalid authorization' | 'ch-1' | 'something else' || 500