2 ==================================================================================
3 Copyright (c) 2021 Nokia
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.
16 ==================================================================================
24 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
27 func TestRestEndpointOk(t *testing.T) {
29 var clientEndpoint models.SubscriptionParamsClientEndpoint
36 host = "service-ricxapp-xappname-http.ricxapp"
38 clientEndpoint.HTTPPort = &httpPort
39 clientEndpoint.RMRPort = &rmrPort
40 clientEndpoint.Host = host
42 expectedHttpEndpoint := "service-ricxapp-xappname-http.ricxapp:8080"
43 expectedRmrEndpoint := "service-ricxapp-xappname-rmr.ricxapp:4560"
45 httpEndPoint, rmrEndPoint, err := ConstructEndpointAddresses(clientEndpoint)
48 t.Errorf("Mismatching return value: %s - ecpected NIL", err)
50 if httpEndPoint != expectedHttpEndpoint {
51 t.Errorf("Mismatching httpEndpoint: %s - ecpected %s", httpEndPoint, expectedHttpEndpoint)
53 if rmrEndPoint != expectedRmrEndpoint {
54 t.Errorf("Mismatching httpEndpoint: %s - ecpected %s", httpEndPoint, expectedHttpEndpoint)
58 func TestRestEndpointNoHttpPort(t *testing.T) {
60 var clientEndpoint models.SubscriptionParamsClientEndpoint
67 host = "service-ricxapp-xappname-http.ricxapp"
69 clientEndpoint.HTTPPort = &httpPort
70 clientEndpoint.RMRPort = &rmrPort
71 clientEndpoint.Host = host
73 expectedHttpEndpoint := ""
74 expectedRmrEndpoint := "service-ricxapp-xappname-rmr.ricxapp:4561"
76 httpEndPoint, rmrEndPoint, err := ConstructEndpointAddresses(clientEndpoint)
79 t.Errorf("Mismatching return value: %s - ecpected NIL", err)
81 if httpEndPoint != expectedHttpEndpoint {
82 t.Errorf("Mismatching httpEndpoint: %s - ecpected %s", httpEndPoint, expectedHttpEndpoint)
84 if rmrEndPoint != expectedRmrEndpoint {
85 t.Errorf("Mismatching httpEndpoint: %s - ecpected %s", httpEndPoint, expectedHttpEndpoint)
89 func TestRestEndpointNok(t *testing.T) {
91 var clientEndpoint models.SubscriptionParamsClientEndpoint
98 host = "service-ricxapp-xappname-http.ricxapp"
100 clientEndpoint.HTTPPort = &httpPort
101 clientEndpoint.RMRPort = &rmrPort
102 clientEndpoint.Host = host
104 _, _, err := ConstructEndpointAddresses(clientEndpoint)
107 t.Errorf("Mismatching return value: - expected ERR but got NIL")
111 func TestRestEndpointNoHttpInHost(t *testing.T) {
113 var clientEndpoint models.SubscriptionParamsClientEndpoint
120 host = "service-ricxapp-xappname.ricxapp"
122 clientEndpoint.HTTPPort = &httpPort
123 clientEndpoint.RMRPort = &rmrPort
124 clientEndpoint.Host = host
126 expectedHttpEndpoint := "service-ricxapp-xappname.ricxapp:8080"
127 expectedRmrEndpoint := "service-ricxapp-xappname.ricxapp:4562"
129 httpEndPoint, rmrEndPoint, err := ConstructEndpointAddresses(clientEndpoint)
132 t.Errorf("Mismatching return value: %s - ecpected NIL", err)
134 if httpEndPoint != expectedHttpEndpoint {
135 t.Errorf("Mismatching httpEndpoint: %s - ecpected %s", httpEndPoint, expectedHttpEndpoint)
137 if rmrEndPoint != expectedRmrEndpoint {
138 t.Errorf("Mismatching httpEndpoint: %s - ecpected %s", httpEndPoint, expectedHttpEndpoint)
142 //-----------------------------------------------------------------------------
144 //-----------------------------------------------------------------------------