From 5663879bc96dd56123481c20aec1d1fed7c12856 Mon Sep 17 00:00:00 2001 From: evgeniy-scherbina Date: Fri, 3 Nov 2023 12:30:19 -0400 Subject: [PATCH] Add config validation tests --- config/validate_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/config/validate_test.go b/config/validate_test.go index 9a70f63..a4d8563 100644 --- a/config/validate_test.go +++ b/config/validate_test.go @@ -1,6 +1,7 @@ package config_test import ( + "github.com/stretchr/testify/require" "testing" "github.com/kava-labs/kava-proxy-service/config" @@ -100,3 +101,27 @@ func TestUnitTestValidateConfigReturnsErrorIfInvalidMetricPartitioningPrefillPer assert.NotNil(t, err) } + +func TestUnitTestValidHostnameToHeaderValueMap(t *testing.T) { + testConfig := defaultConfig + testConfig.HostnameToAccessControlAllowOriginValueMapRaw = "localhost:7777>*,evm.kava.io>*" + + err := config.Validate(testConfig) + require.NoError(t, err) +} + +func TestUnitTestEmptyHostnameToHeaderValueMap(t *testing.T) { + testConfig := defaultConfig + testConfig.HostnameToAccessControlAllowOriginValueMapRaw = "" + + err := config.Validate(testConfig) + require.NoError(t, err) +} + +func TestUnitTestInvalidHostnameToHeaderValueMap(t *testing.T) { + testConfig := defaultConfig + testConfig.HostnameToAccessControlAllowOriginValueMapRaw = "invalidmap" + + err := config.Validate(testConfig) + require.Error(t, err) +}