| 1 |
package mock |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"github.com/golang/mock/gomock" |
| 7 |
|
| 8 |
"github.com/zitadel/oidc/v3/pkg/oidc" |
| 9 |
"github.com/zitadel/oidc/v3/pkg/op" |
| 10 |
) |
| 11 |
|
| 12 |
func NewClient(t *testing.T) op.Client { |
| 13 |
return NewMockClient(gomock.NewController(t)) |
| 14 |
} |
| 15 |
|
| 16 |
func NewClientExpectAny(t *testing.T, appType op.ApplicationType) op.Client { |
| 17 |
c := NewClient(t) |
| 18 |
m := c.(*MockClient) |
| 19 |
m.EXPECT().RedirectURIs().AnyTimes().Return([]string{ |
| 20 |
"https://registered.com/callback", |
| 21 |
"http://registered.com/callback", |
| 22 |
"http://localhost:9999/callback", |
| 23 |
"custom://callback", |
| 24 |
}) |
| 25 |
m.EXPECT().ApplicationType().AnyTimes().Return(appType) |
| 26 |
m.EXPECT().LoginURL(gomock.Any()).AnyTimes().DoAndReturn( |
| 27 |
func(id string) string { |
| 28 |
return "login?id=" + id |
| 29 |
}) |
| 30 |
m.EXPECT().IsScopeAllowed(gomock.Any()).AnyTimes().Return(false) |
| 31 |
return c |
| 32 |
} |
| 33 |
|
| 34 |
func NewClientWithConfig(t *testing.T, uri []string, appType op.ApplicationType, responseTypes []oidc.ResponseType, devMode bool) op.Client { |
| 35 |
c := NewClient(t) |
| 36 |
m := c.(*MockClient) |
| 37 |
m.EXPECT().RedirectURIs().AnyTimes().Return(uri) |
| 38 |
m.EXPECT().ApplicationType().AnyTimes().Return(appType) |
| 39 |
m.EXPECT().ResponseTypes().AnyTimes().Return(responseTypes) |
| 40 |
m.EXPECT().DevMode().AnyTimes().Return(devMode) |
| 41 |
return c |
| 42 |
} |