2 // ========================LICENSE_START=================================
5 // Copyright (C) 2022: Nordix Foundation
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===================================
27 "github.com/deepmap/oapi-codegen/pkg/testutil"
28 "github.com/labstack/echo/v4"
29 "github.com/stretchr/testify/assert"
34 func Test_routing(t *testing.T) {
50 returnStatus: http.StatusOK,
55 name: "Provider path",
57 url: "/api-provider-management/v1/registrations/provider",
58 returnStatus: http.StatusNoContent,
65 url: "/published-apis/v1/apfId/service-apis/serviceId",
66 returnStatus: http.StatusNotFound,
71 name: "Discover path",
73 url: "/service-apis/v1/allServiceAPIs?api-invoker-id=api_invoker_id",
74 returnStatus: http.StatusNotFound,
81 url: "/api-invoker-management/v1/onboardedInvokers/invoker",
82 returnStatus: http.StatusNoContent,
87 name: "Security path",
89 url: "/capif-security/v1/trustedInvokers/apiInvokerId",
90 returnStatus: http.StatusNotImplemented,
95 for _, tt := range tests {
96 t.Run(tt.name, func(t *testing.T) {
97 var result *testutil.CompletedRequest
98 if tt.args.method == "GET" {
99 result = testutil.NewRequest().Get(tt.args.url).Go(t, e)
100 } else if tt.args.method == "DELETE" {
101 result = testutil.NewRequest().Delete(tt.args.url).Go(t, e)
104 assert.Equal(t, tt.args.returnStatus, result.Code(), tt.name)