feat(op): Server interface (#447)
* first draft of a new server interface * allow any response type * complete interface docs * refelct the format from the proposal * intermediate commit with some methods implemented * implement remaining token grant type methods * implement remaining server methods * error handling * rewrite auth request validation * define handlers, routes * input validation and concrete handlers * check if client credential client is authenticated * copy and modify the routes test for the legacy server * run integration tests against both Server and Provider * remove unuse ValidateAuthRequestV2 function * unit tests for error handling * cleanup tokenHandler * move server routest test * unit test authorize * handle client credentials in VerifyClient * change code exchange route test * finish http unit tests * review server interface docs and spelling * add withClient unit test * server options * cleanup unused GrantType method * resolve typo comments * make endpoints pointers to enable/disable them * jwt profile base work * jwt: correct the test expect --------- Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
parent
daf82a5e04
commit
0f8a0585bf
28 changed files with 3654 additions and 126 deletions
|
@ -3,13 +3,14 @@ package op_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/zitadel/oidc/v3/pkg/op"
|
||||
)
|
||||
|
||||
func TestEndpoint_Path(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
e op.Endpoint
|
||||
e *op.Endpoint
|
||||
want string
|
||||
}{
|
||||
{
|
||||
|
@ -27,6 +28,11 @@ func TestEndpoint_Path(t *testing.T) {
|
|||
op.NewEndpointWithURL("/test", "http://test.com/test"),
|
||||
"/test",
|
||||
},
|
||||
{
|
||||
"nil",
|
||||
nil,
|
||||
"",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
@ -43,7 +49,7 @@ func TestEndpoint_Absolute(t *testing.T) {
|
|||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
e op.Endpoint
|
||||
e *op.Endpoint
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
|
@ -77,6 +83,12 @@ func TestEndpoint_Absolute(t *testing.T) {
|
|||
args{"https://host"},
|
||||
"https://test.com/test",
|
||||
},
|
||||
{
|
||||
"nil",
|
||||
nil,
|
||||
args{"https://host"},
|
||||
"",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
@ -91,16 +103,19 @@ func TestEndpoint_Absolute(t *testing.T) {
|
|||
func TestEndpoint_Validate(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
e op.Endpoint
|
||||
wantErr bool
|
||||
e *op.Endpoint
|
||||
wantErr error
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
{
|
||||
"nil",
|
||||
nil,
|
||||
op.ErrNilEndpoint,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := tt.e.Validate(); (err != nil) != tt.wantErr {
|
||||
t.Errorf("Endpoint.Validate() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
err := tt.e.Validate()
|
||||
require.ErrorIs(t, err, tt.wantErr)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue