Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing test: escaping inconsistent to requestInterceptor #1252

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@ describe('constructor', () => {
$ref: 'http://petstore.swagger.io/v2/ref.json#b'
}
))
.get('http://petstore.swagger.io/v2/user/\'', () => ({u: 'quote'})) // Not hit, this is the URL the interceptor sees.
.get('http://petstore.swagger.io/v2/user/%27', () => ({u: 'percent-twentyseven'})) // We actually get this.
})

test('should support request interceptor', (cb) => {
Expand Down Expand Up @@ -646,5 +648,25 @@ describe('constructor', () => {
}).catch(cb)
}
)
test(
'should give the interceptor the URL which actually hits the network',
(cb) => {
new Swagger({
url: 'http://petstore.swagger.io/v2/swagger.json',
requestInterceptor: (req) => {
if (req.url === 'http://petstore.swagger.io/v2/swagger.json') {
return req // skip this
}
expect(req.url).toEqual('http://petstore.swagger.io/v2/user/\'') // Not percent-escaped
return req
}
}).then(client =>
client.apis.user.getUserByName({username: '\''}).then((data) => {
expect(data.body.u).toEqual('quote') // not percent escaped
cb()
})
).catch(cb)
}
)
})
})