(
t *testing.T,
reg interface {
config.Provider
client.Registry
},
opts ...func(*client.Client),
)
| 839 | } |
| 840 | |
| 841 | func newDeviceClient( |
| 842 | t *testing.T, |
| 843 | reg interface { |
| 844 | config.Provider |
| 845 | client.Registry |
| 846 | }, |
| 847 | opts ...func(*client.Client), |
| 848 | ) (*client.Client, *oauth2.Config) { |
| 849 | ctx := context.Background() |
| 850 | c := &client.Client{ |
| 851 | GrantTypes: []string{ |
| 852 | "refresh_token", |
| 853 | "urn:ietf:params:oauth:grant-type:device_code", |
| 854 | }, |
| 855 | Scope: "hydra offline openid", |
| 856 | Audience: []string{"https://api.ory.sh/"}, |
| 857 | TokenEndpointAuthMethod: "none", |
| 858 | } |
| 859 | |
| 860 | // apply options |
| 861 | for _, o := range opts { |
| 862 | o(c) |
| 863 | } |
| 864 | |
| 865 | require.NoError(t, reg.ClientManager().CreateClient(ctx, c)) |
| 866 | return c, &oauth2.Config{ |
| 867 | ClientID: c.GetID(), |
| 868 | Endpoint: oauth2.Endpoint{ |
| 869 | DeviceAuthURL: reg.Config().OAuth2DeviceAuthorisationURL(ctx).String(), |
| 870 | TokenURL: reg.Config().OAuth2TokenURL(ctx).String(), |
| 871 | AuthStyle: oauth2.AuthStyleInHeader, |
| 872 | }, |
| 873 | Scopes: strings.Split(c.Scope, " "), |
| 874 | } |
| 875 | } |
no test coverage detected