70 lines
1.8 KiB
Lua
70 lines
1.8 KiB
Lua
_G.spy = spy
|
|
local mock_env = require("spec.env_mock")
|
|
local rng = require("spec.fuzzgen")
|
|
|
|
describe("smr biography",function()
|
|
setup(mock_env.setup)
|
|
teardown(mock_env.teardown)
|
|
it("should allow users to set their biography",function()
|
|
local claim_post = require("endpoints.claim_post")
|
|
local login_post = require("endpoints.login_post")
|
|
local index_get = require("endpoints.index_get")
|
|
local bio_get = require("endpoints.bio_get")
|
|
local bio_post = require("endpoints.bio_post")
|
|
local db = require("db")
|
|
local config = require("config")
|
|
config.domain = "test.host"
|
|
configure()
|
|
local username = rng.subdomain()
|
|
local claim_req = {
|
|
method = "POST",
|
|
host = "test.host",
|
|
path = "/_claim",
|
|
args = {
|
|
user = username
|
|
}
|
|
}
|
|
claim_post(claim_req)
|
|
local login_req = {
|
|
method = "POST",
|
|
host = "test.host",
|
|
path = "/_login",
|
|
args = {
|
|
user = username
|
|
},
|
|
file = {
|
|
pass = claim_req.response
|
|
}
|
|
}
|
|
login_post(login_req)
|
|
local cookie = login_req.response_headers["set-cookie"]
|
|
local sessionid = cookie:match("session=([^;]+)")
|
|
local home_req_get = {
|
|
method = "GET",
|
|
host = username .. ".test.host",
|
|
path = "/",
|
|
cookies = {
|
|
session = sessionid
|
|
}
|
|
}
|
|
index_get(home_req_get)
|
|
local edit_bio_button = '<a href="/_bio"'
|
|
assert(
|
|
home_req_get.response:find(edit_bio_button),
|
|
"After logging in the user should have a button to" ..
|
|
" edit their biography. Looking for " .. edit_bio_button
|
|
.. " but didn't find it in " .. home_req_get.response
|
|
)
|
|
local edit_bio_req_get = {
|
|
method = "GET",
|
|
host = username .. ".test.host",
|
|
path = "/_bio",
|
|
cookies = {session = sessionid},
|
|
args = {}
|
|
}
|
|
bio_get(edit_bio_req_get)
|
|
assert(edit_bio_req_get.responsecode == 200)
|
|
assert(edit_bio_req_get.response:find("<textarea"))
|
|
end)
|
|
end)
|