* expose fetchLimitBytes/userAgent in got-config module * export a function not a factory * send better user-agent values - add userAgentBase setting - send short SHA in user agent on heroku - set a version (tag or short SHA) in Dockefile and use it to report server version in UA for docker users * add a comment explaining fileSize Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
36 lines
957 B
JavaScript
36 lines
957 B
JavaScript
import nock from 'nock'
|
|
import config from 'config'
|
|
import { fetch } from '../core/base-service/got.js'
|
|
const runnerConfig = config.util.toObject()
|
|
|
|
function cleanUpNockAfterEach() {
|
|
afterEach(function () {
|
|
nock.restore()
|
|
nock.cleanAll()
|
|
nock.enableNetConnect()
|
|
nock.activate()
|
|
})
|
|
}
|
|
|
|
function noToken(serviceClass) {
|
|
let hasLogged = false
|
|
return () => {
|
|
const userKey = serviceClass.auth.userKey
|
|
const passKey = serviceClass.auth.passKey
|
|
const noToken =
|
|
(userKey && !runnerConfig.private[userKey]) ||
|
|
(passKey && !runnerConfig.private[passKey])
|
|
if (noToken && !hasLogged) {
|
|
console.warn(
|
|
`${serviceClass.name}: no credentials configured, tests for this service will be skipped. Add credentials in local.yml to run them.`
|
|
)
|
|
hasLogged = true
|
|
}
|
|
return noToken
|
|
}
|
|
}
|
|
|
|
const defaultContext = { requestFetcher: fetch }
|
|
|
|
export { cleanUpNockAfterEach, noToken, defaultContext }
|