首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AD Azure AD- Bearer令牌配置函数

AD Azure AD- Bearer令牌配置函数
EN

Stack Overflow用户
提问于 2019-05-23 13:19:22
回答 1查看 3.1K关注 0票数 0

我在Visual中创建了一个插件,它使用以下类:

代码语言:javascript
复制
using Microsoft.Azure.KeyVault;
using Microsoft.Azure.Services.AppAuthentication;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.AzureKeyVault;

此类使用客户端ID、客户端秘密和资源ID输出承载令牌,该令牌被附加到请求的头部,以提供对位于Azure中的应用程序的性能测试访问。

然而,我们现在希望转移到使用JMeter。目标是在JMeter中创建相同的函数。

我看过各种论坛和网站。然而,在使用所需的变量方面,它似乎并没有完全满足我所寻找的内容,而是逐步遍历配置令牌的Microsoft配置。

代码语言:javascript
复制
public string TenantId = "{TenantID}";
public string Authority = "{Authority URL}";

private static IConfiguration Configuration;
private ApplicationAuthenticator _applicationAuthenticator;

public override void PreWebTest(object sender, PreWebTestEventArgs e)
    {
        Configuration = 
TestConfigurationBuilder.BuildConfiguration(KeyVaultUrl, AppId, TenantId, 
AppKey, Authority);

        _applicationAuthenticator = new 
ApplicationAuthenticator(Authority);
        string token = 
_applicationAuthenticator.SetToken
(Configuration[ClientIdKeyVaultVariable], 
Configuration[ClientSecretKeyVaultVariable], 
Configuration[ResourceIdKeyVaultVariable]);

        e.WebTest.Context.Add("AuthToken", $"Bearer {token}");
    }

这是使用C#在Visual中生成{token}的代码。

为了输出相同的值,我需要在JMeter中使用哪些类和函数?

EN

回答 1

Stack Overflow用户

发布于 2022-07-15 11:15:48

索德定律.我能让剧本运行起来。下面的链接很有用:https://swtestacademy.com/jmeter-tutorial-api-performance-testing

比我想象的要简单。第一个HTTP请求需要遵循以下内容:

代码语言:javascript
复制
login.microsoftonline.com/{company specific}/oauth2/token?= 

添加变量:- grant_type - client_id - client_secret - resource

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56276193

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档