From 538564cc2eb99c0ba393b6bf2e3469dc2fac1dae Mon Sep 17 00:00:00 2001 From: Gulsum Atici Date: Tue, 2 Apr 2024 18:48:30 +0300 Subject: [PATCH] chore: Adding unit tests for custom Webui URL (#223) * Adding unit tests for custom Webui URL Signed-off-by: gatici * Apply suggestions from code review --------- Signed-off-by: gatici Co-authored-by: gab-arrobo --- amfTest/amfcfg.yaml | 1 - amfTest/amfcfg_with_custom_webui_url.yaml | 12 ++++++++ factory/amf_config_test.go | 34 +++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 amfTest/amfcfg_with_custom_webui_url.yaml create mode 100644 factory/amf_config_test.go diff --git a/amfTest/amfcfg.yaml b/amfTest/amfcfg.yaml index f8f94fb5..27709172 100644 --- a/amfTest/amfcfg.yaml +++ b/amfTest/amfcfg.yaml @@ -45,7 +45,6 @@ configuration: supportDnnList: # the DNN (Data Network Name) list supported by this AMF - internet nrfUri: http://127.0.0.10:8000 # a valid URI of NRF - webuiUri: webui:9876 # a valid URI of Webui security: # NAS security parameters integrityOrder: # the priority of integrity algorithms - NIA2 diff --git a/amfTest/amfcfg_with_custom_webui_url.yaml b/amfTest/amfcfg_with_custom_webui_url.yaml new file mode 100644 index 00000000..6b3cb5ea --- /dev/null +++ b/amfTest/amfcfg_with_custom_webui_url.yaml @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2024 Canonical Ltd. + +info: + version: 1.0.0 + description: AMF initial local configuration + +configuration: + amfName: AMF # the name of this AMF + webuiUri: myspecialwebui:9872 # a valid URI of Webui + + diff --git a/factory/amf_config_test.go b/factory/amf_config_test.go new file mode 100644 index 00000000..afa9c4e5 --- /dev/null +++ b/factory/amf_config_test.go @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2024 Canonical Ltd. +/* + * Tests for AMF 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("../amfTest/amfcfg.yaml"); err != nil { + fmt.Printf("Error in InitConfigFactory: %v\n", err) + } + got := AmfConfig.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("../amfTest/amfcfg_with_custom_webui_url.yaml"); err != nil { + fmt.Printf("Error in InitConfigFactory: %v\n", err) + } + got := AmfConfig.Configuration.WebuiUri + want := "myspecialwebui:9872" + assert.Equal(t, got, want, "The webui URL is not correct.") +}