github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/runtime/oidc_values_test.go (about)

     1  package runtime
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/kyma-project/kyma-environment-broker/internal"
     7  	"github.com/stretchr/testify/assert"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  const testFilePath = "testdata/oidc-values.yaml"
    12  
    13  func TestReadOIDCDefaultValuesFromYAML(t *testing.T) {
    14  
    15  	t.Run("should read default OIDC values", func(t *testing.T) {
    16  		// given
    17  		expectedOidcValues := internal.OIDCConfigDTO{
    18  			ClientID:       "9bd05ed7-a930-44e6-8c79-e6defeb7dec9",
    19  			GroupsClaim:    "groups",
    20  			IssuerURL:      "https://kymatest.accounts400.ondemand.com",
    21  			SigningAlgs:    []string{"RS256"},
    22  			UsernameClaim:  "sub",
    23  			UsernamePrefix: "-",
    24  		}
    25  
    26  		// when
    27  		oidcValues, err := ReadOIDCDefaultValuesFromYAML(testFilePath)
    28  
    29  		// then
    30  		require.NoError(t, err)
    31  		assert.Equal(t, expectedOidcValues, oidcValues)
    32  	})
    33  
    34  	t.Run("should return error while reading YAML file", func(t *testing.T) {
    35  		// given
    36  		nonExistentFilePath := "not/existent/file.yaml"
    37  
    38  		// when
    39  		oidcValues, err := ReadOIDCDefaultValuesFromYAML(nonExistentFilePath)
    40  
    41  		// then
    42  		require.Error(t, err)
    43  		assert.Equal(t, internal.OIDCConfigDTO{}, oidcValues)
    44  	})
    45  }