-
Notifications
You must be signed in to change notification settings - Fork 59
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
URL Wildcards for hook matching #67
Comments
👍 |
I did start implementing RegExp matching hooks at some point, but for some reason it turned out awkward -- as I remember it, it had something to do with the manner in which the test cases are added. Part of my idea was to have the tests do things in order and keep state in-between, so my tests would be able to e.g. Anyway, until this is implemented, what you can do is create a {beforeEach, after} = require 'hooks'
makeAuth = (username, password) ->
return (new Buffer "#{username}:#{password}").toString 'base64'
username = 'runejuhl'
password = 'testpass'
auth = (new Buffer "#{username}:#{password}").toString 'base64'
# This endpoint generates a new password and returns it in the response. If we
# update the global variable `password`, it'll be used on subsequent requests.
after 'POST /user/{email}/password/generate -> 200', (test, done) ->
password = test.response.body.password
console.log 'new pass', password
done()
beforeEach (test, done) ->
console.log 'before', test.request.path
console.log 'pass is', password
# Don't use Basic auth for endpoints starting with /public
if /^\/public\//.test(test.request.path)
done()
auth = makeAuth(username, password)
test.request.headers['Authorization'] = "Basic #{auth}"
done()
@ProLoser : For your case, you could match on |
I have a long api endpoint:
/browse/items/{browse_type}/filter/{filter_type}/sort/{sort_method}/offset/{offset}/size/{size}:
and I can query it by doingabao browse.raml /browse
but in my hooks just using/browse
will not match this endoint, instead I must specify the full endpoint lenght.It would be nice if I could do either
/browse/*
or if the hooks used substring matches to figure out when they should be applied.Example:
The text was updated successfully, but these errors were encountered: