feat(oidc): return defined error when discovery failed
This commit is contained in:
parent
b555396744
commit
aadfd3017f
3 changed files with 18 additions and 5 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/zitadel/oidc/v3/pkg/oidc"
|
||||
)
|
||||
|
||||
func TestDiscover(t *testing.T) {
|
||||
|
@ -22,7 +23,7 @@ func TestDiscover(t *testing.T) {
|
|||
name string
|
||||
args args
|
||||
wantFields *wantFields
|
||||
wantErr bool
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
name: "spotify", // https://github.com/zitadel/oidc/issues/406
|
||||
|
@ -32,16 +33,27 @@ func TestDiscover(t *testing.T) {
|
|||
wantFields: &wantFields{
|
||||
UILocalesSupported: true,
|
||||
},
|
||||
wantErr: false,
|
||||
wantErr: nil,
|
||||
},
|
||||
{
|
||||
name: "discovery failed",
|
||||
args: args{
|
||||
issuer: "https://example.com",
|
||||
},
|
||||
wantFields: &wantFields{
|
||||
UILocalesSupported: true,
|
||||
},
|
||||
wantErr: oidc.ErrDiscoveryFailed,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := Discover(context.Background(), tt.args.issuer, http.DefaultClient, tt.args.wellKnownUrl...)
|
||||
if tt.wantErr {
|
||||
assert.Error(t, err)
|
||||
if tt.wantErr != nil {
|
||||
assert.ErrorIs(t, err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
|
||||
require.NoError(t, err)
|
||||
if tt.wantFields == nil {
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue