Implement the basic interface for the Authentication endpoint

* Handle errors as 422
* Require parameters through strong_parameters
* Use a custom rescue_from
This commit is contained in:
Maciej Szlosarczyk 2018-07-19 11:50:40 +03:00
parent 1c6b838b2b
commit dad57ba528
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
4 changed files with 35 additions and 11 deletions

View file

@ -28,6 +28,17 @@ class RegistrantApiAuthenticationTest < ApplicationSystemTestCase
end
def test_request_returns_existing_user
assert_no_changes User.count do
post '/api/v1/registrant/auth/eid', @user_hash
end
end
def test_request_documented_parameters_are_required
params = { foo: :bar, test: :test }
post '/api/v1/registrant/auth/eid', params
json = JSON.parse(response.body, symbolize_names: true)
assert_equal({errors: [{ident: ['parameter is required']}]}, json)
assert_equal(422, response.status)
end
end