change endpoint

This commit is contained in:
Oleg Hasjanov 2021-07-29 12:50:01 +03:00 committed by olegphenomenon
parent 36e9aac1d3
commit f6e46b8fe6
3 changed files with 7 additions and 7 deletions

View file

@ -0,0 +1,33 @@
require 'test_helper'
class ReppV1AccreditationInfoTest < ActionDispatch::IntegrationTest
def setup
@user = users(:api_bestnames)
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
end
def test_valid_login
get '/repp/v1/registrar/accreditation_info', headers: @auth_headers
json = JSON.parse(response.body, symbolize_names: true)
assert_response :ok
assert_equal json[:data][:username], @user.username
assert_equal json[:data][:identity_code], @user.identity_code
end
def test_invalid_login
token = Base64.encode64("#{@user.username}:0066600")
token = "Basic #{token}"
auth_headers = { 'Authorization' => token }
get '/repp/v1/registrar/accreditation_info', headers: auth_headers
json = JSON.parse(response.body, symbolize_names: true)
assert_response :unauthorized
assert_equal json[:message], 'Invalid authorization information'
end
end