Update checked-in dependencies
This commit is contained in:
parent
35f1961385
commit
17223bdff7
20 changed files with 1756 additions and 646 deletions
73
node_modules/nock/lib/interceptor.js
generated
vendored
73
node_modules/nock/lib/interceptor.js
generated
vendored
|
|
@ -1,8 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
const debug = require('debug')('nock.interceptor')
|
||||
const stringify = require('json-stringify-safe')
|
||||
const _ = require('lodash')
|
||||
const querystring = require('querystring')
|
||||
const { URL, URLSearchParams } = require('url')
|
||||
|
||||
|
|
@ -34,8 +32,9 @@ module.exports = class Interceptor {
|
|||
// When enabled filteringScope ignores the passed URL entirely so we skip validation.
|
||||
|
||||
if (
|
||||
!scope.scopeOptions.filteringScope &&
|
||||
uriIsStr &&
|
||||
!scope.scopeOptions.filteringScope &&
|
||||
!scope.basePathname &&
|
||||
!uri.startsWith('/') &&
|
||||
!uri.startsWith('*')
|
||||
) {
|
||||
|
|
@ -73,7 +72,7 @@ module.exports = class Interceptor {
|
|||
scope.scopeOptions.badheaders || []
|
||||
)
|
||||
|
||||
this.delayInMs = 0
|
||||
this.delayBodyInMs = 0
|
||||
this.delayConnectionInMs = 0
|
||||
|
||||
this.optional = false
|
||||
|
|
@ -181,8 +180,8 @@ module.exports = class Interceptor {
|
|||
}
|
||||
}
|
||||
|
||||
debug('reply.headers:', this.headers)
|
||||
debug('reply.rawHeaders:', this.rawHeaders)
|
||||
this.scope.logger('reply.headers:', this.headers)
|
||||
this.scope.logger('reply.rawHeaders:', this.rawHeaders)
|
||||
|
||||
this.body = body
|
||||
|
||||
|
|
@ -228,13 +227,23 @@ module.exports = class Interceptor {
|
|||
}
|
||||
}
|
||||
|
||||
debug("request header field doesn't match:", key, header, reqHeader)
|
||||
this.scope.logger(
|
||||
"request header field doesn't match:",
|
||||
key,
|
||||
header,
|
||||
reqHeader
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
match(req, options, body) {
|
||||
if (debug.enabled) {
|
||||
debug('match %s, body = %s', stringify(options), stringify(body))
|
||||
// check if the logger is enabled because the stringifies can be expensive.
|
||||
if (this.scope.logger.enabled) {
|
||||
this.scope.logger(
|
||||
'attempting match %s, body = %s',
|
||||
stringify(options),
|
||||
stringify(body)
|
||||
)
|
||||
}
|
||||
|
||||
const method = (options.method || 'GET').toUpperCase()
|
||||
|
|
@ -244,7 +253,7 @@ module.exports = class Interceptor {
|
|||
const { proto } = options
|
||||
|
||||
if (this.method !== method) {
|
||||
debug(
|
||||
this.scope.logger(
|
||||
`Method did not match. Request ${method} Interceptor ${this.method}`
|
||||
)
|
||||
return false
|
||||
|
|
@ -276,6 +285,7 @@ module.exports = class Interceptor {
|
|||
)
|
||||
|
||||
if (!reqHeadersMatch) {
|
||||
this.scope.logger("headers don't match")
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -283,26 +293,32 @@ module.exports = class Interceptor {
|
|||
this.scope.scopeOptions.conditionally &&
|
||||
!this.scope.scopeOptions.conditionally()
|
||||
) {
|
||||
this.scope.logger(
|
||||
'matching failed because Scope.conditionally() did not validate'
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
const reqContainsBadHeaders = this.badheaders.some(
|
||||
const badHeaders = this.badheaders.filter(
|
||||
header => header in options.headers
|
||||
)
|
||||
|
||||
if (reqContainsBadHeaders) {
|
||||
if (badHeaders.length) {
|
||||
this.scope.logger('request contains bad headers', ...badHeaders)
|
||||
return false
|
||||
}
|
||||
|
||||
// Match query strings when using query()
|
||||
if (this.queries === null) {
|
||||
debug('query matching skipped')
|
||||
this.scope.logger('query matching skipped')
|
||||
} else {
|
||||
// can't rely on pathname or search being in the options, but path has a default
|
||||
const [pathname, search] = path.split('?')
|
||||
const matchQueries = this.matchQuery({ search })
|
||||
|
||||
debug(matchQueries ? 'query matching succeeded' : 'query matching failed')
|
||||
this.scope.logger(
|
||||
matchQueries ? 'query matching succeeded' : 'query matching failed'
|
||||
)
|
||||
|
||||
if (!matchQueries) {
|
||||
return false
|
||||
|
|
@ -405,8 +421,8 @@ module.exports = class Interceptor {
|
|||
}
|
||||
|
||||
const reqQueries = querystring.parse(options.search)
|
||||
debug('Interceptor queries: %j', this.queries)
|
||||
debug(' Request queries: %j', reqQueries)
|
||||
this.scope.logger('Interceptor queries: %j', this.queries)
|
||||
this.scope.logger(' Request queries: %j', reqQueries)
|
||||
|
||||
if (typeof this.queries === 'function') {
|
||||
return this.queries(reqQueries)
|
||||
|
|
@ -483,7 +499,7 @@ module.exports = class Interceptor {
|
|||
// Normalize the data into the shape that is matched against.
|
||||
// Duplicate keys are handled by combining the values into an array.
|
||||
queries = querystring.parse(queries.toString())
|
||||
} else if (!_.isPlainObject(queries)) {
|
||||
} else if (!common.isPlainObject(queries)) {
|
||||
throw Error(`Argument Error: ${queries}`)
|
||||
}
|
||||
|
||||
|
|
@ -583,7 +599,7 @@ module.exports = class Interceptor {
|
|||
* @return {Interceptor} - the current interceptor for chaining
|
||||
*/
|
||||
delayBody(ms) {
|
||||
this.delayInMs += ms
|
||||
this.delayBodyInMs = ms
|
||||
return this
|
||||
}
|
||||
|
||||
|
|
@ -594,26 +610,7 @@ module.exports = class Interceptor {
|
|||
* @return {Interceptor} - the current interceptor for chaining
|
||||
*/
|
||||
delayConnection(ms) {
|
||||
this.delayConnectionInMs += ms
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @returns {number}
|
||||
*/
|
||||
getTotalDelay() {
|
||||
return this.delayInMs + this.delayConnectionInMs
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the socket idle for a certain number of ms (simulated).
|
||||
*
|
||||
* @param {integer} ms - Number of milliseconds to wait
|
||||
* @return {Interceptor} - the current interceptor for chaining
|
||||
*/
|
||||
socketDelay(ms) {
|
||||
this.socketDelayInMs = ms
|
||||
this.delayConnectionInMs = ms
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue