chore: replace gorilla/mux with go-chi/chi (#332)
BREAKING CHANGE: The returned router from `op.CreateRouter()` is now a `chi.Router` Closes #301
This commit is contained in:
parent
62caf5dafe
commit
57fb9f77aa
12 changed files with 98 additions and 60 deletions
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/gorilla/schema"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
httphelper "github.com/zitadel/oidc/v2/pkg/http"
|
||||
"github.com/zitadel/oidc/v2/pkg/oidc"
|
||||
"github.com/zitadel/oidc/v2/pkg/op"
|
||||
|
@ -967,3 +966,40 @@ func (m *mockEncoder) Encode(src interface{}, dst map[string][]string) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Test_parseAuthorizeCallbackRequest(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
url string
|
||||
wantId string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "parse error",
|
||||
url: "/?id;=99",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "missing id",
|
||||
url: "/",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "ok",
|
||||
url: "/?id=99",
|
||||
wantId: "99",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := httptest.NewRequest(http.MethodGet, tt.url, nil)
|
||||
gotId, err := op.ParseAuthorizeCallbackRequest(r)
|
||||
if tt.wantErr {
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
assert.Equal(t, tt.wantId, gotId)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue