Jmeter OAuth 1.0 Request - java

I have a Java code for OAuth 1.0 Authentication and each time i have to execute it before testing each request. I am currently working on JSR223 sampler.
But happen to see this OAuth 1.0 Plugin, can someone explain me how this OAuth 1.0 based Authentication in the screenshot works.
I have some parameter value to be passed in the Authorization header output example given below for each request.
For the first URL, I have two parameter
Key
Secret Key
Which give the Access token and secret access token for the Second URL and for the third it will add
request Payload
Email
Status
without these the request will fail.
My output code looks like the below in Eclipse:-
Authorization :OAuth oauth_signature="Dynamic Value",scope="Parameter Value",oauth_version="Dynamic Value",oauth_nonce="Dynamic Value",oauth_signature_method=HMAC-SHA1,oauth_consumer_key="Parameter Value",oauth_token="Dynamic Value",oauth_timestamp="Dynamic Value"
Is there a way that i run the piece of Java code directly with all the Jar files in Jmeter [without doing any changes] is that possible?
OAuth 1.0 Plugin

I would suggest adding OAuth client libraries to JMeter's classpath (just drop them to /lib folder of your JMeter installation)
Also download the latest version of groovy-all.jar and put it to the same /lib folder. Restart JMeter to pick the jars up.
Then add JSR223 Sampler to your Test Plan, choose "groovy" in "Language" drop-down and put your Java code to "Script" area. Valid Java code in 99% of cases will be valid Groovy code so you can run it this way.
See How to Run Performance Tests on OAuth Secured Apps with JMeter guide for more detailed information on the domain.

Related

Generate java code from WSDL when HTTP authentication is enabled

I have custom wsdl url. Now in Intelij I am trying to generate java classes using this wsdl. I tried to use Tools->WebServices->Generate Java Code From Wsdl. When **http-auth is disabled on my wsdl url, this option Apache axis 2 works good, But it's required that http-auth to be enabled. There is no option under Axis 2 to enter username and password. I've also tried Apache axis option. I entered user/password after that ok button enabled but after clicking on it I got an error: Server returned HTTP response code: 401 for URL: mywsdlurl. There is also Glassfix/Jax-WS 2.2 RI /Metro 1.X / JWSDP 2.2 option which worked fine before enabling http-auth. Can someone suggest correct way how to generate Java code from WSDL when http authentication is enabled?
You could try to set up proxy (like tinyProxy) that adds authroziation header to the requests with proper credentials encoded and configure your IDE to work throughout that proxy.
After trying 3 hours I found this solution. I created file someFile.txt with the content http://user:pass#host:port/ws/mywsdl.wsdl. And then in the same directory opened cmd and executed command:
wsimport -Xauthfile "someFile.txt" -keep -p com.demo.my_package_name "http://host:port/ws/mywsdl.wsdl"
And then generated package/classes copied into my project.
Take into account that you have to add C:\Program Files\Java\java_version\bin into your EnvironmentVariables->path section. Otherwise wsimport won't work.
Hope this helps to someone.

Maven automated deploy on google app engine

I know that to deploy onto app-engine you can run the maven command:
mvn appengine:update
Which then prompts for the auth code and launches a browser to confirm you want to publish onto the app engine. I'm looking to automate this fully so it can just be run as a command from maven. I have the appengine-maven-plugin setup but there doesn't seem to be any functionality to skip the manual step.
Has anyone managed to solve this? I know you can deploy right from Jenkins but we're looking for a solution that could be automates if our Jenkins server was down
Thanks
The authentication flow which redirects you to the browser for login and consent is call three-legged Oauth because it involves three steps: 1) request for a token 2) login and consent 3) API call with token.
An authentication flow which does not involve user login and consent is called two-legged Oauth (server to server): 1) request for a token, signed with a private key 2) API call with token. Server to server auth requires that you setup a service account with appropriate permissions (scopes). You must also safely distribute the private key for that service account so that you can sign your requests. See the OAuth2ServiceAccount instructions
The Bitnami Jenkins image actually does quite a bit for you out of the box. When you setup Push-to-Deploy you launch an instance with gcloud. That launch command specifies the scopes you want that images to have access too with the --scopes parameter, including "https://www.googleapis.com/auth/appengine.admin". Permission to these scopes is given to the default project service account. When Jenkins deploys your code, the service account credentials are made available through the Jenkins Google Oauth Plugin.
You can build another tool that will push code programatically. You will need to create a service account which generates a JSON Web Token (JWT) Again see the Outh2ServiceAccount instructions. The JWT is your private credential and you need to find a secure place to store it. The App Engine SDK knows how to use JWTs to get auth tokens.
During runtime you can pass the path to the JWT file as the --service_account_json_key_file parameter to appcfg.py. To plumb that parameter through the Maven plugin you'll have to use -DadditionalParams="--service_account_json_key_file " which is available on the tip of github.com/GoogleCloudPlatform/appengine-maven-plugin/master. (Will be in App Engine release 1.9.27, but you can pull from Github until then.)

