In cucumber feature file, am trying to send username and password. password is a mix of specialcharacters, digits and alphabet like
"Password#2"
. I tried escaping with slashes like
"Password/#2", "Password\#2" , "Password/#/2"
and double slashes as well but not successful. How can we pass such special characters in cucumber feature file.
Thanks in Advance.
Related
Very Similar problem to AADSTS50012: Invalid client secret is provided when moving from a Test App to Production
The top answer says to Encode your secret e.g. replace + by %2B and = by %3D, etc how would I replace the special character Tilde ~
As Suggested by juunas, and as per the document yes, you can replace the special character.
URL encoding converts characters into a format that can be transmitted over the Internet.
Here is the link for complete information regarding Encoding Techniques.
I need to convert a protobuf message to JSON string in java. For this I am using the below API as recommended by the docs (https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/util/JsonFormat.Printer.html)
String jsonString = JsonFormat.printer().includingDefaultValueFields().print(protobufMessage);
This is working fine for a simple string, however, when my string contains special characters like &, single quote etc. the gson.toJson() method inside JsonFormat is converting special characters to octal format. For example "A&BC" is converted to "A\u0026BC". Also, the resultant string has an extra backslash appended.
So finally "A&BC" is converted to the string "A\\u0026BC".
If it were "A\u0026BC" then I could have converted to a byte array and formed a string with it. But because of the additional backslash I am not able to do so.
Currently I am using protobuf version 3.7.1 and I tried to upgrade and check if any latest API is available, but it did not help. I searched online but did not find any references (a similar issue was reported for JSONFormat.printToString but this API is removed in a later version. https://github.com/carlomedas/protobuf-java-format/issues/16). Can someone please help here if you have come across this issue.
I think the problem might be that you're using that string to pass along, and it's getting parsed a 2nd time. If you use the printer, it will convert "A&BC" to "A\u0026BC". Then when Jackson parses that, it will append the 2nd backslash. To avoid this, you can use #JsonRawValue annotation to avoid being parsed with the 2nd backslash.
I have used following step def for capture error message from given pop up modal
Then warning "Invalid file. File name should be "Users.xml" " should be given to user
In this case I want to include "User.xml" inside the given string
#Then("^warning \"([^\"]*)\" should be given to user
But this will not escaping the ". How do I escape this " character for matching the exact string
You need to change
#Then("^warning \"([^\"]*)\" should be given to user
to
#Then("^warning \"(.*?)\" should be given to user$"
[^"]* is matching everything except quotes
.*? will match everything (including quotes )
For more information See here
You can also use multiline string to do that as explained in above link
Also see this video tutorial for including strings in your arguments
I have the issue that the Ids that are being generated based on certain input contain the character "/". This leads to an error during the Upsert operation as "/" is not allowed in the Document id.
Which characters are not allowed beside that?
What are ways to handle such a situation?
The illegal characters are /, \\, ?, # (see https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.documents.resource.id?view=azure-dotnet)
Ways to deal with such a situation:
Remove the character already in the input used for generating the id
Replace the character in the id with another character / set of characters
Use Hashing / Encoding (e.g. Base64)
If you know a better way please share. Thanks
I'm base64 encoding the plaintext. Then replacing the '/' and '=' that can still be there from base64 with '-' and '_' respectively. This seems to be working well. I ran into other issues when I just tried UrlEncode the value.
Psuedo:
var encoded = String.ConvertToBase64(plainTextId);
var preppedId = encoded.Replace('/','-').Replace('=','_');
I have an API which it's URL requires a string with spaces --> A B C
I have tried
String X = "A B C";
vars.put("myKey",X);
GET https://myserver.com/Api/v1.0/config/${myKey}
When JMeter executes this it replaces spaces with %20 in url. I do not want JMeter to repalces spaces with %20, how can I do that
GET https://myserver.com/Api/v1.0/config/A%20B%20C
You can't send space in URL:
A URL must not contain a literal space. It must either be encoded using the percent-encoding or a different encoding that uses URL-safe characters (like application/x-www-form-urlencoded that uses + instead of %20 for spaces).
But you can use + instead of space
And notice that server/receiving end will decode it back to spaces so there isn't a real issue.
Usually browser replaces spaces entered into the address bar with %20. So do JMeter.
You have to update your API, so URL param with %20 should be interpreted as a string with a space(s) by your API.