Tuesday, June 12, 2018

Make Postman test - Grails

Leave a Comment

I have the following test of a grails integration:

def http = new HTTPBuilder(loginUrl) http.request( POST, TEXT ) {     headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4'     send URLENC, [j_username: username, j_password: password]      response.success = { resp, reader ->         loggedIn = ! reader.text.contains("j_username")     } } 

I'm trying to mount the test in Postman, but I'm not sure if I'm doing it correctly because of this send URLENC, [j_username: username, j_password: password]

I put the POST type route, and put something like:

{     j_username: username,     j_password: password } 

And the headers parameters:

'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4' 'Content-type' = 'Application/json' 

But it is always returning my login form in the body, does anyone know how to mount this test?

UPDATE

Actually in other projects I follow the reference and it works well. However I have developed the grails response part, did not leave an api/login route, and I believe that the login is done by the same web route /login/auth, but I can not validate the test by postman, but on the web logo perfectly.

UPDATE 2

I believe that in the project that receives my login request, to try to facilitate, they have made access to the api by the same web, and this request that is mounted in the integration, do not make a json type request, because of "send URLENC", Can someone please explain to me how to put this call in postman?

1 Answers

Answers 1

If you have the default Spring Security and Spring Security REST config, here how I do it :

Body of the Postman call

Header of the Postman call

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment