Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ignore NRF URI containing a specific IP on registration #52

Merged
merged 4 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,20 +429,17 @@ func (udm *UDM) registerNF() {
self := context.UDM_Self()
for msg := range ConfigPodTrigger {
initLog.Infof("Minimum configuration from config pod available %v", msg)
proflie, err := consumer.BuildNFInstance(self)
profile, err := consumer.BuildNFInstance(self)
if err != nil {
logger.InitLog.Errorln(err.Error())
} else {
var newNrfUri string
var err1 error
var prof models.NfProfile
prof, newNrfUri, self.NfId, err1 = consumer.SendRegisterNFInstance(self.NrfUri, self.NfId, proflie)
if err1 != nil {
logger.InitLog.Errorln(err1.Error())
prof, _, self.NfId, err = consumer.SendRegisterNFInstance(self.NrfUri, self.NfId, profile)
if err != nil {
logger.InitLog.Errorln(err.Error())
} else {
udm.StartKeepAliveTimer(prof)
logger.CfgLog.Infof("Sent Register NF Instance with updated profile")
self.NrfUri = newNrfUri
}
}
}
Expand Down
35 changes: 35 additions & 0 deletions service/init_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Open Networking Foundation <[email protected]>
//

package service

import (
"fmt"
"net/http"
"net/http/httptest"
"testing"
"time"

"github.com/omec-project/udm/context"
)

func Test_nrf_url_is_not_overwritten_when_registering(t *testing.T) {
svr := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "banana")
}))
svr.EnableHTTP2 = true
svr.StartTLS()
defer svr.Close()
self := context.UDM_Self()
self.NrfUri = svr.URL
self.RegisterIPv4 = "127.0.0.2"
var udm *UDM
go udm.registerNF()
ConfigPodTrigger <- true

time.Sleep(1 * time.Second)
if self.NrfUri != svr.URL {
t.Errorf("Expected NRF URL to stay %v, but was %v", svr.URL, self.NrfUri)
}
}
Loading