require_relative "./base" class UserSystemTest < LifePexTest def setup @fixture ||= FixtureReader.new # should be in startup @fixture.apply! "user_base" end def cleanup @fixture.cleanup! end def test_login_generates_cookie data = { username: 'test', password: 'test' } api_post '/api/user/v1/login', data assert last_response.ok? assert_not_empty last_response.headers["Set-Cookie"] end def test_register_and_login data = { username: 'test2', password: 'test' } api_post '/api/user/v1/register', data assert last_response.ok? assert_not_empty last_response.headers["Set-Cookie"] assert_match (/auth=[\-\.\w]+; domain=example.org; path=\//), last_response.headers["Set-Cookie"] end def test_register_refuse_duplicate data = { username: 'test2', password: 'test' } api_post '/api/user/v1/register', data assert last_response.ok? data = { username: 'test2', password: 'test' } api_post '/api/user/v1/register', data refute last_response.ok? end end