我对grails集成进行了以下测试:
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")
}
}
我试图在Postman中安装测试,但我不确定我是否因为发送URLENC而正确执行此操作,[j_username:username,j_password:password]
我把POST类型的路由放在了:
{
j_username: username,
j_password: password
}
标题参数:
'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?
更新
实际上在其他项目中我遵循参考,它运作良好。但是我已经开发了grails响应部分,没有留下api /登录路由,我相信登录是通过相同的web路由/ login / auth完成的,但我不能通过postman验证测试,但是在网上徽标完美。