2
我正在進行需要身份驗證的集成測試。 會話狀態(即Cookie)似乎不會被請求保持。 有沒有CookieManager或類似的東西?如何使用Groovy HttpBuilder在兩個請求之間保持會話狀態
@Test
public void whenAuthenticatedUserRequestAForbiddenUrlShouldObtain403() {
def client = new RESTClient('http://127.0.0.1:8080/app/')
def login = client .post(
path: 'api/login.json',
body: [j_username: 'user', j_password: 'test'],
requestContentType: ContentType.URLENC)
def resp = client .get(path: 'forbidden-url')
assert (resp.status == 403)
==> FAILS status = 200
}