How the architecture should be for a Java command line app integrating with shopify

In my company we have a custom point of sale which was built in house, and I am assigned to integrate the POS with the shopify. For the mvp, we have decided to go with the simple java app, which will run from the command line. I have done the following
1) Went to www.shopify.com/app-developers and then got my private store bla.myshopify.com. 2) Then went to Apps -> private apps. Got my API key, password and shared secret. As I have mentioned, we are doing a simple java app which can run from command line. This app will read all the keys from the local file. Now should I be doing OAUTH? As they have mentioned to redirect to a web page in here https://docs.shopify.com/api/authentication/oauth. Since we have don't have a webpage, where should I redirect the user to?
And is there anything wrong I am doing? Kindly correct me if there is a better architecture
Basic Authentication works with Shopify: Whatever package you are using for your http connection should have tools to let you set the Authorization header. Look up pre-emptive authorization for your package and use the API Key:Password (from the private app) for the Base 64 encrypted credential token

How to connect Jmeter to Java class?

I am new to Jmeter. Currently i have tested web service calls in Jmeter. I have sent a request to server through web service calls. My input is xml file and its encrypted form. So i given encrypted string in PostBody.
My problem is I'm not able to do the encryption process in Jmeter.
So i have decided to connect jmeter to my java class and send to server.
Jmeter--->Java class--->server.
I have used Jmeter 2.8
Is there any possible to connect Jmeter to java class?
I am not sure to understand but if what you want to do is the following:
Encrypt some XML
Pass it as Raw Post Body to the HTTP Sampler which will call your webservice
Then the answer to do that is the following:
Add groovy-all.jar in JMETER_HOME/lib folder
Use a JSR223 Pre Processor on your HTTP sampler, and put the following Groovy code:
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
import org.apache.jmeter.protocol.http.util.HTTPArgument;
HTTPSamplerBase httpSamplerBase = (HTTPSamplerBase) sampler;
HTTPArgument argument =
httpSamplerBase.getArguments().getArgument(0);
String valueToEncrypt = argument.getValue();
// Do you encryption here, in this example I put ENC for testing
valueToEncrypt = "ENC"+valueToEncrypt;
httpSamplerBase.getArguments().clear();
httpSamplerBase.addNonEncodedArgument("", valueToEncrypt, "");
In the HTTP Sampler, put your original XML to be encrypted in Raw Post Body text area
Plan will have following structure (HTTP mirror server is just for my test):
Note: I use current JMeter nightly build so I have Script Compilation caching part which is not yet available and will be in 2.9. Instead put your script in an external file and reference it in File Name field.
jMeter can talk to a lot of things (see this list at Apache). One is JMS and that could probably be used to connect to your java server. Or http (which it's normally used for). It all depends on what your java class is able to respond to.
You can also make a jar of your java class, and append it to your test plan. You can then reference them from the JSR223 preprocessor with the groovy engine.

Hudson project without user interface

Can I configure, create/update the existing project in Hudson without using its user interface?
Is it possible by changing configuration file or other mean?
The Remote Access API page mentions that you an create/copy job with it.
Remote access API is offered in a REST-like style.
That is, there is no single entry point for all features, and instead they are available under the ".../api/" URL where "..." portion is the data that it acts on.
For example, if your Hudson installation sits at http://deadlock.netbeans.org/hudson/, http://deadlock.netbeans.org/hudson/api/ will give you HTML lists of all available functionality that act on the Hudson root.
On my Hudson, the /api address gives:
Create Job
To create a new job, post config.xml to this URL with query parameter name=JOBNAME.
You'll get 200 status code if the creation is successful, or 4xx/5xx code if it fails.
config.xml is the format Hudson uses to store the project in the file system, so you can see examples of them in /server/path/to/your/hudson/home.

Categories

Resources