Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to execute in jmeter cli context with Shared access signature selected #4

Closed
dislev opened this issue Apr 30, 2021 · 2 comments

Comments

@dislev
Copy link
Contributor

dislev commented Apr 30, 2021

Unable to execute in jmeter cli context with Shared access signature selected. Error generated from below:

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.");
} else {
if (credObject instanceof AzAdCredentialComponentImpl) {
AzAdCredentialComponentImpl cred = (AzAdCredentialComponentImpl) credObject;
return cred;
} else {
String errorMsg = "Found object stored under variable:'" + credentialName + "' with class:"
+ credObject.getClass().getName() + "and value: '" + credObject
+ " but it's not a AzAdCredentialComponent, check you're not already using this name as another variable";
log.error(errorMsg);
throw new Exception(errorMsg);
}
}
}

due to the following:

if (getAuthType() == AUTHTYPE_SAS) {
final String connectionString
= "Endpoint=sb://".concat(getNamespaceName()).concat("/;")
.concat("SharedAccessKeyName=").concat(getSharedAccessKeyName()).concat(";")
.concat("SharedAccessKey=").concat(getSharedAccessKey());
requestBody = requestBody.concat("\n")
.concat("Shared Access Policy: ").concat(getSharedAccessKeyName()).concat("\n")
.concat("Shared Access Key: **********");
producerBuilder = producerBuilder.connectionString(connectionString, getEventHubName());
} else { // AUTHTYPE_AAD
AzAdCredentialComponentImpl credential = AzAdCredential.getCredential(getAadCredential());
requestBody = requestBody.concat(credential.getRequestBody());
producerBuilder = producerBuilder.credential(getNamespaceName(), getEventHubName(), credential.getCredential());
}

The if (getAuthType() == AUTHTYPE_SAS) line seems to be causing some unintended behavior where, == compares memory address of the two values (which since AUTHTYPE_SAS is static, it's not the same address). Versus, changing the if statement to getAuthType().equals(AUTHTYPE_SAS), will compare the value of the variables (https://www.geeksforgeeks.org/difference-equals-method-java/).

Actual:
Unable to execute in jmeter cli context with Shared access signature selected with proper parameters

Expected:
Able to execute in jmeter cli context with Shared access signature selected with proper parameters

@dislev
Copy link
Contributor Author

dislev commented May 2, 2021

PRのマージありがとうございました!このバグを解決したという形でクローズして良いでしょうか?

@kuniteru
Copy link
Member

kuniteru commented May 2, 2021

You are right.
I'll be closing this issue since I've merged your pull request.
Thank you very much for your great feedback.

@kuniteru kuniteru closed this as completed May 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants