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

chore: Adding unit tests for custom Webui URL #92

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
34 changes: 34 additions & 0 deletions factory/udm_config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2024 Canonical Ltd.
/*
* Tests for UDM Configuration Factory
*/

package factory

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
)

// Webui URL is not set then default Webui URL value is returned
func TestGetDefaultWebuiUrl(t *testing.T) {
if err := InitConfigFactory("udmcfg.yaml"); err != nil {
fmt.Printf("Error in InitConfigFactory: %v\n", err)
}
got := UdmConfig.Configuration.WebuiUri
want := "webui:9876"
assert.Equal(t, got, want, "The webui URL is not correct.")
}

// Webui URL is set to a custom value then custom Webui URL is returned
func TestGetCustomWebuiUrl(t *testing.T) {
if err := InitConfigFactory("udmcfg_with_custom_webui_url.yaml"); err != nil {
fmt.Printf("Error in InitConfigFactory: %v\n", err)
}
got := UdmConfig.Configuration.WebuiUri
want := "myspecialwebui:9872"
assert.Equal(t, got, want, "The webui URL is not correct.")
}
25 changes: 25 additions & 0 deletions factory/udmcfg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2024 Canonical Ltd.

configuration:
keys:
udmProfileAHNPrivateKey: whatever private key
nrfUri: https://nrf:443
sbi:
bindingIPv4: 0.0.0.0
port: 29503
registerIPv4: 1.1.1.1
scheme: https
tls:
key: free5gc/support/TLS/udm.key
log: free5gc/udmsslkey.log
pem: free5gc/support/TLS/udm.pem
serviceNameList:
- nudm-sdm
- nudm-uecm
- nudm-ueau
- nudm-ee
- nudm-pp
info:
description: UDM initial local configuration
version: 1.0.0
9 changes: 9 additions & 0 deletions factory/udmcfg_with_custom_webui_url.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2024 Canonical Ltd.

configuration:
nrfUri: https://nrf:443
webuiUri: myspecialwebui:9872 # a valid URI of Webui
info:
description: UDM initial local configuration
version: 1.0.0
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/omec-project/util v1.0.13
github.com/omec-project/util_3gpp v1.2.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
github.com/urfave/cli v1.22.14
gopkg.in/yaml.v2 v2.4.0
)
Expand All @@ -23,6 +24,7 @@ require (
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
Expand All @@ -43,6 +45,7 @@ require (
github.com/omec-project/logger_conf v1.1.1 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
Expand Down