HSQLDB connection URL: user and pwd properties - hsqldb

Chapter 12 of the HSQLDB docs says: "The properties user and password are always required." but AFAICT does not specify the syntax for supplying them as part of the URL.

An example using the URL is below:
jdbc:hsqldb:hsql://localhost/enrollments;user=user500240;password=nothing
If you are using a java.util.Properties object with the DriverManager.getConnection (String url, Properties info) call, then you should set the properties with the calls below before calling the getConnection method:
info.setProperty("user", "user500240");
info.setProperty("password", "nothing");
Update: Links to Javadoc and the Guide:
http://hsqldb.org/doc/2.0/apidocs/org.hsqldb/org/hsqldb/jdbc/JDBCConnection
http://hsqldb.org/doc/guide/dbproperties-chapt.html#dpc_connection_url

Related

Adding Json data in a variable in ROBOT framework

I am starting to work on automating API requests using ROBOT framework and came across the below issue.
I have this JSON data
{
"password": "123456789",
"username": "test#test.com"
}
I want to put the above in a variable and generate a token as a response.
Previously I had used the below
${body}= create dictionary username=test#test.com password=123456789
I got the below error response
HTTPError: 415 Client Error: Unsupported Media Type for url:
Can someone help me on this please.
Updated Code
*** Settings ***
Library String
Library Collections
Library RequestsLibrary
*** Variables ***
Credentials
${prod_url} localhost:3000/api
*** Test Cases ***
User login and token generation.
Create Session demo ${prod_url}
${body}= create dictionary username=test#test.com password=123456789
${header}= create dictionary Content-Type=application/json
${login}= post on session demo /login data=${body} headers=${header}
log to console ${login.content}
Above is full code. What I need is the username and password needs to be in JSON format because My API is accepting only those values..
Instead of the data argument, try passing the dictionary to the json one:
${login}= post on session demo /login json=${body}
headers=${header}
When you use the data, the library passes as-is the string representation of the object - and in python a str of a dict is {'password': '123456789' ,... - e.g. it uses single quotes, not double ones, which is an invalid json.
Passing the dict to the other argument, json, will make it convert to the proper format.

Using Variables in Basic Authentication in an API Katalon-Studio

I have been trying to use variables for the Username and Password in the katalon-studio API, basic authentication using the following syntax:
Syntax:
GlobalVariable syntax:
However none of them are working.
please advise.
This answer might came a little bit too late, but maybe someone will find this in the future...
What the authorization tab does (and what basic authorizaton means - as mentioned in it's documentation ) is encoding the string of "${username}:${password}" by Base64.
What I did was mimic the "Update to header" button of the Authorization tab by first encoding the said string:
String basicAuthToken = "${username}:${password}".bytes.encodeBase64().toString()
Assuming authToken is a variable of the request with the type of String
Then just skip the Authorization tab and put this value straight into the header:
Name: Authorization Value: Basic ${authToken}
And now just pass the basicAuthToken as a parameter to the Webservice Request the same way you would any other variable:
WS.sendRequest(findTestObject('id_of_your_WSR_object', [('authToken'):basicAuthToken, ...any other variables]))

How to store variable in property in jmeter using beanshell post processor and refrence that variable in next request.

I am hitting an http url and need url contents into property in jmeter.
I have done the fetching part from url,but unable to store the value in properties using the jmeter.
For e.g.
Request is like
http://url/user=admin,password=admin
I need property in jmeters
property1(user)=admin
property(password)=admin
Given you have already extracted what you need it might be easier to use __setProperty() function like:
${__setProperty(foo,bar,)}
creates "foo" property with the value of "bar"
If you still want to go the "Beanshell" way, you can use props shorthand which provides read-write access to JMeter Properties (in fact it's instance of java.util.Properties) for properties manipulation.
The Beanshell script:
props.put("foo", "bar");
will create a property "foo" having value of "bar".
Returning to your use case, if your URL looks like http://example.com/?user=admin&password=admin use the following Beanshell code:
Map parameters = ctx.getCurrentSampler().getArguments().getArgumentsAsMap();
String user = parameters.get("user");
String password = parameters.get("password");
props.put("user", user);
props.put("password", password);
should do what you need. See How to Use BeanShell: JMeter's Favorite Built-in Component guide for more information on Beanshell scripting in JMeter.

ODataService Type Provider error: (401) Unauthorized

The type provider
'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders'
reported an error: Error reading schema. The remote server returned an
error: (401) Unauthorized.
Is there a way to use the OData type provider with an OData service which requires a username and password?
Static type parameters for the type provider:
ServiceUri : string The URI string for the OData service.
LocalSchemaFile : string The path to a file that contains the schema. This file is written by the type provider.
ForceUpdate : bool Requires that the direct connection to the service is available at design/compile time and the local service
file is refreshed. The default value is true. When ForceUpdate is
false, the provider reacts to changes in the LocalSchemaFile.
ResolutionFolder : string A folder to be used to resolve relative file paths at compile time. The default value is the folder that
contains the project or script.
DataServiceCollection : bool Generates collections derived from DataServiceCollection. The default value is false.
Yes, but unfortunately it's not quite as slick, and you don't get compile-time validation, which is one of the nice benefits of type providers.
You need to grab the $metadata from your service and save it locally as a .csdl file, then use the LocalSchemaFile static parameter in your code. You can then set credentials on the data context object in order to authenticate at runtime.
// download http://services.odata.org/Northwind/Northwind.svc/$metadata to local file Metadata.csdl
type Northwind = ODataService<"http://services.odata.org/Northwind/Northwind.svc/",
LocalSchemaFile="Metadata.csdl",
ForceUpdate=false>
let db = Northwind.GetDataContext()
db.Credentials <- System.Net.CredentialCache.DefaultCredentials // or whatever creds you need
// go party

Struts ActionMessage

Hi I have a struts 1.X app, and in order to show errors detected in an action class, I use:
errors.add("Error Global", new ActionMessage("some_string_in_properties_file"));
Which works just fine.
My problem is that now the string I need to send to the jsp page as error has a session variable in it (like "You have 3 more valid attempts", being 3 the session variable).
How can I accomplish this ?
Thanks.
Try to use ActionMessage constructor of 2 arguments. According to JavaDoc:
public ActionMessage(java.lang.String key,
java.lang.Object value0)
Construct an action message with the specified replacement values.
Parameters:
key - Message key for this message
value0 - First replacement value
In your case:
errors.add("Error Global", new ActionMessage("some_string_in_properties_file", sessionVariable));
some_string_in_properties_file should look like this:
some_string_in_properties_file=You have {0} more valid attempt(s)