Add auth-token class

This commit is contained in:
Maciej Szlosarczyk 2018-07-19 10:31:31 +03:00
parent d67e777ea8
commit 1c6b838b2b
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
5 changed files with 65 additions and 6 deletions

View file

@ -4,6 +4,8 @@ class RegistrantApiAuthenticationTest < ApplicationSystemTestCase
def setup
super
@user_hash = {ident: "37010100049", first_name: 'Adam', last_name: 'Baker'}
@existing_user = RegistrantUser.find_or_create_by_api_data(@user_hash)
end
def teardown
@ -14,11 +16,18 @@ class RegistrantApiAuthenticationTest < ApplicationSystemTestCase
def test_request_creates_user_when_one_does_not_exist
params = {
ident: "30110100103",
first_name: "Jan",
last_name: "Tamm",
country: "ee",
first_name: "John",
last_name: "Smith",
}
post '/api/v1/registrant/auth/eid', params
assert(User.find_by(registrant_ident: 'EE-30110100103'))
json = JSON.parse(response.body, symbolize_names: true)
assert_equal([:access_token, :expires_at, :type], json.keys)
end
def test_request_returns_existing_user
end
end