简体   繁体   English

在C#中创建OAuth客户端以进行自动化测试

[英]create an OAuth client in c# for automation testing

I am trying to test againt a service that implements the OAuth 2.0 authentication protocol and I want to run the automation without using any browser elements. 我正在尝试再次测试实现OAuth 2.0身份验证协议的服务,并且我想在不使用任何浏览器元素的情况下运行自动化。 Is that possible and if so how? 那有可能吗?

What i am currently doing is opening a browser and then sending user/key combination and then on redirect, I get the access token from the URL which I then use in subsequent REST calls. 我目前正在做的是打开浏览器,然后发送用户/密钥组合,然后重定向,然后从URL获取访问令牌,然后将其用于后续的REST调用中。 but this method takes a bit of time and may not be completely reliable for running lots of tests. 但是这种方法会花费一些时间,并且对于运行大量测试可能并不完全可靠。

Is there any way that I can programatically handle the initial handshake, ie, send the user/key, get the permission request page and then accept it through c# as well and finally get the access token without any browser in the middle? 有什么办法可以以编程方式处理初始握手,即发送用户/密钥,获取权限请求页面,然后也通过c#接受它,最后获得中间没有任何浏览器的访问令牌?

Check out DotNetOpenAuth - http://www.dotnetopenauth.net/ 查看DotNetOpenAuth- http://www.dotnetopenauth.net/

You should be able to write automated test cases quite simply 您应该能够非常简单地编写自动化测试用例

You could try service account authentication for your test system. 您可以尝试对测试系统进行服务帐户身份验证。 This approach replaces user interaction with cryptographically signed JSON Web Tokens (JWTs). 这种方法用加密签名的JSON Web令牌(JWT)代替了用户交互。

Google's implementation docs have some details. Google的实施文档中有一些详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM