Assert something about the returned userinfo

This commit is contained in:
Andy Lindeman 2019-06-24 09:39:54 -04:00
parent 46f5726d11
commit 840065faaf

View File

@ -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
}, },
}, },