Dynatrace synthetic monitoring- JS function import and invoke - monitoring

We have a requirement to use cyptojs to encrypt and decrypt password. We are using Httpmonitor to perform synthetic transactions in Dynatrace to monitor API endpoints
Please advise how to import js in Http Monitor Request so that we can use this function to encrypt the request payload and decrypt response payload.
Any example or pointers would be an great help

Related

In Karate framework, How to retrieve APIGEE token generated out of SHA256 encrypted libraries?

In my current application under test using Karate framework, I came across TWO APIs - Token and Extended, which provides the APIGEE token value to access backend services.
API-1: Token API
Input payload (form-data) -
grant-type: authorization_code
code: *8-digit-characters*
redirect_uri: https://../oauth-code-callback
code-verifier:*28-digit-characters*
client_id: *Unique-Client-Key*
Response -
{"access-token":"..."}
API-2: Extended API
Input payload (JSON) -
{"access-token":"..."}
Response -
"APIGEE_Token"
Looking at the input payload in API-1, code and code-verifier are SHA-256 encrypted values generated using typescript. Now, in order to generate the final APIGEE token, I need to generate code and code-verifier values using the same typescript libraries in Karate. Is there any possibility as such? Else, please suggest if there is any alternative approach for my requirement. Thanks in advance!
First, I suggest you check if the tokens can be generated using some standard algorithm, in that case you can re-write them in Java or JS. Examples here: https://stackoverflow.com/search?q=%5Bkarate%5D+jwt
Else here are 2 extra creative solutions:
Karate uses the Graal JS engine, so if you can get the pure-JS equivalent of the routine you need, it may be possible to load it into Karate by reading the .js file. For example read() (or karate.read()) can return a JS function, which you can then invoke within your test flow.
If you have node / npm installed, you can write a command-line program that takes command-line args and returns the data you need. Note that you can even return JSON and use karate.fromString() to parse it. Karate happens to have very good support for OS command-line execution, refer: https://stackoverflow.com/a/62911366/143475 and a similar idea is described here: https://stackoverflow.com/a/51150286/143475
Finally, it may well be worth it to ask your dev-team to stand-up a small REST service that returns these tokens for you in your pre-prod environment. And the moment you have a REST option, guess what Karate is really good at :) The REST is up to you.

How do I create a channel and server token using AgoraRtcEngineKit in Swift?

I am following the Agora.io channel management guide for joining a channel using AgoraRtcEngineKit for iOS. It states that I should call createRtcChannel of the AgoraRtcEngineKit class to create an AgoraRtcChannel object with a channel ID. However, AgoraRtcEngineKit does not have a createRtcChannel method in Swift. The alternative is that I use Obj-C code, but this seems a little hacky.
Second, following the token generation reference, I need to generate a server token using RtcTokenBuilder. It states "your token needs to be generated on your own server, hence you are required to first deploy a token generator on the server." Ideally, I would be able to generate a token in Swift, but the only available languages for the source code is C++, Java, Python, PHP, Node.js, Go, Ruby. I assume I can do this with JavaScriptCore, but, like with the channel generation, this doesn't seem like an optimal solution.
Per the documentation:
After a token (or a temporary token) is generated, the client should
use the token to join a channel within 24 hours. Otherwise, you need
to generate a new token (or temporary token).
A token (or a temporary token) expires after a certain period of
time. When the SDK notifies the client that the token is about to
expire or has expired by the onTokenPrivilegeWillExpire or
onTokenExpired callbacks, you need to generate a new token and call
the renewToken method.
The token encoding uses the standard HMAC/SHA1 approach and the
libraries are available on common server-side development platforms,
such as Node.js, Java, PHP, Python, and C++.
What is the standard way to generate a channel and token to join channel using AgoraRtcEngineKit in iOS Swift via Agora.io?
Thanks in advance!
I ultimately figured it out following this guide on deploying a Dynamic Key Server. You need to simply deploy a Heroku Dynamic Key server, which is in the TokenServer-nodeJS. Go to this deployment link and input your respective Agora.io APP_ID and APP_CERTIFICATE. Once the token server is deployed, we can use an HTTP get request to get the token as a response in JSON format which you can then parse with a framework like SwiftyJSON. Namely, once the server is running you replace below with your instance url and generate tokens using this endpoint:
https://<heroku url>/access_token?channel=test&uid=1234
Using this instance url example:
let request = AF.request("https://matchr-token.herokuapp.com/access_token?channel=test&uid=1234")
request.responseJSON { (response) in
guard let tokenDict = response.value as! [String : Any]? else { return }
let token = tokenDict["token"] as! String
// use the generated token here
}
There are two parameters in this instance url, i.e. the channel and uid, which can be set as needed to generate a unique token.

Pass CALLER_ID to a URL once getting Call on Avaya

Whenever we get a call on Avaya, I need Avaya or 3rd party App to call a URL / API and pass the CALLER_ID AND EXT_ID to that API. e.g,
myCRM.com/{CALLER_ID}/{EXT_ID}
myCRM.com/01132899470/777
You did not reveal too much detail about your setup.
If you have AES server then you can write a TSAPI/JTAPI/DMCC client application that can monitor the stations/VDNs and call the URL with relevant parameters wherever it is appropriate for you (DELIVERED, ESTABLISHED events).
You can read about AES if you are not familiar with it:
https://www.devconnectprogram.com/site/global/products_resources/avaya_aura_application_enablement_services/overview/index.gsp
Here you can read about the interfaces AES provide:
https://www.devconnectprogram.com/site/global/products_resources/avaya_aura_application_enablement_services/interfaces/index.gsp

(Rails app Api) Send data via HTTP and receive JSON or XML

I'm building a simple calculator for courier company. This calculator should receive some data via http request: weight, origin city and destination city. Then calculator should send back JSON or XML: price.
Sounds very simple, but I can't find any usable information how to handle with http request.
As I understand the request should be something like this:
localhost?weight=20&origin="Almaty"&destination="Moscow"
But I have no idea how to handle it with Rails. How to obtain these variables in HTTP?
You have to use sockets so the client get make a http request, you receive it on your socket, compute it and send him back the result.
Documentation for url attributes parser: http://www.ruby-doc.org/stdlib-2.0/libdoc/cgi/rdoc/CGI.html#M000075
this might help edit:
require 'cgi'
CGI::parse('param1=value1&param2=value2&param3=value3')
returns you sth like that:
{"param1"=>["value1"], "param2"=>["value2"]}

Progress feedback in stateless HTTP session

I need to program a stateless server to execute remote methods. The client uses REST with a JSON parameter to pass the method name and its parameters. After servicing the result the session is closed. I have to use Indy10, TCP/IP as protocol, and therefore look at using IdHTTPServer.
Large result sets are chunked by Indy10 and sent to the client in parts.
My problem now is:
The methods on the server provide progress information if they take longer to produce the results. These are short messages. How can I write back to the client?
So far I have used writeflush on the server, but the client waited for the request to end before handing back the full resultset, including the progress information. What can I do to display/process such progress information on the client and yet keep the connection open to receive further data on the same request?
On the client side instead of the regular HTTP client component TIdHTTP you can instead use Indy class TIdTCPClientCustom in unit IdTCPClient to send the request and process the response.
This class gives total control over the processing of the server responses. I used the TIdTelnet class as a starting point to implement a client for a message broker messaging protocol, and found it stable and reliable for both text and binary data.
In the receiving thread, the incoming data can be read up to delimiters and parsed into chunks (for the progress information) and immediately processed.

Resources