I created an API using SlimeFramework then wrote test to see if results returned from the routes are accurate and also to test side effects of accessing these routes. I am making the client call with guzzle.
I am required to use continuous integration to send the information to travisCI, but travis does not have a host on which I can test my API, and guzzle requires a client(url) from which to make the route calls.
I am new to using any form of continuous integration and do not know what to do. I need help.
How do I test my API on travis?
Related
How to set up rest server and client.
I read the tutorial https://code.tutsplus.com/tutorials/working-with-restful-services-in-codeigniter--net-8814.
I got idea about restfull services , and rest server work fine , but rest client not.
My problem is I dont get the idea about rest client spark , And the given link CodeIgniter Curl library: http://getsparks.org/packages/curl/show was down , So cant get this.
How do I get this ?
The client mentioned in the post is merely for testing purposes. It is not part of the REST server.
What you need to set up in your code is the REST server library, method of authentication, database tables (if using any), and the controllers that will map your endpoints.
The client concept represents any device/application that will be consuming from or sending data to your REST service through the HTTP methods.
You could be using postman for your testing. It is free and open-source, and very intuitive to use.
I am working on an API authentication project. Authentication is achieved by adding a client certificate to the https request to the api. Everything works great when I curl to my api using my client certificate and Lumen actually made it trivial to do.
What is not so trivial is unit testing this.
Does anyone know how to make an HTTPS connection in a unit test?
The callSecure method seems to have disappeared since the last version of lumen.
Assuming the HTTPS connection is made - does anyone know how to easily set the certificate. I was hoping I could just get the unit test framework to set up the correct $_SERVER superglobal values so I could use a data provider to send several different certificate errors.
I'd also like to mock the models the controller is injected with so I provide known data in my data providers without having to do any database manipulation.
What I do not want to do is write some methods to make an entire curl request using real certificates.
So - apparently this can not be done as simply as I wanted. In order to test the unit of code in question I have had to add a "getter" to return a copy of the $_SERVER array. In my unit test I then mock the controller object and override the getter to return data I can control. Then rather than using the call method in the test I just directly call the method I am testing.
It has added complexity in terms of having to do more development within the production code just so I can have some tests - however that additional development time will be well worth it in the future.
I created a API and would like to test it. My initial thoughts was to use an API client, which I did, I used guzzlehttp, but after deploying the app to heroku and using travis and coveralls to build my test, it turns out coveralls is not able to see the part of my code covered by the test.
So my question is really "How do I test my REST API without an API Client?"
below is the link to my Github showing 0% as my test coverage
I'm an experienced data analist with mostly SQL and R experience, little Python, and unfortunately little .NET and PHP exposure. I have searched extensively for anyone with a similar questions, but unfortunately I haven't found what I'm looking for.
Situation: I'm setting up an HDInsight cluster on Azure (with Apache Spark) and I need to pull in some data from a SOAP API (no restful API).
Problem: Where and how do I pull this data in? I thought the Logic App in Azure would be a suitable place. However, I don't quite succeed in calling on this API.
I do have a working PHP script with a proper API call. Here is a (part of) the syntax.
$client = new SoapClient('http://someURL?wsdl');
$webservice = new SoapClient('http://someotherURL?wsdl');
$session = $client->someOperationToLogin($var1, $var2, $var3);
$operation = $webservice->someOperationToGetData($session, $var4, $var5);
$session = $client->logout($session);
As you can see, I first need to obtain a session id and then use this session id in subsequent calls. As far as I understand, I can't get to this data through a simple HTTP request.
Questions:
Can I call this particular SOAP API directly through one of the existing connectors in the Azure Logic App
If (1) is not possible, can I make use of the existing PHP script? How and where?
Is there any other route I can follow to make use of the data through this SOAP API? For instance: using pyspark in the Spark/HDInsight Cluster?
I really appreciate your help and pointers.
You Can Make The Call Through The Normal HTTP Connector.
1- First Set Your Http trigger method to post and send it your xml Body.
HTTP Trigger
2- Make An Http Action with the url to Your Soap End like
abc.asmx
xyz.svc Http Call To Soap End
Don`t forget to set the Method To Post and Content-Type to text/xml as a header.
3- Finally Bind your Http Response to response action set the status code and body To the HTTP Action Status and Body Dynamically don`t forget to set to content type Here to text/xml as well Return Response Action
4- Finally Configure the run After for response component to sun after HttP Action Even If Faild , Cancled or time out Just to pass the Status code for every call Like That Right click on Response and configure run after conf Run After For response Action .
Here is The Full View Full Flow.
Like The Response If This helps.
There are no SOAP APIs called thru the existing connectors in Azure Logic App.
This is a list of Connectors and API Apps Reference: https://msdn.microsoft.com/en-us/library/azure/dn948518.aspx.
Their supported functions are all based on REST APIs via Http/Https.
All services & apis on Azure are almost based on REST APIs to compatible with crossover platform & language scenes.
But even so, you can create own SOAP APIs thru Azure App Service or Cloud Service.Please refer to http://azure.microsoft.com/en-us/documentation/services/app-service/api/ and https://azure.microsoft.com/en-us/documentation/articles/app-service-logic-arm-with-api-app-provision/.
In Azure HDInsight, you can pull in some data from Storage Service and Service Bus. If you want to use Azure Logic App, the exisiting connectors are Blob Connector and ServiceBus Connector, and even Dropbox Connector.
You can refer to the references below to use PHP script to access the Azure Storage & ServiceBus services linked as HDInsight resources to store/get or send/receive some data.
1.https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-blobs/
2.https://azure.microsoft.com/en-us/documentation/articles/service-bus-php-how-to-use-queues/.
Best Regards.
It is now possible to create a REST API from a SOAP WSDL file through Azure API Management using the SOAP to Rest feature.
This can be accessed from:
Azure portal -> API Management services -> <Your API Management Service> -> APIs -> Add API -> WSDL
After this is set up, it is easy to access this API from other Azure products.
I have written Integration tests for an application built in CodeIgniter 2.x. The tests are a Selenium + PhpUnit combination.
So far, I have used test accounts of Stripe and Amazon within the application and obviously the tests use the same accounts. I was wondering how would i go about creating Mock objects for these APIs so that i can avoid live data creation/deletion.
For Stripe, i could not find any mocking library for PHP. So stubbing the responses and requests does seem to be a good option. But again, even if i use stubs in my tests in place of real data, the application during that certain integration test will still be needing correct information for it to pass.How do i tell the application to use fake data?
Also, i would like to know if it is generally a good idea to mock objects in integration tests i.e. within the context of web applications?
This is a tool that Stripe themselves have developed for mocking Stripe.
https://github.com/stripe/stripe-mock
It runs a server on your local machine that responds to API calls in s Stripe-like fashion. This would be something you could try for acceptance tests
For PHP Unit tests, you'd be better using something like AspectMock - although config is a bit tricky. You can specify in advance what a call to a Stripe resource (e.g. \Stripe\Stripe::setApiKey, or \Stripe\Customer::retrieve) is supposed to return without hitting the Stripe servers - and you can also test whether or not your application code tried to make these calls. You can also simulate failures to test that your application behaves properly if, say, Stripe is down.