91ca3b012c
* [NET-3090] Add new JWT provider config entry * Add initial test cases * update validations for jwt-provider config entry fields * more validation * start improving tests * more tests * Normalize * Improve tests and move validate fns * usage test update * Add split between ent and oss for partitions * fix lint issues * Added retry backoff, fixed tests, removed unused defaults * take into account default partitions * use countTrue and add aliases * omit audiences if empty * fix failing tests * add omit-entry * update copyright headers ids --------- Co-authored-by: Ronald Ekambi <ronekambi@gmail.com> Co-authored-by: Ronald <roncodingenthusiast@users.noreply.github.com>
50 lines
1 KiB
Go
50 lines
1 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
|
|
package api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/consul/sdk/testutil"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestAPI_ConfigEntries_JWTProvider(t *testing.T) {
|
|
t.Parallel()
|
|
c, s := makeClient(t)
|
|
defer s.Stop()
|
|
|
|
entries := c.ConfigEntries()
|
|
|
|
testutil.RunStep(t, "set and get", func(t *testing.T) {
|
|
jwtProvider := &JWTProviderConfigEntry{
|
|
Name: "okta",
|
|
Kind: JWTProvider,
|
|
JSONWebKeySet: &JSONWebKeySet{
|
|
Local: &LocalJWKS{
|
|
Filename: "test.txt",
|
|
},
|
|
},
|
|
Meta: map[string]string{
|
|
"gir": "zim",
|
|
},
|
|
}
|
|
|
|
_, wm, err := entries.Set(jwtProvider, nil)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, wm)
|
|
require.NotEqual(t, 0, wm.RequestTime)
|
|
|
|
entry, qm, err := entries.Get(JWTProvider, "okta", nil)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, qm)
|
|
require.NotEqual(t, 0, qm.RequestTime)
|
|
|
|
result, ok := entry.(*JWTProviderConfigEntry)
|
|
require.True(t, ok)
|
|
|
|
require.Equal(t, jwtProvider.Name, result.Name)
|
|
require.Equal(t, jwtProvider.JSONWebKeySet, result.JSONWebKeySet)
|
|
})
|
|
}
|