How do you change the HTTP verb for DalekJS tests? - functional-testing

The DalekJS documentation for the open() action says "You can forge GET, POST, PUT, DELETE and HEAD requests".
Can anyone tell me how to do this? I need to send POST, PUT & DELETE requests to the server for some tests.

per definition the Webdriver Spec & the underlying JSON-Wire protocol do not support manipulation the HEADERS of a request.
That seems like a limitation, but makes sense if you think about what the protocol is designed for. It is designed to "simulate" a "real" user. What a real user normally doesn't do, is changing the HEADERS of its request.
There are other tools if you want to test a REST interface, Dalek isn't (becauseof the underlying protocol) not designed to test such things.

Related

Should a Get-Ajax request change data on the server?

I read documents online. They say that
A GET-Ajax request is used for getting data from the server.
A POST-Ajax request is used for change data on the server.
But why is it?
A Get-Ajax request can change the data on the server TOO, right?
Why should only the POST-Ajax request change the data?
Is it because of a security reason or something? Please explain to me
GET and POST are different methods for web requests that provide different features/describe different intentions for programmers and APIs. You are correct that, technically speaking, if you want to do some other CRUD operation on the server when using a GET request, you can. Most would probably argue that this is not a good idea, in part for security/performance features that either method provides. Example: GET requests can be cached, POST cannot.
More on that here: https://www.w3schools.com/tags/ref_httpmethods.asp

Is a response and status code required even when the client side doesn't care about the response?

I'm trying to design an endpoint that just does some loggings for the client-side applications. The implementation is simple, just log the events that the client send to some platforms. (We don't want the mobile app to integrate with the platforms directly) If the client doesn't care about the response and won't handle the response either, is there a need for the server to send back the 200 all the time? Or is it okay to just return nothing?
I can't seem to find any similar use cases. Maybe giving a status code is always a good practice?
I'm using sprint boot and the controller allows the return type of void.
If this is your product and you're not beholden to any other API expectations or other miscellaneous requirements, you can implement whatever behavior you'd like.
That said I can understand wanting to stick to best practices. In general if the response is going to be empty, a simple HTTP status code of 204 is typically the best option to conform to standard HTTP status codes.

Are there some Ajax JSON testing and debugging web services/APIs?

I'm debugging some tricky Ajax code without a server side, in fact I have no domain etc to even put any server-side code on.
I would like to find some very minimal Ajax JSON(P) testing or debugging webservice or web API that just sends something back. Something like a ping or noop or ack.
I would prefer something small, fast, and reliable, preferably provided by major Internet companies such as Google, Microsoft, or Yahoo.
Ideally it would support these features, though none are totally essential:
Support JSONP.
Parametrically return success or various kinds of failure.
Parametrically delay a specified time before responding.
Parametrically support or reject CORS requests.
Parametric control over HTTP headers.
Parametrically describe the object returned.
In fact the most basic form of such a service from a major provider would also be useful for determining that Internet access is available, at least to a degree beyond navigator.onLine.
jsFiddle actually supports some of the features I'm looking for with their “Echo Javascript file and XHR requests”.
To improve user experience “echo” features has been created. This allows to test XHR requests, add javascript files, create workers - all from one fiddle, so it is more transparent for the user reading the code. XHR requests are split to HTML, JSON, JSONP and XML. Gist and github responses are similar to the echo feature and go nicely in pair with storing fiddles in gist and github.
They're not really intended for use outside jsFiddle though. Some limitations:
HTTP POST must be used for everything except JSONP and JavaScript.
CORS is not supported.
Of the desired features I listed, it supports at least:
specifying a delay
describing an object to return

How to create a WCF reply service for AJAX unit testing

I want to create a WCF service that will simply reply back the query string, HTTP headers, and the HTTP verb used in a request it received.
I want to use it to unittest a AJAX enabled JavaScript framework I am building so I can verify that the HTTP headers and HTTP verbs are being set correctly.
Basically I need a way to make the WCF service bind to HTTP GET, POST, PUT, and DELETE, and I need a way to grab all the headers etc. and return them.
Any input is much appreciated, Egil.
Not sure that it is possible to do exactly what you want to do. But you could come close using REST with WCF, see http://msdn.microsoft.com/en-us/netframework/cc950529.aspx
It turns out a HTTP handler was an easier way to go than a WCF service. I posted my solution over at my blog: Simple Ping/Reply Service for Unit Testing AJAX/XHR requests. I hope this helps others as well.

Modifying HTTP request and responses with a Browser Helper Object

I want to modify HTTP requests headers using an Internet Explorer Browser Helper Object.
I basically need to change a few headers for every request, and then modify the response before it returns to the browser.
I tried using the OnNavigate2 events, but those don't even give you access to all of the headers.
I tried making an Asynchronous Pluggable Protocol, but then I don't really have access to the default HTTP implementation, and i can't override the default HTTP requests.
Do you have any idea how this is supposed to be done?
I prefer C#, but could use C++ if necessary.
It can be done with URL monikers.
There is an implementation of something like that by a guy called Igor Tandetik.
You can find links to the code in: microsoft.public.inetsdk.programming google group - just look for PassthruAPP.
(I would have posted a link but apparently new users are not allowed to do this)
It doesn't directly support modifying the response body though.
You will have to insert a hook into the IInternetProtocolImpl::Read method.
The easiest way to do it is to use an http proxy to intercept everything the way Fiddler does.
See this description of the Fiddler PowerToy (Part 1).
It seems that you can only modify CUSTOM headers by using the headers parameters of the BeforeNavigate2 event. Not all the headers are accessible. This is a way to try to minimize the potential of the BHOs to act as a Trojans. Use a HTTP proxy instead.

Resources