How do I want to generate a hash using beanshell(SHA1) in JMeter to sign up to a application?
I'm not able to get a substantial answer yet from net
Generating a hash is pretty easy, just use DigestUtils class from Apache Commons Codec library (it's a part of JMeter so you won't need to install anything external)
Something like:
import org.apache.commons.codec.digest.DigestUtils;
String foo = "bar";
String sha1Hex = DigestUtils.sha1Hex(foo);
Usually SHA1 is being required for signing requests to OAuth-protected applications, if it is your case, I believe How to Run Performance Tests on OAuth Secured Apps with JMeter will be extremely helpful.
There's a new JMeter function __digest, currently in nightly builds which can be used to encode strings
In your case to save in sha1Value variable the result of myVar variable use the following:
${__digest(SHA-1,${myVar},,,sha1Value)}
4th parameter is uppercase, so you can send true to automatically uppercase it.
Related
I am trying to create a load test versus one of our apps that is used on web and mobile. I am trying to access this app from the web. I login to the website. Using this login, I click on the web version of the app. The below response is returned here.
This app is using SiteMinder and Worklight to negotiate with the main site I am coming from.
My question is, how do I correlate a value such as 'SMIDENTITY=' when it is being returned TWICE in the same string?
Here is an example of what is being returned by the server (I have broken up the string so the variables are separated:
Test4.c(225):
Cookie:testcookie=oreo;
SMIDENTITY=Cq16kwJwrJWgBd5zQ8ci0kP8IEZ47kftOxMr1wVsxx+W/7sGS92ZA9zu69GRpolh0PRX97bvfHRya0m1ty1E07qR0HjKKXE8ypRsWPgG4m2w8mlspPUxL8t5Z4RE5/CCJpOxpXHIHeQK4f77gkihKFq8cBQr+Vy9kZGFGMUJH6+EiLNmmJT+XYZcUi7gzV0r+naJypMewtXAYaOcvn8Kqsu2JA5SiNUcJbxxX4dNCHOsC4cf45Jm0H40Efq6nOwN7MDyAE2gXSou4oa9ZlYxlsvWdEVl6CxgnqnqEkBJYVuBsgj/277+F7q9KB4xpct/sYvRT9CR/Rvh79hmpJJedH+lA8A6UtqyA21CnECQJzrbKJJgx3eeyN86BQv3g/kOWJ2CE4txEn22U+AjMKmxgB7fmLTNdxKS5+sn9P/Fs+TGwhRSX3pr/l1h4NQpNzb1Rz1fbt80/ODWbLSlBFBmQTCCRkLx54dc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0SKHNd2YJ2mBrc4j7oBOE8GOXiJlH8B5qnKvX99aYIdKxXoNILDBfK/RFaGWIy34uLNVRjOkZcUkKCBVB0D83GIj2EM2YqFs+GuWnRKvW7woAGIN69j7T50NWoIF/TPmdCnCM1HEfxhHfqxK0u5PUKheZeKNXqepoNIEb5ry1QGBho0OAeXQvlYeXiPZfKknu66iJpPEQaIpj0csWThztytn7uDuAiTCPZ4Yhwm+6pYHhxp7Jx/U84L2u3M7BamqD+oiCrFaYpMXkCGHw99hbHhE1okP3q+Hb/TCODKwIG80lw7660Y+nFGMIaCreNeu0Em+dY7rTU+KubyJqeYtt/NssB1Qq945MShkhix+KDKE+ViNmmyRqyUQpTEx6fXgbJQihm7KguDfOJSxvsalaO3vAwwN/mJTSxcRVktIaAYT4ZcakZS5r/mLRVllQmOczO4Ex2zAgflcEZ3GUlG3+TuL6JCYVWI3haAa0wUWffLCYRPo/n2+4vl5v/x9HkTXIZe0p4JCS1nWpzZXsg==;
LtpaToken=EHYGd9YV18oZsd8vSkJGm6EitmZCspgF2RbWMb/kDol6urQ8ZBeespgw8VR0jXPkwKdnAQjJ5x4ZdmTexnZiL3QIVzdH+DwWbTNP4KBAe/cdizYf8/0w05B9N13YX4rT7xl/Y0ZUhZX1brNgM7zP19a4IjL0E0M5uK2qah9ggErQhovcziPkA6Uubd4ne5keV/H/S0ZdaRMSjhXp6njlRtJl6C2U5r91YTXYVnbnl+sgG88g9jnPa6+peg+yi4P9VeoSohydoAIrqBGbpr7yL9ocaO3dL6bq/Ff6WAWZuca1V+7+x4bxtWHQ2CgafibbAkowunOsCyHvCRbv2FH8MQ==;
JSESSIONID=0000QLn5MU6tB5uMM0bXlOC8ZYS:15b4l3mm8;
SITE_ENTRY_JUMPTO=polhome;
scoreboard="";
scoreboardReport="";
WLSESSIONID=0000Xr6ZS67VI4UH-HoycrnVBq1:18lm04lom\r\n
Use the Ordinal (or index) number of the instance of the variable which you need as part of your collection
See training material or online help for correlation functions related to ordinal value
You didn't say what you're actually trying to do. Do you need only use the most recent? only use the first?
You use a web_reg_save_param_ex to capture all Ordinals of a parameter. It puts it into an array.
You can then do what you want with that array.
You can also use a web_reg_save_param_regexp
I coped the code from the official documentation and put your variable name in there to make it easier for you.
web_reg_save_param_ex(
"ParamName=SMIDENTITY",
"LB/IC=SMIDENTITY=",
"RB/IC=;",
"Ordinal=all",
LAST);
web_submit_data("...");
/* Getting individual elements from a parameter array.
Since the parameter created by web_reg_save_param_ex
is called "SMIDENTITY", the number of elements
is saved in parameter "SMIDENTITY_count".
The array elements are parameters "SMIDENTITY_1",
"SMIDENTITY_2", ... "SMIDENTITY_n".
*/
elemCnt = atoi(lr_eval_string("{SMIDENTITY_count}"));
lr_output_message("Number of items found = %d",elemCnt);
for (x=1;x<=elemCnt;x++) {
sprintf(arrayParamName, "{SMIDENTITY_%d}", x);
lr_output_message ("%s: %s",
arrayParamName,
lr_eval_string(arrayParamName));
}
Is there a way to capture and store (or write to a file) the values returned in the Response? (Checkpoint values)
Using HP UFT 11.52
Thanks,
Lynn
I figured it out. In UFT API under Standard Activities, there are File function modules including "Write to File". I added the module to the test, set the path and other properties, passed the variable to the file and it worked! Couldn't be easier.
I mentioned this on my other answer , you can also write it programatically if you have dynamic array response please refer below:
https://stackoverflow.com/a/28012383/3972994
After running a test, in the test folder, you can find a Snapshots/LastIteration directory.
In it you can find the return value for each step saved in a txt file.
Pay attention that if you data drive the step, only the last iteration will be saved to file.
However, in the Test's log (Test dir/Log/vtd_user.log) you can find all the iterations persisted
Thanks,
Yossi
You do not need to use the standard activities if you do this
var iResponse = this.Activity.responsebody;
System.IO.File.WriteLines(#"directorypath&FileName);
the above will write the response to the file and rewrite it for every run
How to use Stanford parser from GATE embedded (using GATE through Java code). I currently use GATE_Developer_7.0 on my machine; i know that there is plugin for Stanford Parser in GATE but don't know how to use it using java code.
Thanks
The usual approach we always recommend for GATE Embedded is to build up your pipeline using GATE Developer, test it out and get it debugged by processing sample documents in the GUI. Once you're happy with the application, use "save application state" or "export for GATECloud.net" to produce a saved state that you can then load in your embedded code using the PersistenceManager. This will automatically ensure that all the necessary plugins are loaded and is generally much simpler and less error-prone than trying to build up your pipeline by hand in your code.
The BatchProcessApp example on the GATE website shows how you can load a saved application with the PersistenceManager, essentially it's
Gate.init(); // always the first thing you do
CorpusController controller = (CorpusController)PersistenceManager
.loadObjectFromFile(new File("/path/to/application.xgapp"));
Corpus corpus = Factory.newCorpus("myCorpus");
controller.setCorpus(corpus);
then for each document you want to process
Document doc = Factory.newDocument(....);
corpus.add(doc);
try {
controller.execute();
// code here to do stuff with the annotated document, e.g. extract
// annotations/features
} finally {
corpus.clear();
Factory.deleteResource(doc);
}
I have set up a soap4r client for a web service, and it's working fairly well. We're using it to send data from one database to another (don't bother asking about that... I know it's not optimal), but we're not entirely sure the mapping is correct, so it's often very handy to get the XML that a particular record would generate.
Of course, that's possible - if you set $DEBUG, soap4r will supply you with a nice dump of the XML going over the wire. You can even set the "device" (file) that you would like to send it to.
However, I'd like to be able to get the XML that it's going to generate without having to actually call the web service.
Is there a way to do this? Grepping around, I've found a variety of obj2soap and similar methods, but none of them seems to be quite the one I want.
An indirect answer: you might want to look at handsoap. It's faster and tries to be more Ruby-like. It uses builder-style XML generation - but you have to generate everything yourself. It's more like a toolbox to write your client in a clean way. This way you know what was generated (and can inspect it easily).
Another option is to set $DEBUG and restore it afterwards:
$REMEMBER_DEBUG_STATE = $DEBUG
$DEBUG = true
# call soap (and have your XML generated)
$DEBUG = $REMEMBER_DEBUG_STATE
This could be extracted to a nice function like this:
def with_debug_output
remember = $DEBUG
$DEBUG = true
yield if block_given?
$DEBUG = remember
end
and then use it:
with_debug_output do
# call soap
end
Is it possible to specify the application name which is used by CWinApp::WriteProfileString()?
If I use CWinApp::SetRegistryKey to set the name of my company to "MyCompany", and I call AfxGetApp()->WriteProfileString in my application called "SomeApp", my string will be stored under the following registry key:
HKEY_CURRENT_USER\Software\MyCompany\SomeApp\...
The problem is that my users want to run multiple versions of SomeApp. So in order that the registry settings don't conflict I want to store them in keys like this:
HKEY_CURRENT_USER\Software\MyCompany\SomeApp 1.1\...
HKEY_CURRENT_USER\Software\MyCompany\SomeApp 2.0\...
etc.
I could replace all instances of WriteProfileString with my own function, but this would be quite difficult as it is used extensively in both our source code and some of the third-party libraries that we use.
Is there some way to force WriteProfileString to use a different string for the application name?
This code in the app constructor worked well:
free((void*)m_pszProfileName);
free((void*)m_pszRegistryKey);
m_pszRegistryKey = _tcsdup(L"nobugz");
m_pszProfileName = _tcsdup(L"myapp\\1.0");