add test suite

This commit is contained in:
Luna 2022-12-06 15:53:20 -03:00
parent 06924d10f6
commit 5d21c975ea
5 changed files with 160 additions and 45 deletions

View file

@ -0,0 +1,23 @@
TestWebfinger = {}
function TestWebfinger:setup()
self.mod = setupTest('scripts.webfinger_allowlist', {accounts = {'correct@example.org'}})
end
local WEBFINGER_PATH = '/.well-known/webfinger'
function TestWebfinger:testCorrectAccount()
setupFakeRequest(WEBFINGER_PATH, { params = {resource = 'acct:correct@example.org'} })
onRequest()
lu.assertIs(ngx.status, nil)
end
function TestWebfinger:testWrongAccount()
setupFakeRequest(WEBFINGER_PATH, { params = {resource = 'acct:wrong@example.org'} })
onRequest()
lu.assertIs(ngx.status, 404)
end
function TestWebfinger:teardown()
teardownNgx()
end