Skip to content

Commit

Permalink
Add config validation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed Nov 3, 2023
1 parent 16cea28 commit 5663879
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions config/validate_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config_test

import (
"github.com/stretchr/testify/require"
"testing"

"github.com/kava-labs/kava-proxy-service/config"
Expand Down Expand Up @@ -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)
}

0 comments on commit 5663879

Please sign in to comment.