pnopjp / jmeter-plugins

Apache JMeter plugins for Microsoft Azure
Apache License 2.0
17 stars 13 forks source link

NullPointerException AzAdAccessToken.execute #6

Closed germantempone closed 3 years ago

germantempone commented 3 years ago

Hi there,

I have the below message when try to run a test plan.

java.lang.NullPointerException
    at jp.co.pnop.jmeter.functions.AzAdAccessToken.execute(AzAdAccessToken.java:156)
    at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:138)
    at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:113)
    at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:100)
    at org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(AbstractTestElement.java:280)
    at org.apache.jmeter.protocol.http.control.Header.getValue(Header.java:91)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.setConnectionHeaders(HTTPHC4Impl.java:1406)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.setupRequest(HTTPHC4Impl.java:1303)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:622)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1296)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1285)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
    at java.lang.Thread.run(Unknown Source)

Can you say me what I'm missing?

It' a simple test plan with a csv credentials, client_secret, client_id, tenant_id and AZ login

Thanks

kuniteru commented 3 years ago

It seems that Azure AD is returning an error for some reason. To investigate the cause, we have released v0.4.1, which has been modified to output logs the response from Azure AD. https://github.com/pnopjp/jmeter-plugins/releases/download/function0.4.2/jmeter-plugins-functions-azure-0.4.2.jar Using this, please run the same test again and check the logs.

germantempone commented 3 years ago

Hi @kuniteru thanks for the response.

It's seams the Tenant ID not exits. It's odd because we use that url to login. 2021-08-02 09:28:46,307 INFO o.a.j.e.StandardJMeterEngine: Running the test! 2021-08-02 09:28:46,307 INFO o.a.j.s.SampleEvent: List of sample_variables: [] 2021-08-02 09:28:46,310 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*) 2021-08-02 09:28:46,427 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group 2021-08-02 09:28:46,428 INFO o.a.j.e.StandardJMeterEngine: Starting 15 threads for group Thread Group. 2021-08-02 09:28:46,428 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error 2021-08-02 09:28:46,428 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=15 ramp-up=1 delayedStart=false 2021-08-02 09:28:46,431 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1 2021-08-02 09:28:46,432 INFO o.a.j.s.FileServer: Stored: C:/Users/*************/Desktop/credentials.csv 2021-08-02 09:28:46,435 INFO o.a.j.t.ThreadGroup: Started thread group number 1 2021-08-02 09:28:46,435 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started 2021-08-02 09:28:46,497 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-2 2021-08-02 09:28:46,564 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-3 2021-08-02 09:28:46,640 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-4 2021-08-02 09:28:46,697 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-5 2021-08-02 09:28:46,742 INFO j.c.p.j.f.AzAdAccessToken: Warn calling __AzAdAccessToken Azure AD request, Response status: 404, Response body 2021-08-02 09:28:46,742 ERROR j.c.p.j.f.AzAdAccessToken: Error calling __AzAdAccessToken function with Tenant ID https://login.microsoftonline.com/*****-****-****-****-********, grant_type password, client_id *******-****-****-****-********, username test.user@somedomain.com, scope , resource *******-****-****-****-********, aadVersion , aadUri login.microsoftonline.com, java.lang.NullPointerException: null at jp.co.pnop.jmeter.functions.AzAdAccessToken.execute(AzAdAccessToken.java:157) [jmeter-plugins-functions-azure-0.4.2.jar:?] at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:138) [ApacheJMeter_core.jar:5.4.1] at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:113) [ApacheJMeter_core.jar:5.4.1] at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:100) [ApacheJMeter_core.jar:5.4.1] at org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(AbstractTestElement.java:280) [ApacheJMeter_core.jar:5.4.1] at org.apache.jmeter.protocol.http.control.Header.getValue(Header.java:91) [ApacheJMeter_http.jar:5.4.1] at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.setConnectionHeaders(HTTPHC4Impl.java:1406) [ApacheJMeter_http.jar:5.4.1] at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.setupRequest(HTTPHC4Impl.java:1303) [ApacheJMeter_http.jar:5.4.1] at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:622) [ApacheJMeter_http.jar:5.4.1] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66) [ApacheJMeter_http.jar:5.4.1] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1296) [ApacheJMeter_http.jar:5.4.1] at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1285) [ApacheJMeter_http.jar:5.4.1] at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638) [ApacheJMeter_core.jar:5.4.1] at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558) [ApacheJMeter_core.jar:5.4.1] at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) [ApacheJMeter_core.jar:5.4.1] at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) [ApacheJMeter_core.jar:5.4.1] at java.lang.Thread.run(Unknown Source) [?:1.8.0_301]

I replaced the sensitive data for *

Thanks again!

germantempone commented 3 years ago

I'm going to close the issue, thanks again!

kuniteru commented 3 years ago

Isn't the first argument, Tenant ID, specified incorrectly? According to the log, you wrote "https://login.microsoftonline.com/*****-********-****-********". The Tenant ID should be something like "*****-****-****-****-********" or "********.onmicrosoft.com".

germantempone commented 3 years ago

Thanks for the update @kuniteru working like a charm