forked from mystiq/dex
Assert something about the returned userinfo
This commit is contained in:
parent
46f5726d11
commit
840065faaf
1 changed files with 4 additions and 1 deletions
|
@ -203,10 +203,13 @@ func TestOAuth2CodeFlow(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "fetch userinfo",
|
name: "fetch userinfo",
|
||||||
handleToken: func(ctx context.Context, p *oidc.Provider, config *oauth2.Config, token *oauth2.Token) error {
|
handleToken: func(ctx context.Context, p *oidc.Provider, config *oauth2.Config, token *oauth2.Token) error {
|
||||||
_, err := p.UserInfo(ctx, config.TokenSource(ctx, token))
|
ui, err := p.UserInfo(ctx, config.TokenSource(ctx, token))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to fetch userinfo: %v", err)
|
return fmt.Errorf("failed to fetch userinfo: %v", err)
|
||||||
}
|
}
|
||||||
|
if conn.Identity.Email != ui.Email {
|
||||||
|
return fmt.Errorf("expected email to be %v, got %v", conn.Identity.Email, ui.Email)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue