mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-01 00:24:08 +00:00
45 lines
975 B
Plaintext
45 lines
975 B
Plaintext
meta {
|
|
name: getCookie
|
|
type: http
|
|
seq: 1
|
|
}
|
|
|
|
get {
|
|
url: {{host}}/ping
|
|
body: none
|
|
auth: inherit
|
|
}
|
|
|
|
script:pre-request {
|
|
const jar = bru.cookies.jar()
|
|
|
|
jar.setCookie("https://testbench-sanity.usebruno.com", "name", "value")
|
|
}
|
|
|
|
tests {
|
|
const jar = bru.cookies.jar()
|
|
|
|
jar.getCookie("https://testbench-sanity.usebruno.com", "name", function(error, data) {
|
|
if(error) {
|
|
console.error("Cookie retrieval error:", error)
|
|
throw new Error(`Failed to get cookie: ${error.message || error}`)
|
|
}
|
|
|
|
test("should successfully retrieve cookie data", function() {
|
|
expect(data).to.have.property('key');
|
|
expect(data).to.have.property('value');
|
|
expect(data.key).to.equal("name");
|
|
expect(data.value).to.be.a('string');
|
|
expect(data.value).to.not.be.empty;
|
|
expect(data.domain).to.include('usebruno.com');
|
|
console.log("Retrieved cookie:", data);
|
|
});
|
|
})
|
|
|
|
jar.clear()
|
|
}
|
|
|
|
settings {
|
|
encodeUrl: true
|
|
}
|