test: add test for invalid cookie url (#18751)
Co-Authored-By: Erick Zhao <erick@hotmail.ca>
This commit is contained in:
parent
ba96cdb7dc
commit
ddec3c0e78
2 changed files with 18 additions and 7 deletions
|
@ -84,7 +84,7 @@ the response.
|
||||||
#### `cookies.set(details)`
|
#### `cookies.set(details)`
|
||||||
|
|
||||||
* `details` Object
|
* `details` Object
|
||||||
* `url` String - The url to associate the cookie with.
|
* `url` String - The url to associate the cookie with. An error is thrown if the url is invalid.
|
||||||
* `name` String (optional) - The name of the cookie. Empty by default if omitted.
|
* `name` String (optional) - The name of the cookie. Empty by default if omitted.
|
||||||
* `value` String (optional) - The value of the cookie. Empty by default if omitted.
|
* `value` String (optional) - The value of the cookie. Empty by default if omitted.
|
||||||
* `domain` String (optional) - The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains. Empty by default if omitted.
|
* `domain` String (optional) - The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains. Empty by default if omitted.
|
||||||
|
|
|
@ -88,12 +88,23 @@ describe('session module', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('yields an error when setting a cookie with missing required fields', async () => {
|
it('yields an error when setting a cookie with missing required fields', async () => {
|
||||||
await expect((async () => {
|
|
||||||
const { cookies } = session.defaultSession
|
const { cookies } = session.defaultSession
|
||||||
const name = '1'
|
const name = '1'
|
||||||
const value = '1'
|
const value = '1'
|
||||||
await cookies.set({ url: '', name, value })
|
|
||||||
})()).to.eventually.be.rejectedWith('Failed to get cookie domain')
|
await expect(
|
||||||
|
cookies.set({ url: '', name, value })
|
||||||
|
).to.eventually.be.rejectedWith('Failed to get cookie domain')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('yields an error when setting a cookie with an invalid URL', async () => {
|
||||||
|
const { cookies } = session.defaultSession
|
||||||
|
const name = '1'
|
||||||
|
const value = '1'
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
cookies.set({ url: 'asdf', name, value })
|
||||||
|
).to.eventually.be.rejectedWith('Failed to get cookie domain')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should overwrite previous cookies', async () => {
|
it('should overwrite previous cookies', async () => {
|
||||||
|
|
Loading…
Reference in a new issue