单元测试 ASP.NET Core AAD 身份验证 [英] Unit Testing ASP.NET Core AAD Auth

查看:126
本文介绍了单元测试 ASP.NET Core AAD 身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Selenium 对 ASP.NET Core MVC Web 应用程序中的 Azure AD 应用程序进行单元测试,并且除了在 DOM 中搜索登录输入元素之外,我还在寻找一种更好的登录测试用户的方法.我在 Azure DevOps 中进行单元测试,因此不能选择使用浏览器 UI 登录.有什么想法吗?

I'm using Selenium to Unit Test an Azure AD application in ASP.NET Core MVC web app and I am looking for a better method of logging in the test user besides searching the DOM for login input elements. I'm Unit Testing in Azure DevOps so logging in with the browser UI is not an option. Any ideas?

推荐答案

在基于 OAuth 的技术中,如果没有交互式重定向,作为用户获取令牌并不容易.出于自动化测试目的,最简单的选择通常是使用 资源所有者密码授予.但是,不建议将其用于实际 UI 中的生产用途.

In OAuth based technologies it is not easy to get a token as a user without an interactive redirect. For automated test purposes the simplest option is often to use the Resource Owner Password Grant. This is not recommended for production usage in real UIs though.

这篇关于单元测试 ASP.NET Core AAD 身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