How to dbms_output.put_line the UTL_HTTP.req object? - web-services

I have a scenario where PLSQL package UTL_HTTP API is being used to make Webservice calls to Global Payment Gateway API (GPI Atlanta). The goal is certify against their newly upgraded API.
It goes well on other operations until we hit a particular operation which used to work fine until Global decided to upgrade their back end. Since then we are getting 'Invalid Login Attempt' response for that operation.
I am looking for the Request payload to get an idea what is going on.
How to print UTL_HTTP.req?

Can you give more details? Are you invoking utl_http.get_response and it's returning "Invalid Login Attempt"?
UTL_HTTP.req specs:
TYPE req IS RECORD (
url VARCHAR2(32767 byte), -- Requested URL
method VARCHAR2(64), -- Requested method
http_version VARCHAR2(64), -- Requested HTTP version
private_hndl PLS_INTEGER -- For internal use only
);

Related

Receive Callback request inside Postman automated test

I am trying to write automated tests with Postman. I am new to postman automation world so sorry if the question will seem dumb.
In the api that I need to test when I send a request I immediately receive a response with a transactionID, no matter transaction succeeded or not. Along with my request I send a CallbackURL to the server where I expect the actual transaction result to be called back. The server will do a PUT request back to the CallbackURL that I have provided with the transactionID and the actual response or error.
So the question is, can I have such kind of scenarios in my postman tests?
I guess I should run a web server and expose an endpoint which will expect a PUT request and I should get the body of this PUT request in my tests to check it, and respond back to it with success.
In other words, within my script I need to perform the following actions:
Do a request to the server passing a callback URL
check the immediate response from the server and keep the returned transactionID
Have a webserver run with an endpoint that I passed as a callback URL
Expect a request to that endpoint with transactionID and actual response
Check that the response is what I actually expected
Respond to the request with success
I was thinking about Postman Mock server, but seems it is not designed for such usage.
I also think may be I can run some JS Webserver (may be nodeJS) inside the postman Sandbox...
Actually I am very new to postman testing and I am really confused about this kind of issue. Is it even possible to do this with postman or I need something else?
There are some features provided by POSTMAN which can help you to resolve your problem
When you do request to server passing callback URL it gives you transactionID in response. Save that transactionID in environment variable or global variable. Same you can do it for callbackURL.
Eg. pm.environment.set("transactionID", transactionID);
Then you can do the second request where you passed callback URL and transactionID which you have already.
In short in POSTMAN there are features like
Set global and environment variable which helps to pass some values fetched from response to another request.
call other request on success of first request
eg. postman.setnextRequest({{requestname}});
If you can mentioned your problem statement little bit in details it will be easy to answer in better way.
Hope This Will Help You

Creating asset on Bigchaindb server using http call

I have created an account on bigchaindb site. Now I want to post some data to online server using http call by postman. I got it that I need to mention api_key and app_id in header. What I need to keep in body and what other parameters should be passed ?
I'm not sure what all you need to tell Postman, but here's a start:
method = POST
URL = https://test.bigchainb.com/api/v1/transactions?mode=commit
Headers
app_id: value
app_key: value
Content-Type: application/json
Body
The final, signed (fulfilled) transaction goes in the body, but I'm not sure what format Postman expects it in. Maybe a Unicode JSON string?
To construct a valid signed transaction, you should probably use one of the BigchainDB drivers, and if you're doing that, then why not also use the same driver to POST the transaction to the BigchainDB Testnet? Here's a list of drivers:
http://docs.bigchaindb.com/projects/server/en/master/drivers-clients/index.html

WSO2 - simple endpoint fails

