Acording to sails.js docs, it is only needed to use req.cookie('name', 'value') in order to make it work, however I can't make it work.
error: Sending 500 ("Server Error") response:
TypeError: res.cookie is not a function
at Object.login [as acounts/login] (/home/emirc/Escritorio/projects/letrica-vB0.1/letrica-beta/api/controllers/AcountsController.js:154:9)
Related
I need to delete a tenant and make sure that the tenant is not accessible anymore. Is there a way to validate 'Could not resolve host' i.e. 'Error: getaddrinfo' in Postman as this error is the expected behavior?
When below curl command is executed in a terminal
curl https://invaliddomain1281738012732.com -v
Proper error message is displayed
curl: (6) Could not resolve host: invaliddomain1281738012732.com
But in postman, is there a way to add a test to validate this behavior?
You won't be able to test the validity of the URL by calling it directly and writing a test on the result, from Postman's Learning Center:
Tests will execute after the response is received, so when you click
Send, Postman will run your test script when the response data returns
from the API.
A workaround to that is to query that URL directly from the Tests tab and assert the response there, e.g.:
pm.test("address doesn't exist", function(){
pm.sendRequest('https://invaliddomain1281738012732.com', (error, response) => {
pm.expect(error.errno).to.eql("ENOTFOUND");
});
})
I am trying to make a webhook that get triggered by ATrigger. I tried it but every time it shows error 405, method not allowed.
It works when doing a POST through the server, or through Hurl.it
ATrigger doesn't use POST, it uses GET
I am using JSONAPIAdapter in Ember Data, in case server wants to reject the request, server returns HTTP status code 400 Bad Request with json payload like this:
{"errors":[{"code":"698","title":"Invalid request"}]}
According to the jsonapi.org, I think this is the correct format( a array of error objects keyed by "errors" )
But when I run Ember, I always get a Adapter error. Is my format incorrect?
Getting AdapterError is correct behavior in this case. You can see that your payload from the server is correctly parsed by Ember and errors property of Error object you've logged is populated.
So, your adapter tries for example to get some records, but instead it gets 400 error and it's expected that you will get AdapterError.
If you don't want to get AdapterError you have to change the way your server behaves and instead of rejecting request provide model data.
You can also catch AdapterError if this is expected for you and handle that manually.
I am trying to setup ember.js with QUnit to write integration tests.
Following the directions on http://emberjs.com/guides/testing/integration/ I have:
document.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
App.rootElement = '#ember-testing';
App.setupForTesting();
App.injectTestHelpers();
module("Integration Tests", {
setup: function() {
App.reset();
}
});
test("root lists first page of posts", function(){
visit("/").then(function() {
equal(find(".post").length, 5, "The first page should have 5 posts");
// Assuming we know that 5 posts display per page and that there are more than 5 posts
});
});
However when I run QUnit I get the following error:
Assertion failed: You have turned on testing mode, which disabled the
run-loop's autorun. You will need to wrap any code with asynchronous
side-effects in an Ember.run
This assertion error is triggered because I am making a http request in the app initializer to check if there is a current user session. This returns a 401 error if there is no valid user. (If I force the app to always return 200 for this request, this assertion error does not occur and the tests continue as expected).
I believe the app and API is behaving correctly by returning a http error for an invalid user, and I don't want to change to response to a 200 just to get my tests working. What do I need to do to get ember and QUnit to handle a http error and assertion? From what I've read I need to wrap something with Ember.run, but I can't figure out what.
Your unit and integration tests should ideally run in isolation from external resources (like an HTTP API), so mocking HTTP requests is the easiest pattern.
To get truly full-stack smoke testing, you'll want to exercise the app with browser automation tools like PhantomJS.
I use the App Engine for run my application and want to test how it will handle server errors.
Is there any possibility to simulate an error 500 via the WebTest ?
I got around it using a try except loop.
try:
self.testapp.get('/')
self.assertEqual(1, 2, 'GET request should have resulted in a 405 error') # Purposely fail
except webtest.app.AppError:
pass
Another way is the following:
self.assertEqual("500 Internal Server Error", self.testapp.post('/', params={}, expect_errors=True).status, 'POST Request should have resulted in a 500 error')
Both methods still will cause traceback to appear but the test passes
A 500 error is just what your webapp returns to the client when it gets an uncaught exception. It's not a specific failure - just what it shows to your users when something unexpected goes wrong. Instead, you should unit-test your handlers to ensure they act as expected.