Skip to content

Commit

Permalink
Merge pull request #22 from pnopjp/MSEntraID
Browse files Browse the repository at this point in the history
Support for name change from Azure Active Directory to Microsoft Entra ID
  • Loading branch information
kuniteru authored Mar 24, 2024
2 parents a868418 + a61450c commit f9cb763
Show file tree
Hide file tree
Showing 19 changed files with 102 additions and 81 deletions.
26 changes: 13 additions & 13 deletions docs/configurations.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Configurations

- **[Azure AD Credential](#azure-ad-credential)**
Configuration for authentication and authorization by Azure AD.
- **[Microsoft Entra ID Credential](#microsoft-entra-id-credential)**
Configuration for authentication and authorization by Microsoft Entra ID.
- **[Azure Service Bus Connection](#azure-servicebus-connection)**
Create a connection to the Azure Service Bus.

## Azure AD Credential
## Microsoft Entra ID Credential

This is the configuration for authentication and authorization by Azure AD.
This is the configuration for authentication and authorization by Microsoft Entra ID.

### How to install

Expand All @@ -21,7 +21,7 @@ Download jmeter-plugins-azure-ad.?.?.?.jar file from [latest release](https://gi
|Name|Descriptive name for this sampler that is shown in the tree|No|
|Variable Name for created credential|Variable name bound to credential. This needs to uniquely identify the configuration. It is used by the Samplers to identify the configuration to be used.|Yes|
|Credential type|Types of credentail.|Yes|
|Authority host|Specifies the Azure Active Directory endpoint to acquire tokens.<br />For general Microsoft Azure, select "login<span></span>.microsoft.online.com". For the Azure Government or Azure China 21Vianet, etc., select the appropriate endpoint.|Yes|
|Authority host|Specifies the Microsoft Entra ID endpoint to acquire tokens.<br />For general Microsoft Azure, select "login<span></span>.microsoft.online.com". For the Azure Government or Azure China 21Vianet, etc., select the appropriate endpoint.|Yes|

### Parameters for each credential type

Expand All @@ -31,8 +31,8 @@ The parameters to be set for each credential type are different.

|Attribute|Description|Required|
|-----|-----|-----|
|Tenant Id|Azure AD tenant Id.|Yes|
|Client Id|Client \(Application\) Id of Azure AD application.|Yes|
|Tenant Id|Microsoft Entra ID tenant Id.|Yes|
|Client Id|Client \(Application\) Id of Microsoft Entra ID application.|Yes|
|File type|Certification file type. \(PEM or PFX\)|Yes|
|Filename|Certification file name.|Yes|
|Password|Password for certification file.|No|
Expand All @@ -41,15 +41,15 @@ The parameters to be set for each credential type are different.

|Attribute|Description|Required|
|-----|-----|-----|
|Tenant Id|Azure AD tenant Id.|Yes|
|Client Id|Client \(Application\) Id of Azure AD application.|Yes|
|Client Secret|Client secret for Azure AD application.|Yes|
|Tenant Id|Microsoft Entra ID tenant Id.|Yes|
|Client Id|Client \(Application\) Id of Microsoft Entra ID application.|Yes|
|Client Secret|Client secret for Microsoft Entra ID application.|Yes|

#### Managed identity

|Attribute|Description|Required|
|-----|-----|-----|
|Client Id|Client \(Application\) Id of Azure AD application.|No|
|Client Id|Client \(Application\) Id of Microsoft Entra ID application.|No|

### Sample files

Expand Down Expand Up @@ -77,10 +77,10 @@ Download jmeter-plugins-azure-servicebus.?.?.?.jar file from [latest release](ht
|Send messages to|Choose whether to send the messages to the "Queue" or to the "Topic".|Yes|
|Queue name / Topic name|Queue/Topic name to send messages to.|Yes|
|Protocol|Protocol for sending messages|Yes|
|Auth Type|Authorization type to use when sending messages to Azure Event Hubs.<br />If you select "Azure AD credential", also define the Azure AD Credential Config Element.|Yes|
|Auth Type|Authorization type to use when sending messages to Azure Event Hubs.<br />If you select "Microsoft Entra ID credential", also define the Microsoft Entra ID Credential Config Element.|Yes|
|Shared Access Policy [\*1](#1-servicebus)|Shared access policy name of the Event Hubs namespace or Event Hub.|Yes|
|Shared Access Key [\*1](#1-servicebus)|Shared access keys for the shared access policy|Yes|
|Variable Name of credential declared in Azure AD Crednetial|The variable name of the credential declared in Azure AD Credential, specified, if "Azure AD credential" is selected for "Auth Type".|Yes|
|Variable Name of credential declared in Microsoft Entra ID Crednetial|The variable name of the credential declared in Microsoft Entra ID Credential, specified, if "Microsoft Entra ID credential" is selected for "Auth Type".|Yes|
|Variable name for created connection|The name of the connection to create.|No|

<span id="1-servicebus">\*1</span>: If "Shared access signature" is selected for Auth type, set these parameters.
Expand Down
16 changes: 8 additions & 8 deletions docs/functions.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Functions

- **[AzAdAccessToken](#__azadaccesstoken)**
Get an access token from Azure AD.
Get an access token from Microsoft Entra ID.
- **[AzAppServiceAuthenticationToken](#__AzAppServiceAuthenticationToken)**
Get an authentication token for Azure App Service
- **[AzCosmosDbAuthZ](#__azcosmosdbauthz)**
Expand All @@ -15,22 +15,22 @@ Download jmeter-plugins-functions-azure-?.?.?.jar file from [latest release](htt

## __AzAdAccessToken

This function gets the access token for the Azure AD application from the Azure AD token endpoint with a password flow.
This function gets the access token for the Microsoft Entra ID application from the Microsoft Entra ID token endpoint with a password flow.

### Parameters

|Attribute|Description|Required|
|----|----|----|
|Azure AD tenant ID|Tenant ID of Azure AD.|Yes|
|Microsoft Entra ID tenant ID|Tenant ID of Microsoft Entra ID.|Yes|
|Grant type|Only "password" can be used.|Yes|
|Application \(Client\) ID|The client identifier of Azure AD application.|Yes|
|Client secret|Client secret of Azure AD application.|Yes|
|Application \(Client\) ID|The client identifier of Microsoft Entra ID application.|Yes|
|Client secret|Client secret of Microsoft Entra ID application.|Yes|
|Username|Access user account name. \(e.g. name<span></span>@example.onmicrosoft.com\)|Yes|
|Password|Access user password.|Yes|
|Scope|Acess Token Scope.|No|
|Resource|App ID URI of the receiving web service.<br />Valid only for Azure AD version 1.<br />If you omit this, the "Application ID" value is applied.|No|
|Azure AD version|v2.0 or empty string.|No|
|Azure AD endpoint URI|Specify when using an Azure AD endpoint, such as Azure Government or Azure China.<br />\(e.g. login<span></span>.partner.microsoftonline.cn\)<br />Or you can use some abbreviations. \(us / cn / de\)<br />The default is Azure global endpoint.<br />\* But I haven't been able to test with Azure Govement, Azure China or Azure Germany, because I don't have subscriptions there. If you use these Azure, I would be happy to have you report your results to [here](https://github.com/pnopjp/jmeter-plugins/issues).|No|
|Resource|App ID URI of the receiving web service.<br />Valid only for Microsoft Entra ID version 1.<br />If you omit this, the "Application ID" value is applied.|No|
|Microsoft Entra ID version|v2.0 or empty string.|No|
|Microsoft Entra ID endpoint URI|Specify when using an Microsoft Entra ID endpoint, such as Azure Government or Azure China.<br />\(e.g. login<span></span>.partner.microsoftonline.cn\)<br />Or you can use some abbreviations. \(us / cn / de\)<br />The default is Azure global endpoint.<br />\* But I haven't been able to test with Azure Govement, Azure China or Azure Germany, because I don't have subscriptions there. If you use these Azure, I would be happy to have you report your results to [here](https://github.com/pnopjp/jmeter-plugins/issues).|No|
|Name of variable|The name of the variable to set.|No|

### Examples
Expand Down
12 changes: 6 additions & 6 deletions docs/samplers.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Download jmeter-plugins-azure-eventhubs.?.?.?.jar file from [latest release](htt
|Event Hubs Namespace|Azure Event Hubs namespace name to send messages to.<br />\(e.g. YOUREVENTHUBS<span></span>.servicebus.windows.net\)|Yes|
|Event Hub|Event Hub name to send messages to.|Yes|
|Partition|Partition to send message to. You can select either Not specified, Partition Key, or Partition ID.|No|
|Auth Type|Authorization type to use when sending messages to Azure Event Hubs.<br />If you select "Azure AD credential", also define the Azure AD Credential Config Element.|Yes|
|Auth Type|Authorization type to use when sending messages to Azure Event Hubs.<br />If you select "Microsoft Entra ID credential", also define the Microsoft Entra ID Credential Config Element.|Yes|
|Shared Access Policy [\*1](#1-eventhubs)|Shared access policy name of the Event Hubs namespace or Event Hub.|No|
|Shared Access Key [\*1](#1-eventhubs)|Shared access keys for the shared access policy|No|
|Variable Name of credential declared in Azure AD Crednetial|The variable name of the credential declared in Azure AD Credential, specified if "Azure AD credential" is selected for "Auth Type".|No|
|Variable Name of credential declared in Microsoft Entra ID Crednetial|The variable name of the credential declared in Microsoft Entra ID Credential, specified if "Microsoft Entra ID credential" is selected for "Auth Type".|No|
|Event data|List of messages to be sent in batches. Select "String" to send a UTF-8 string, "Base64 encoded binary" to send a Base64 encoded binary, or "File" to send a file as binary.|No|

<span id="1-eventhubs">\*1</span>: Set these parameters only if "Shared access signature" is selected in Auth type.
Expand Down Expand Up @@ -65,10 +65,10 @@ Download jmeter-plugins-azure-servicebus.?.?.?.jar file from [latest release](ht
|Send messages to [\*1](#1-servicebus)|Choose whether to send the messages to the "Queue" or to the "Topic".|Yes|
|Queue name / Topic name [\*1](#1-servicebus)|Queue/Topic name to send messages to.|Yes|
|Protocol|Protocol for sending messages|Yes|
|Auth Type [\*1](#1-servicebus)|Authorization type to use when sending messages to Azure Event Hubs.<br />If you select "Azure AD credential", also define the Azure AD Credential Config Element.|Yes|
|Auth Type [\*1](#1-servicebus)|Authorization type to use when sending messages to Azure Event Hubs.<br />If you select "Microsoft Entra ID credential", also define the Microsoft Entra ID Credential Config Element.|Yes|
|Shared Access Policy [\*1](#1-servicebus) [\*2](#2-servicebus)|Shared access policy name of the Event Hubs namespace or Event Hub.|No|
|Shared Access Key [\*1](#1-servicebus) [\*2](#2-servicebus)|Shared access keys for the shared access policy|No|
|Variable Name of credential declared in Azure AD Crednetial [\*1](#1-servicebus)|The variable name of the credential declared in Azure AD Credential, specified, if "Azure AD credential" is selected for "Auth Type".|No|
|Variable Name of credential declared in Microsoft Entra ID Crednetial [\*1](#1-servicebus)|The variable name of the credential declared in Microsoft Entra ID Credential, specified, if "Microsoft Entra ID credential" is selected for "Auth Type".|No|
|Create transaction before sending messages|Create a transaction before sending a messages.|No|
|Variable name for created transaction|The name of the transaction to create, if "Create transaction before sending messages" is turned on.|No|
|Transaction state|Specify whether to commit or rollback, if "Use Defined Transaction" is selected for "Connection/Transaction".<ul><li>\[Continue transaction\]<br />No commit, and no rollback.</li><li>\[Commit transaction after sending messages\]<br />Commits the specified transaction after sending the messages.</li><li>\[Rollback transaction before sending messages\]<br />Sends the messages after the specified transaction is rolled back. (Sending messages are not included in the transaction)</li></ul>|No|
Expand Down Expand Up @@ -103,13 +103,13 @@ Download jmeter-plugins-azure-storage-queue.?.?.?.jar file from [latest release]
|Attribute|Description|Required|
|-----|-----|-----|
|Name|Descriptive name for this sampler that is shown in the tree|No|
|Auth type|Authorization type to use when sending messages to Azure Storage Queue.<br />If you select "Azure AD credential", also define the Azure AD Credential Config Element.|Yes|
|Auth type|Authorization type to use when sending messages to Azure Storage Queue.<br />If you select "Microsoft Entra ID credential", also define the Microsoft Entra ID Credential Config Element.|Yes|
|Connection string|Connection string of the target Azure Storage, specified if "Auth type" is selected for "Connection string".|No|
|Default Endpoints Protocol [\*1](#1-storagequeue)|Select the protocol from "http" or "https".|No|
|Account Name [\*1](#1-storagequeue)|Target Azure storage account name.|No|
|Storage Key [\*1](#1-storagequeue)|Storage key of the target Azure Storage.|No|
|Endpoint Suffix [\*1](#1-storagequeue)|Usually, "core<span></span>.windows.net" is specified. However, if your target is Azure Government, specify "core<span></span>.usgovcloudapi.net", and if your target is Azure China, specify "core<span></span>.chinacloudapi.cn". In this way, if a Storage Queue other than Azure Public is targeted, specify the appropriate suffix.|No|
|Variable Name of credential declared in Azure AD Crednetial [\*2](#2-storagequeue)|The variable name of the credential declared in Azure AD Credential.|No|
|Variable Name of credential declared in Microsoft Entra ID Crednetial [\*2](#2-storagequeue)|The variable name of the credential declared in Microsoft Entra ID Credential.|No|
|Endpoint URL [\*2](#2-storagequeue) [\*3](#3-storagequeue)|Endpoint URL of the target Azure Storage Queue.|No|
|Queue name|Queue name to send message to.|Yes|
|SAS token [\*3](#3-storagequeue)|Shared access signature token string. It is sometimes called a "Query string".|No|
Expand Down
2 changes: 1 addition & 1 deletion plugins/functions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>jp.co.pnop</groupId>
<artifactId>jmeter-plugins-functions-azure</artifactId>
<version>0.4.3</version>
<version>0.4.4</version>

<name>Custom JMeter functions for Azure</name>
<description>Custom JMeter functions for Azure</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ public class AzAdAccessToken extends AbstractFunction {
private static final int MAX_PARAMETER_COUNT = NAME_OF_VAL + 1;

static {
desc.add("Azure AD Tenant ID");
desc.add("Microsoft Entra ID Tenant ID");
desc.add("Grant type");
desc.add("Application (Client) ID");
desc.add("Client secret of Azure AD application");
desc.add("Client secret of Microsoft Entra ID application");
desc.add("Username");
desc.add("Password");
desc.add("Acess Token Scope (optional)");
desc.add("Resource (optional)");
desc.add("Azure AD version (optional)");
desc.add("Azure AD endpoint URI (optional)");
desc.add("Microsoft Entra ID version (optional)");
desc.add("Microsoft Entra ID endpoint URI (optional)");
desc.add("Name of variable in which to store the result (optional)");
}

Expand Down Expand Up @@ -153,9 +153,9 @@ public synchronized String execute(SampleResult previousResult, Sampler currentS
accessToken = node.get("access_token").textValue();
addVariableValue(accessToken, values, NAME_OF_VAL);
} else {
log.info("Warn calling {} Azure AD request, Response status: {}, Response body {}", KEY, status, responseMessage);
log.info("Warn calling {} Microsoft Entra ID request, Response status: {}, Response body {}", KEY, status, responseMessage);
String errorDescription = node.get("error_description").textValue();
log.warn("Warn calling {} Azure AD request, {}: {}", KEY, response.getStatusLine().toString(),
log.warn("Warn calling {} Microsoft Entra ID request, {}: {}", KEY, response.getStatusLine().toString(),
errorDescription);
}
} catch (IllegalArgumentException e) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/protocol/aad/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

<groupId>jp.co.pnop</groupId>
<artifactId>jmeter-plugins-azure-ad</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>

<name>Azure AD Credential Configure</name>
<name>Microsoft Entra ID Credential Configure</name>
<description>Conigure of Azure Active Directory Configure</description>
<licenses>
<license>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ public void testStarted() {
JMeterVariables variables = getThreadContext().getVariables();
String credentialName = getCredentialName();
if (JOrphanUtils.isBlank(credentialName)) {
log.error("Name for Azure AD credential must not be empty in " + getName());
log.error("Name for Microsoft Entra ID credential must not be empty in " + getName());
} else if (variables.getObject(credentialName) != null) {
log.error("Azure AD credential already defined for: {}", credentialName);
log.error("Microsoft Entra ID credential already defined for: {}", credentialName);
} else {
variables.putObject(credentialName, new AzAdCredentialComponentImpl());
}
Expand All @@ -234,7 +234,7 @@ public Object clone() {
public static AzAdCredentialComponentImpl getCredential(String credentialName) throws Exception {
Object credObject = JMeterContextService.getContext().getVariables().getObject(credentialName);
if (credObject == null) {
throw new Exception("No credential found named: '" + credentialName + "', ensure Variable Name matches Variable Name of Azure AD Credentail.");
throw new Exception("No credential found named: '" + credentialName + "', ensure Variable Name matches Variable Name of Microsoft Entra ID Credentail.");
} else {
if (credObject instanceof AzAdCredentialComponentImpl) {
AzAdCredentialComponentImpl cred = (AzAdCredentialComponentImpl) credObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public String getLabelResource() {
}

public String getStaticLabel() {
return "Azure AD Credential";
return "Microsoft Entra ID Credential";
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions plugins/protocol/eventhubs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>jp.co.pnop</groupId>
<artifactId>jmeter-plugins-azure-eventhubs</artifactId>
<version>0.2.4</version>
<version>0.2.5</version>

<name>Azure Event Hubs Sampler</name>
<description>Sample to Azure Event Hubs</description>
Expand Down Expand Up @@ -128,7 +128,7 @@
<dependency>
<groupId>jp.co.pnop</groupId>
<artifactId>jmeter-plugins-azure-ad</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

import com.azure.messaging.eventhubs.*;
import com.azure.messaging.eventhubs.models.CreateBatchOptions;
import com.azure.core.amqp.exception.*;
import com.azure.core.amqp.exception.AmqpException;

import jp.co.pnop.jmeter.protocol.aad.config.AzAdCredential;
import jp.co.pnop.jmeter.protocol.aad.config.AzAdCredential.AzAdCredentialComponentImpl;
Expand Down Expand Up @@ -86,6 +86,7 @@ public class AzEventHubsSampler extends AbstractSampler implements TestStateList

public static final String AUTHTYPE_SAS = "Shared access signature";
public static final String AUTHTYPE_AAD = "Azure AD credential";
public static final String AUTHTYPE_ENTRAID = "Microsoft Entra ID credential";

public static final String PARTITION_TYPE_NOT_SPECIFIED = "Not specified";
public static final String PARTITION_TYPE_ID = "ID";
Expand Down Expand Up @@ -206,7 +207,7 @@ public SampleResult sample(Entry e) {
.concat("Shared Access Policy: ").concat(getSharedAccessKeyName()).concat("\n")
.concat("Shared Access Key: **********");
producerBuilder = producerBuilder.connectionString(connectionString, getEventHubName());
} else { // AUTHTYPE_AAD
} else { // AUTHTYPE_ENTRAID or AUTHTYPE_AAD
AzAdCredentialComponentImpl credential = AzAdCredential.getCredential(getAadCredential());
requestBody = requestBody.concat(credential.getRequestBody());
producerBuilder = producerBuilder.credential(getNamespaceName(), getEventHubName(), credential.getCredential());
Expand Down
Loading

0 comments on commit f9cb763

Please sign in to comment.