I am trying to setup a simple API test against a local endpoint. I have create the sample API (phone number lookup) and that works fine.
http://192.168.1.11:8080/api/simpleTest is my endpoint and the WSO2 service also runs on 192.168.1.11 ... but when I test it in 'publisher', it always fails. This is a simple GET with no parameters.
I can run it from a browser or CURL (outside of WSO2) and it works fine.
Thanks.
I assume you talk about clicking the Test button when providing Backend Endpoint in API publisher.
The way that Test button works at the moment (as far as I understand) is that it invokes HTTP HEAD method on the endpoint provided (because according to RFC 2616, "This method is often used for testing hypertext links for validity, accessibility, and recent modification.")
Then it checks response. If response is valid or 405 (method not allowed), then the URL is marked as Valid.
Thus sometimes, if backend is not properly following RFC, you might get otherwise working URLs declared as Invalid during the test because of that improper HEAD response evaluation. Obviously, this is just a check for your convenience and you can ignore the check if you know the endpoint works for the methods and resources you need it to work.
P.S. Checked it on API Cloud but behavior is identical to downloadable API Manager.

How to access the HttpServletResponse from a custom CAS AuthenticationHandler to generate a cookie? in

I have a CAS 3.5.2 and a welcome web application installed in my JBOSS 4.
I have written a custom AuthenticationHandler by implementing the interface:
org.jasig.cas.authentication.handler.AuthenticationHandler.
My AuthenticationHandler authenticates correctly but in case the authentication is correct I would like to generate a cookie with the response.addCookie method. So I would need have access to the HttpServletResponse. The problem is that the only information I'm receiving in the authenticate method is the [Credentials credentials] parameter.
How could I do it?
Indeed, the authentication handler is only given credentials as input parameter. Though, you can use the ExternalContextHolder object (from the SpringWebflow) to get a ServletExternalContext from which you will get the HttpServletRequest...
Finally I found 2 solutions.
At first, I added a filter in the web xml that put the response in the ThreadLocal and it was retrieved from the AuthenticationHandler.
One day, looking for another thing I found a easier way:
HttpServletResponse res=WebUtils.getHttpServletResponse(RequestContextHolder.getRequestContext());
I hope it is useful to someone else.

Using Request, HttpNtlmAuth to make a system call with authentication

I've got the following snip of code the has the audacity to tell me it is "FAIL to load undefnied" (the nerve...) I'm trying to pass my authenticated session to a system call that uses javascript.
import requests
from requests_ntlm import HttpNtlmAuth
from subprocess import call
# THIS WORKS - 200 returned
s = requests.Session()
r = s.get("http://example.com",auth=HttpNtlmAuth('domain\MyUserName','password'))
call(["phantomjs", "yslow.js", r.url])
The issue is when "calL" gets called - all I get is the following
FAIL to load undefined.
Im guessing that just passing the correct authenticated session should work - but the question is how do I do it such that I can extract the info I want. Out of all the other attempts this has been the most fruitful. Please help - thanks!
There seem to be couple things going on here so I'll address them one-by-one.
The subprocess module in python is meant to be used to call out to the system as if you were using the command line. It knows nothing of "authenticated session"s and the command line (or shell) has no knowledge of how to use a python object, like a session, to work with phantomjs.
phantomjs has python bindings since version 1.8 so I would expect this might be made easier by using them. I have not used them, however, so I can not tell you with certainty that they will be helpful.
I looked at yslow's website and there appears to be no way to pass it the content that you are downloading with requests. Even then, the content would not have everything (for example: any externally hosted javascript that would be loaded by selenium/phantomjs or a browser, is not loaded by requests)
yslow seems as though it normally just downloads the URL for you and performs its analysis. When the website is behind NTLM, however, it first sends the client a 401 response which should indicate to the client that it must authenticate. Further, information is sent to the client that tells it how to authenticate and provides it parameters to use when authenticating for NTLM. This is how requests_ntlm works with requests. The first request is made and generates a 401 response, then the authentication handler generates the proper header(s) and re-sends the request which is why you see the 200 response bound to r.
yslow accepts a JSON representation of the headers you want to send so you can try to use the headers found in r.request.headers but I doubt they will work.
In short, this is not a question that the people who normally follow the requests tag can help you with. And looking at the documentation for yslow it seems that it (technically) does not support authentication of any type. yslow developers might argue though that it supports Basic Authentication because it allows you to specify headers.